Skip to content

Commit

Permalink
Merge pull request #186 from pilot4u/patch-1
Browse files Browse the repository at this point in the history
fix android generating old language code for ISO 639
  • Loading branch information
zoontek authored Jul 12, 2018
2 parents ba46f47 + 9c4f16d commit dcfd1c2
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ public String getName() {
}

private String toLanguageTag(Locale locale) {
String langTag;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return locale.toLanguageTag();
}
langTag = locale.toLanguageTag();
} else {
StringBuilder builder = new StringBuilder();
builder.append(locale.getLanguage());

StringBuilder builder = new StringBuilder();
builder.append(locale.getLanguage());
if (locale.getCountry() != null) {
builder.append("-");
builder.append(locale.getCountry());
}

if (locale.getCountry() != null) {
builder.append("-");
builder.append(locale.getCountry());
langTag = builder.toString();
}

return builder.toString();
if (langTag.matches("^(iw|in|ji).*")){
return langTag.replace("iw","he").replace("in","id").replace("ji","yi");
}
return langTag;
}

private WritableArray getLocaleList() {
Expand Down

0 comments on commit dcfd1c2

Please sign in to comment.