Improve lang code

This commit is contained in:
Victor Shcherb 2015-06-19 10:13:36 +02:00
parent 9d4923cc2e
commit a022c67dc8

View file

@ -624,10 +624,16 @@ public class OsmandApplication extends Application {
} }
public String getLanguage() { public String getLanguage() {
if(preferredLocale != null) { String lang = "";
return preferredLocale.getLanguage(); if (preferredLocale != null) {
lang = preferredLocale.getLanguage();
} else {
lang = Locale.getDefault().getLanguage();
} }
return Locale.getDefault().getLanguage(); if (lang != null && lang.length() > 2) {
lang = lang.substring(0, 2).toLowerCase();
}
return lang;
} }
public RoutingConfiguration.Builder getDefaultRoutingConfig() { public RoutingConfiguration.Builder getDefaultRoutingConfig() {