@@ -112,12 +112,12 @@ public void addTags(String tags) {
112
112
/**
113
113
* Change Locale of Instabug UI elements(defaults to English)
114
114
*
115
- * @param languageTag
115
+ * @param String instabugLocale
116
116
*/
117
117
@ ReactMethod
118
- public void changeLocale (Locale languageTag ) {
118
+ public void changeLocale (String instabugLocale ) {
119
119
try {
120
- mInstabug .changeLocale (languageTag );
120
+ mInstabug .changeLocale (getLocaleByKey ( instabugLocale ) );
121
121
} catch (Exception e ) {
122
122
e .printStackTrace ();
123
123
}
@@ -395,11 +395,53 @@ public void setDebugEnabled(boolean isDebugEnabled) {
395
395
e .printStackTrace ();
396
396
}
397
397
}
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
+ }
399
439
400
440
@ Override
401
441
public Map <String , Object > getConstants () {
402
442
final Map <String , Object > constants = new HashMap <>();
403
443
return constants ;
404
- }
405
- }
444
+
445
+ }
446
+ }
447
+
0 commit comments