@@ -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+
0 commit comments