Skip to content

Commit a9dd80c

Browse files
Fix unsupported data type Locale
1 parent fbac8d8 commit a9dd80c

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ public void addTags(String tags) {
112112
/**
113113
* Change Locale of Instabug UI elements(defaults to English)
114114
*
115-
* @param languageTag
115+
* @param String instabugLocale
116116
*/
117117
@ReactMethod
118-
public void changeLocale(Locale languageTag) {
118+
public void changeLocale(String instabugLocale) {
119119
try {
120-
mInstabug.changeLocale(languageTag);
120+
mInstabug.changeLocale(getLocaleByKey(instabugLocale));
121121
} catch (Exception e) {
122122
e.printStackTrace();
123123
}
@@ -395,11 +395,53 @@ public void setDebugEnabled(boolean isDebugEnabled) {
395395
e.printStackTrace();
396396
}
397397
}
398-
398+
399+
private Locale getLocaleByKey(String instabugLocale) {
400+
String localeInLowerCase=instabugLocale.toLowerCase();
401+
switch (localeInLowerCase){
402+
case "arabic":
403+
return new Locale(InstabugLocale.ARABIC.getCode(), InstabugLocale.ARABIC.getCountry());
404+
case "english":
405+
return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry());
406+
case "czech":
407+
return new Locale(InstabugLocale.CZECH.getCode(), InstabugLocale.CZECH.getCountry());
408+
case "french":
409+
return new Locale(InstabugLocale.FRENCH.getCode(), InstabugLocale.FRENCH.getCountry());
410+
case "german":
411+
return new Locale(InstabugLocale.GERMAN.getCode(), InstabugLocale.GERMAN.getCountry());
412+
case "italian":
413+
return new Locale(InstabugLocale.ITALIAN.getCode(), InstabugLocale.ITALIAN.getCountry());
414+
case "japanese":
415+
return new Locale(InstabugLocale.JAPANESE.getCode(), InstabugLocale.JAPANESE.getCountry());
416+
case "polish":
417+
return new Locale(InstabugLocale.POLISH.getCode(), InstabugLocale.POLISH.getCountry());
418+
case "russian":
419+
return new Locale(InstabugLocale.RUSSIAN.getCode(), InstabugLocale.RUSSIAN.getCountry());
420+
case "spanish":
421+
return new Locale(InstabugLocale.SPANISH.getCode(), InstabugLocale.SPANISH.getCountry());
422+
case "swedish":
423+
return new Locale(InstabugLocale.SWEDISH.getCode(), InstabugLocale.SWEDISH.getCountry());
424+
case "turkish":
425+
return new Locale(InstabugLocale.TURKISH.getCode(), InstabugLocale.TURKISH.getCountry());
426+
case "portuguesebrazil":
427+
return new Locale(InstabugLocale.PORTUGUESE_BRAZIL.getCode(), InstabugLocale.PORTUGUESE_BRAZIL.getCountry());
428+
case "chinesesimplified":
429+
return new Locale(InstabugLocale.SIMPLIFIED_CHINESE.getCode(), InstabugLocale.SIMPLIFIED_CHINESE.getCountry());
430+
case "chinesetraditional":
431+
return new Locale(InstabugLocale.TRADITIONAL_CHINESE.getCode(), InstabugLocale.TRADITIONAL_CHINESE.getCountry());
432+
case "korean":
433+
return new Locale(InstabugLocale.KOREAN.getCode(), InstabugLocale.KOREAN.getCountry());
434+
default:
435+
return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry());
436+
437+
}
438+
}
399439

400440
@Override
401441
public Map<String, Object> getConstants() {
402442
final Map<String, Object> constants = new HashMap<>();
403443
return constants;
404-
}
405-
}
444+
445+
}
446+
}
447+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{
33
"name": "instabug-reactnative",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"description": "React Native plugin for integrating the Instabug SDK",
66
"main": "index.js",
77
"scripts": {

0 commit comments

Comments
 (0)