Commit 2dcb2b1e authored by Fabien Potencier's avatar Fabien Potencier

bug #975 fixed locale when changing it on the translator itself (fabpot)

This PR was merged into the 1.2 branch.

Discussion
----------

fixed locale when changing it on the translator itself

should fix #887 and #905

Commits
-------

46b0535c fixed locale when changing it on the translator itself
parents 8d2140c0 46b0535c
...@@ -34,4 +34,11 @@ class Translator extends BaseTranslator ...@@ -34,4 +34,11 @@ class Translator extends BaseTranslator
{ {
return $this->app['locale']; return $this->app['locale'];
} }
public function setLocale($locale)
{
$this->app['locale'] = $locale;
parent::setLocale($locale);
}
} }
...@@ -135,4 +135,16 @@ class TranslationServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -135,4 +135,16 @@ class TranslationServiceProviderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('The german translation', $app['translator']->trans('key1')); $this->assertEquals('The german translation', $app['translator']->trans('key1'));
} }
public function testChangingLocaleViaTranslator()
{
$app = $this->getPreparedApp();
$this->assertEquals('The translation', $app['translator']->trans('key1'));
$app['translator']->setLocale('de');
$this->assertEquals('The german translation', $app['translator']->trans('key1'));
$this->assertEquals('de', $app['locale']);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment