From 15173ab073b0f7169dc04253aa8f62e1926ec9ec Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 3 Jan 2017 09:47:42 +0100 Subject: [PATCH] Using converter (#3) * Bugfix * Style fix * Added change log * Added branch alias * Using converter --- Changelog.md | 19 +++++++++++++++++++ composer.json | 7 +++++++ src/Loco.php | 15 ++++++--------- 3 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 Changelog.md diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..9862f99 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,19 @@ +# Change Log + +The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. + +## 0.2.0 + +### Added + +- Added support for `TransferableStorage` + +### Changed + +- `Loco::getApiKey()` is now private + +## 0.1.0 + +Init release + + diff --git a/composer.json b/composer.json index c7419b8..6a408b4 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "require": { "php": "^7.0", "php-translation/common": "^0.2", + "php-translation/symfony-storage": "^0.2", "symfony/translation": "^2.7 || ^3.0", "friendsofapi/localise.biz": "^0.2" }, @@ -35,5 +36,11 @@ "scripts": { "test": "vendor/bin/phpunit", "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } } } diff --git a/src/Loco.php b/src/Loco.php index f2a4a8e..8fe96da 100644 --- a/src/Loco.php +++ b/src/Loco.php @@ -14,12 +14,12 @@ use FAPI\Localise\Exception\Domain\AssetConflictException; use FAPI\Localise\Exception\Domain\NotFoundException; use FAPI\Localise\LocoClient; -use Symfony\Component\Translation\Loader\ArrayLoader; use Symfony\Component\Translation\MessageCatalogueInterface; use Translation\Common\Exception\StorageException; use Translation\Common\Model\Message; use Translation\Common\Storage; use Translation\Common\TransferableStorage; +use Translation\SymfonyStorage\XliffConverter; /** * Localize.biz. @@ -131,19 +131,16 @@ public function delete($locale, $domain, $key) public function export(MessageCatalogueInterface $catalogue) { $locale = $catalogue->getLocale(); - $loader = new ArrayLoader(); foreach ($this->domainToProjectId as $domain => $projectKey) { try { $data = $this->client->export()->locale( $projectKey, $locale, - 'json', + 'xliff', ['format' => 'symfony'] ); - $array = json_decode($data, true); - $catalogue->addCatalogue( - $loader->load($array, $locale, $domain) - ); + + $catalogue->addCatalogue(XliffConverter::contentToCatalogue($data, $locale, $domain)); } catch (NotFoundException $e) { } } @@ -156,8 +153,8 @@ public function import(MessageCatalogueInterface $catalogue) { $locale = $catalogue->getLocale(); foreach ($this->domainToProjectId as $domain => $projectKey) { - $data = json_encode($catalogue->all($domain)); - $this->client->import()->import($projectKey, 'json', $data, ['locale' => $locale, 'async' => 1]); + $data = XliffConverter::catalogueToContent($catalogue, $domain); + $this->client->import()->import($projectKey, 'xliff', $data, ['locale' => $locale, 'async' => 1]); } }