Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf0bb7a3

Browse files
Add a Special Case for Translating Choices in en_US_POSIX
See#42036This adds a special case similar to `pt_BR` for handling `en_US_POSIX`which is set as the default locale on some operating systems (AlpineLinux, for instance).
1 parent7253299 commitf0bb7a3

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

‎src/Symfony/Component/Translation/PluralizationRules.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function get($number, $locale/*, bool $triggerDeprecation = true*/
4343
$locale ='xbr';
4444
}
4545

46-
if (\strlen($locale) >3) {
46+
if ('en_US_POSIX' !==$locale &&\strlen($locale) >3) {
4747
$locale =substr($locale,0, -\strlen(strrchr($locale,'_')));
4848
}
4949

@@ -88,6 +88,7 @@ public static function get($number, $locale/*, bool $triggerDeprecation = true*/
8888
case'de':
8989
case'el':
9090
case'en':
91+
case'en_US_POSIX':
9192
case'eo':
9293
case'es':
9394
case'et':

‎src/Symfony/Contracts/Translation/Test/TranslatorTest.php‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ public function testTransChoiceWithDefaultLocale($expected, $id, $number)
8080
$this->assertEquals($expected,$translator->trans($id, ['%count%' =>$number]));
8181
}
8282

83+
/**
84+
* @dataProvider getTransChoiceTests
85+
*/
86+
publicfunctiontestTransChoiceWithEnUsPosix($expected,$id,$number)
87+
{
88+
$translator =$this->getTranslator();
89+
$translator->setLocale('en_US_POSIX');
90+
91+
$this->assertEquals($expected,$translator->trans($id, ['%count%' =>$number]));
92+
}
93+
8394
publicfunctiontestGetSetLocale()
8495
{
8596
$translator =$this->getTranslator();
@@ -296,7 +307,7 @@ public function successLangcodes()
296307
{
297308
return [
298309
['1', ['ay','bo','cgg','dz','id','ja','jbo','ka','kk','km','ko','ky']],
299-
['2', ['nl','fr','en','de','de_GE','hy','hy_AM']],
310+
['2', ['nl','fr','en','de','de_GE','hy','hy_AM','en_US_POSIX']],
300311
['3', ['be','bs','cs','hr']],
301312
['4', ['cy','mt','sl']],
302313
['6', ['ar']],

‎src/Symfony/Contracts/Translation/TranslatorTrait.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private function getPluralizationRule(float $number, string $locale): int
140140
{
141141
$number =abs($number);
142142

143-
switch ('pt_BR' !==$locale &&\strlen($locale) >3 ?substr($locale,0,strrpos($locale,'_')) :$locale) {
143+
switch ('pt_BR' !==$locale &&'en_US_POSIX' !==$locale &&\strlen($locale) >3 ?substr($locale,0,strrpos($locale,'_')) :$locale) {
144144
case'af':
145145
case'bn':
146146
case'bg':
@@ -149,6 +149,7 @@ private function getPluralizationRule(float $number, string $locale): int
149149
case'de':
150150
case'el':
151151
case'en':
152+
case'en_US_POSIX':
152153
case'eo':
153154
case'es':
154155
case'et':

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp