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] Fixed the addition of the fallbackLocale catalogue to the current locale catalogue. #116

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

Merged
3 commits merged into from
Feb 27, 2011
Merged
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
[Translation] Fixed the addition of the fallbackLocale catalogue to t…
…he current locale catalogue.

When loading a catalogue the function "optimizeCatalogue" add the fallback catalogue to the current locale catalogue. This should be done by first adding the language catalogue and finally adding the fallbacklocale catalogue specified in the configuration. This subsequent additions are done by the "loadCatalogue" function.

The problem is that in the "loadCatalogue" function exists an if statement that checks if the resource of a given locale exists before loading it. If not, the function simply returns. This return implies that the subsequent addition of the fallbacklocale wouldn't be done.

This has been fixed by simply replacing the current if statement and adding a new one that, if the resource exists, then executes the process of resource loading. Finally, the function continue calling the "optimizeCatalogue" function.
  • Loading branch information
cgonzalez committed Feb 27, 2011
commit 381d1e2da1410ddf8c9e2da07b4e4b8e1344adb7
23 changes: 7 additions & 16 deletions 23 src/Symfony/Component/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,6 @@ public function trans($id, array $parameters = array(), $domain = 'messages', $l
$this->loadCatalogue($locale);
}

if(!$this->catalogues[$locale]->has($id, $domain)) {

$locale = $this->fallbackLocale;

if (!isset($this->catalogues[$locale])) {
$this->loadCatalogue($locale);
}
}

return strtr($this->catalogues[$locale]->get($id, $domain), $parameters);
}

Expand All @@ -143,15 +134,15 @@ public function transChoice($id, $number, array $parameters = array(), $domain =
protected function loadCatalogue($locale)
{
$this->catalogues[$locale] = new MessageCatalogue($locale);
if (!isset($this->resources[$locale])) {
return;
}

foreach ($this->resources[$locale] as $resource) {
if (!isset($this->loaders[$resource[0]])) {
throw new \RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0]));
if (isset($this->resources[$locale])) {

foreach ($this->resources[$locale] as $resource) {
if (!isset($this->loaders[$resource[0]])) {
throw new \RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0]));
}
$this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2]));
}
$this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2]));
}

$this->optimizeCatalogue($locale);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.