Skip to content

Commit

Permalink
BUGFIX: Restore XLIFF translation fallback: Use canonical string cast…
Browse files Browse the repository at this point in the history
… and add comment

* `$locale` is now cast the way it is in `\Neos\Flow\I18n\Service`
* Added a small comment why the locale chain is reversed
  • Loading branch information
fritjofbohm committed Oct 20, 2017
1 parent f9c49f7 commit 2f0a48c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Neos.Flow/Classes/I18n/Xliff/Service/XliffFileProvider.php
Expand Up @@ -94,11 +94,12 @@ public function initializeObject()
*/
public function getMergedFileData($fileId, Locale $locale): array
{
if (!isset($this->files[$fileId][$locale->__toString()])) {
if (!isset($this->files[$fileId][(string)$locale])) {
$parsedData = [
'fileIdentifier' => $fileId
];
$localeChain = $this->localizationService->getLocaleChain($locale);
// Walk locale chain in reverse, so that translations higher in the chain overwrite fallback translations
foreach (array_reverse($localeChain) as $localeChainItem) {
foreach ($this->packageManager->getActivePackages() as $package) {
/** @var PackageInterface $package */
Expand All @@ -112,11 +113,11 @@ public function getMergedFileData($fileId, Locale $locale): array
if (is_dir($generalTranslationPath)) {
$this->readDirectoryRecursively(FLOW_PATH_DATA . 'Translations', $parsedData, $fileId);
}
$this->files[$fileId][$locale->__toString()] = $parsedData;
$this->files[$fileId][(string)$locale] = $parsedData;
$this->cache->set('translationFiles', $this->files);
}

return $this->files[$fileId][$locale->__toString()];
return $this->files[$fileId][(string)$locale];
}

/**
Expand Down

0 comments on commit 2f0a48c

Please sign in to comment.