Skip to content

Commit 3edde4b

Browse files
committed
Handle emulator cases where countryCode is empty
1 parent 03a7aa8 commit 3edde4b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

android/src/main/java/com/reactcommunity/rnlocalize/RNLocalizeModule.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,18 @@ private static String getLanguageCode(Locale locale) {
158158

159159
private static String getCountryCode(Locale locale, String fallback) {
160160
String countryCode = locale.getCountry();
161-
return countryCode != null ? countryCode : fallback;
161+
return countryCode == null || countryCode.equals("") ? fallback : countryCode;
162162
}
163163

164164
private static String getCurrencyCode(Locale locale, String fallback) {
165+
String countryCode = locale.getCountry();
166+
167+
if (countryCode == null || countryCode.equals("")) {
168+
return fallback;
169+
}
170+
165171
Currency currency = Currency.getInstance(locale);
166-
return currency != null ? currency.getCurrencyCode() : fallback;
172+
return currency == null ? fallback : currency.getCurrencyCode();
167173
}
168174

169175
private static boolean getIsRTL(Locale locale) {

0 commit comments

Comments
 (0)