Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Translation][FrameworkBundle] Adding Translation Providers #37462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Modified POEditor Provider to use xlf export
  • Loading branch information
welcoMattic committed Sep 28, 2020
commit 26050f6b8c916000e869e85ef28823a5785c902d
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@
->set('translator.formatter.default', MessageFormatter::class)
->args([service('identity_translator')])

->set('translation.loader.array', ArrayLoader::class)
->tag('translation.loader', ['alias' => 'array'])

->set('translation.loader.php', PhpFileLoader::class)
->tag('translation.loader', ['alias' => 'php'])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

->set('translation.provider_factory.poeditor', PoEditorProviderFactory::class)
->args([
service('translation.loader.array'),
service('translation.loader.xliff_raw'),
])
->parent('translation.provider_factory.abstract')
->tag('translation.provider_factory')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,7 @@ public function read(array $domains, array $locales): TranslatorBag
'api_token' => $this->apiKey,
'id' => $this->projectId,
'language' => $locale,
/*
* POEditor XLF export not support Terms as <source>.
* The source tag is either empty or equals to Default Language Reference translation.
* This is why we have to export in json, parse it, and load it with ArrayLoader.
*/
'type' => 'key_value_json',
'type' => 'xlf',
'filters' => json_encode(['translated']),
'tags' => json_encode($domains),
],
Expand All @@ -114,18 +109,8 @@ public function read(array $domains, array $locales): TranslatorBag
'headers' => $this->getDefaultHeaders(),
]);

$responseContent = json_decode($response->getContent(), true);

$content = [];

foreach ($responseContent as $translation) {
$content += $translation;
}

if ($responseContent) {
foreach ($domains as $domain) {
$translatorBag->addCatalogue($this->loader->load($content, $locale, $domain));
}
foreach ($domains as $domain) {
$translatorBag->addCatalogue($this->loader->load($response->getContent(), $locale, $domain));
}
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.