Skip to content

Commit

Permalink
Using converter (#3)
Browse files Browse the repository at this point in the history
* Bugfix

* Style fix

* Added change log

* Added branch alias

* Using converter
  • Loading branch information
Nyholm committed Jan 3, 2017
1 parent fa5eef3 commit 15173ab
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
19 changes: 19 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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


7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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"
}
}
}
15 changes: 6 additions & 9 deletions src/Loco.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
}
}
Expand All @@ -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]);
}
}

Expand Down

0 comments on commit 15173ab

Please sign in to comment.