Skip to content

Commit

Permalink
Merge pull request #358 from instructure/MBL-6754
Browse files Browse the repository at this point in the history
Add session locale string for overriding Canvas account language
  • Loading branch information
rolyatwilson authored Oct 17, 2016
2 parents 216bbf7 + 306a0b0 commit a207796
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,29 @@ public void intercept(RequestFacade requestFacade) {
}
}

public static String getLocale() {
// This is kinda gross, but Android is terrible and doesn't use the standard for lang strings...
return Locale.getDefault().toString().replace("_", "-");
}

public static String getAcceptedLanguageString() {
String language = Locale.getDefault().getLanguage();
//This is kinda gross, but Android is terrible and doesn't use the standard for lang strings...
String language3 = Locale.getDefault().toString().replace("_", "-");
return getLocale() + "," + Locale.getDefault().getLanguage();
}

public static String getSessionLocaleString() {
String lang = getLocale();

// Canvas supports Chinese (Traditional) and Chinese (Simplified)
if (lang.equalsIgnoreCase("zh-hk") || lang.equalsIgnoreCase("zh-tw") || lang.equalsIgnoreCase("zh-hant-hk") || lang.equalsIgnoreCase("zh-hant-tw")) {
lang = "zh-Hant";
} else if (lang.equalsIgnoreCase("zh") || lang.equalsIgnoreCase("zh-cn") || lang.equalsIgnoreCase("zh-hans-cn")) {
lang = "zh-Hans";
} else if (!lang.equalsIgnoreCase("pt-BR") && !lang.equalsIgnoreCase("en-AU") && !lang.equalsIgnoreCase("en-GB")) {
// Canvas only supports 3 region tags (not including Chinese), remove any other tags
lang = Locale.getDefault().getLanguage();
}

return language3 + "," + language;
return "?session_locale=" + lang;
}

public static boolean isNetworkAvaliable(Context context) {
Expand Down

0 comments on commit a207796

Please sign in to comment.