Skip to content

Commit

Permalink
Google MT: Handle special case for Indonesian in WorldServer
Browse files Browse the repository at this point in the history
    Note: this is broken in the WorldServer test interface, you have to
    test it by running a real project. This is due to the fact that
    java.util.Locale#getLanguage returns "in" for Indonesian, but
    everything else (including the WS database) uses the correct "id"
    code.
  • Loading branch information
tingley committed Aug 21, 2017
1 parent cce74f8 commit dd781ae
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public WSLanguagePair[] getSupportedLanguagePairs(WSContext wsContext) {
return composeLanguagePairs(langs.toArray(new WSLanguage[langs.size()]));
}
private WSLanguage findLanguage(WSLanguage[] available, LocaleId locale) {
String lang = locale.getLanguage();
String lang = convertLanguageCode(locale.getLanguage());
String region = locale.getRegion();
for (WSLanguage wslang : available) {
Locale l = wslang.getLocale();
Expand All @@ -111,4 +111,12 @@ private WSLanguage findLanguage(WSLanguage[] available, LocaleId locale) {
logger.debug("Could not find a WorldServer locale to map to Google locale {}", locale);
return null;
}

private String convertLanguageCode(String lang) {
// Handle java.util.Locale#getLanguage special case for Indonesian
if (lang.equals("id")) {
lang = "in";
}
return lang;
}
}

0 comments on commit dd781ae

Please sign in to comment.