Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
46b0535c
Commit
46b0535c
authored
Jul 01, 2014
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed locale when changing it on the translator itself
parent
8d2140c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
src/Silex/Translator.php
src/Silex/Translator.php
+7
-0
tests/Silex/Tests/Provider/TranslationServiceProviderTest.php
...s/Silex/Tests/Provider/TranslationServiceProviderTest.php
+12
-0
No files found.
src/Silex/Translator.php
View file @
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
);
}
}
}
tests/Silex/Tests/Provider/TranslationServiceProviderTest.php
View file @
46b0535c
...
@@ -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'
]);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment