@@ -45,39 +45,45 @@ public function testTransWithoutCaching()
4545 {
4646 $ translator = $ this ->getTranslator ($ this ->getLoader ());
4747 $ translator ->setLocale ('fr ' );
48- $ translator ->setFallbackLocale (array ('en ' , 'es ' ));
48+ $ translator ->setFallbackLocale (array ('en ' , 'es ' , ' pt-PT ' , ' pt_BR ' ));
4949
5050 $ this ->assertEquals ('foo (FR) ' , $ translator ->trans ('foo ' ));
5151 $ this ->assertEquals ('bar (EN) ' , $ translator ->trans ('bar ' ));
5252 $ this ->assertEquals ('foobar (ES) ' , $ translator ->trans ('foobar ' ));
5353 $ this ->assertEquals ('choice 0 (EN) ' , $ translator ->transChoice ('choice ' , 0 ));
5454 $ this ->assertEquals ('no translation ' , $ translator ->trans ('no translation ' ));
55+ $ this ->assertEquals ('foobarfoo (PT-PT) ' , $ translator ->trans ('foobarfoo ' ));
56+ $ this ->assertEquals ('other choice 1 (PT-BR) ' , $ translator ->transChoice ('other choice ' , 1 ));
5557 }
5658
5759 public function testTransWithCaching ()
5860 {
5961 // prime the cache
6062 $ translator = $ this ->getTranslator ($ this ->getLoader (), array ('cache_dir ' => $ this ->tmpDir ));
6163 $ translator ->setLocale ('fr ' );
62- $ translator ->setFallbackLocale (array ('en ' , 'es ' ));
64+ $ translator ->setFallbackLocale (array ('en ' , 'es ' , ' pt-PT ' , ' pt_BR ' ));
6365
6466 $ this ->assertEquals ('foo (FR) ' , $ translator ->trans ('foo ' ));
6567 $ this ->assertEquals ('bar (EN) ' , $ translator ->trans ('bar ' ));
6668 $ this ->assertEquals ('foobar (ES) ' , $ translator ->trans ('foobar ' ));
6769 $ this ->assertEquals ('choice 0 (EN) ' , $ translator ->transChoice ('choice ' , 0 ));
6870 $ this ->assertEquals ('no translation ' , $ translator ->trans ('no translation ' ));
71+ $ this ->assertEquals ('foobarfoo (PT-PT) ' , $ translator ->trans ('foobarfoo ' ));
72+ $ this ->assertEquals ('other choice 1 (PT-BR) ' , $ translator ->transChoice ('other choice ' , 1 ));
6973
7074 // do it another time as the cache is primed now
7175 $ loader = $ this ->getMock ('Symfony\Component\Translation\Loader\LoaderInterface ' );
7276 $ translator = $ this ->getTranslator ($ loader , array ('cache_dir ' => $ this ->tmpDir ));
7377 $ translator ->setLocale ('fr ' );
74- $ translator ->setFallbackLocale (array ('en ' , 'es ' ));
78+ $ translator ->setFallbackLocale (array ('en ' , 'es ' , ' pt-PT ' , ' pt_BR ' ));
7579
7680 $ this ->assertEquals ('foo (FR) ' , $ translator ->trans ('foo ' ));
7781 $ this ->assertEquals ('bar (EN) ' , $ translator ->trans ('bar ' ));
7882 $ this ->assertEquals ('foobar (ES) ' , $ translator ->trans ('foobar ' ));
7983 $ this ->assertEquals ('choice 0 (EN) ' , $ translator ->transChoice ('choice ' , 0 ));
8084 $ this ->assertEquals ('no translation ' , $ translator ->trans ('no translation ' ));
85+ $ this ->assertEquals ('foobarfoo (PT-PT) ' , $ translator ->trans ('foobarfoo ' ));
86+ $ this ->assertEquals ('other choice 1 (PT-BR) ' , $ translator ->transChoice ('other choice ' , 1 ));
8187 }
8288
8389 public function testGetLocale ()
@@ -155,6 +161,20 @@ protected function getLoader()
155161 'foobar ' => 'foobar (ES) ' ,
156162 ))))
157163 ;
164+ $ loader
165+ ->expects ($ this ->at (3 ))
166+ ->method ('load ' )
167+ ->will ($ this ->returnValue ($ this ->getCatalogue ('pt-PT ' , array (
168+ 'foobarfoo ' => 'foobarfoo (PT-PT) ' ,
169+ ))))
170+ ;
171+ $ loader
172+ ->expects ($ this ->at (4 ))
173+ ->method ('load ' )
174+ ->will ($ this ->returnValue ($ this ->getCatalogue ('pt_BR ' , array (
175+ 'other choice ' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR) ' ,
176+ ))))
177+ ;
158178
159179 return $ loader ;
160180 }
@@ -183,6 +203,8 @@ public function getTranslator($loader, $options = array())
183203 $ translator ->addResource ('loader ' , 'foo ' , 'fr ' );
184204 $ translator ->addResource ('loader ' , 'foo ' , 'en ' );
185205 $ translator ->addResource ('loader ' , 'foo ' , 'es ' );
206+ $ translator ->addResource ('loader ' , 'foo ' , 'pt-PT ' ); // European Portuguese
207+ $ translator ->addResource ('loader ' , 'foo ' , 'pt_BR ' ); // Brazilian Portuguese
186208
187209 return $ translator ;
188210 }
0 commit comments