10
10
*/
11
11
class Format implements \Magento \Framework \Locale \FormatInterface
12
12
{
13
+ /**
14
+ * Japan locale code
15
+ */
16
+ private const JAPAN_LOCALE_CODE = 'ja_JP ' ;
17
+
13
18
/**
14
19
* @var \Magento\Framework\App\ScopeResolverInterface
15
20
*/
@@ -25,11 +30,6 @@ class Format implements \Magento\Framework\Locale\FormatInterface
25
30
*/
26
31
protected $ currencyFactory ;
27
32
28
- /**
29
- * @var array
30
- */
31
- private $ groupSeparatorByLocale = [];
32
-
33
33
/**
34
34
* @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
35
35
* @param ResolverInterface $localeResolver
@@ -87,12 +87,14 @@ public function getNumber($value)
87
87
}
88
88
} elseif ($ separatorComa !== false ) {
89
89
$ locale = $ this ->_localeResolver ->getLocale ();
90
- $ groupSeparator = $ this ->retrieveLocaleGroupSeparator ($ locale );
91
- if ($ groupSeparator === ', ' ) {
92
- $ value = str_replace (', ' , '' , $ value );
93
- } else {
94
- $ value = str_replace (', ' , '. ' , $ value );
95
- }
90
+ /**
91
+ * It's hard code for Japan locale.
92
+ * Comma separator uses as group separator: 4,000 saves as 4,000.00
93
+ */
94
+ $ value = str_replace (
95
+ ', ' ,
96
+ $ locale === self ::JAPAN_LOCALE_CODE ? '' : '. ' ,
97
+ $ value );
96
98
}
97
99
98
100
return (float )$ value ;
@@ -160,22 +162,4 @@ public function getPriceFormat($localeCode = null, $currencyCode = null)
160
162
161
163
return $ result ;
162
164
}
163
-
164
- /**
165
- * Retrieve group separator symbol by locale
166
- *
167
- * @param string $locale
168
- * @return string
169
- */
170
- private function retrieveLocaleGroupSeparator (string $ locale ): string
171
- {
172
- if (!array_key_exists ($ locale , $ this ->groupSeparatorByLocale )) {
173
- $ formatter = new \NumberFormatter ($ locale , \NumberFormatter::DECIMAL );
174
- $ this ->groupSeparatorByLocale [$ locale ] = $ formatter ->getSymbol (
175
- \NumberFormatter::GROUPING_SEPARATOR_SYMBOL
176
- );
177
- }
178
-
179
- return $ this ->groupSeparatorByLocale [$ locale ];
180
- }
181
165
}
0 commit comments