From fe56004b666b74e4425eb53c6326052a4312e82f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 7 Feb 2020 18:39:33 +0100 Subject: [PATCH] Add locale --- .../src/main/java/net/osmand/map/OsmandRegions.java | 8 ++++++++ OsmAnd/src/net/osmand/plus/AppInitializer.java | 2 +- OsmAnd/src/net/osmand/plus/OsmandApplication.java | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/map/OsmandRegions.java b/OsmAnd-java/src/main/java/net/osmand/map/OsmandRegions.java index 07ed57126c..45300b2ed5 100644 --- a/OsmAnd-java/src/main/java/net/osmand/map/OsmandRegions.java +++ b/OsmAnd-java/src/main/java/net/osmand/map/OsmandRegions.java @@ -374,7 +374,15 @@ public class OsmandRegions { } public void setLocale(String locale) { + setLocale(locale, null); + } + + public void setLocale(String locale, String country) { this.locale = locale; + // Check locale and give 2 locale names +// if("zh".equals(locale) && "rTW".equals(country)) { +// this.locale = "zh-Hant"; +// } } diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index ce7bb80b77..8fcb44f0dc 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -567,7 +567,7 @@ public class AppInitializer implements IProgress { return null; } }); - app.regions.setLocale(app.getLanguage()); + app.regions.setLocale(app.getLanguage(), app.getCountry()); } diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 9fea8ac65a..7f729ca523 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -775,6 +775,16 @@ public class OsmandApplication extends MultiDexApplication { } } } + + public String getCountry() { + String country; + if (preferredLocale != null) { + country = preferredLocale.getCountry(); + } else { + country = Locale.getDefault().getCountry(); + } + return country; + } public String getLanguage() { String lang;