@@ -86,13 +86,15 @@ private static function getPattern($currency)
86
86
if (!$ currency ) {
87
87
return '{{ widget }} ' ;
88
88
}
89
+
90
+ $ locale = \Locale::getDefault ();
89
91
90
- if (!isset (self ::$ patterns [\Locale:: getDefault () ])) {
91
- self ::$ patterns [\Locale:: getDefault () ] = array ();
92
+ if (!isset (self ::$ patterns [$ locale ])) {
93
+ self ::$ patterns [$ locale ] = array ();
92
94
}
93
95
94
- if (!isset (self ::$ patterns [\Locale:: getDefault () ][$ currency ])) {
95
- $ format = new \NumberFormatter (\Locale:: getDefault () , \NumberFormatter::CURRENCY );
96
+ if (!isset (self ::$ patterns [$ locale ][$ currency ])) {
97
+ $ format = new \NumberFormatter ($ locale , \NumberFormatter::CURRENCY );
96
98
$ pattern = $ format ->formatCurrency ('123 ' , $ currency );
97
99
98
100
// the spacings between currency symbol and number are ignored, because
@@ -104,14 +106,14 @@ private static function getPattern($currency)
104
106
preg_match ('/^([^\s\xc2\xa0]*)[\s\xc2\xa0]*123(?:[,.]0+)?[\s\xc2\xa0]*([^\s\xc2\xa0]*)$/u ' , $ pattern , $ matches );
105
107
106
108
if (!empty ($ matches [1 ])) {
107
- self ::$ patterns [\Locale:: getDefault () ] = $ matches [1 ].' {{ widget }} ' ;
109
+ self ::$ patterns [$ locale ][ $ currency ] = $ matches [1 ].' {{ widget }} ' ;
108
110
} elseif (!empty ($ matches [2 ])) {
109
- self ::$ patterns [\Locale:: getDefault () ] = '{{ widget }} ' .$ matches [2 ];
111
+ self ::$ patterns [$ locale ][ $ currency ] = '{{ widget }} ' .$ matches [2 ];
110
112
} else {
111
- self ::$ patterns [\Locale:: getDefault () ] = '{{ widget }} ' ;
113
+ self ::$ patterns [$ locale ][ $ currency ] = '{{ widget }} ' ;
112
114
}
113
115
}
114
116
115
- return self ::$ patterns [\Locale:: getDefault () ];
117
+ return self ::$ patterns [$ locale ][ $ currency ];
116
118
}
117
119
}
0 commit comments