Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1030)

Unified Diff: base/android/java/src/org/chromium/base/LocaleUtils.java

Issue 2371843002: Reland of Move language pak files to assets. (Closed)
Patch Set: Fix ContentShell context setPrivateDataPrefix that was breaking tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/java/src/org/chromium/base/LocaleUtils.java
diff --git a/base/android/java/src/org/chromium/base/LocaleUtils.java b/base/android/java/src/org/chromium/base/LocaleUtils.java
index 5c26e7a50c28618ad009b7499bd1954b44b4541c..35d04a9b73b8e337f8469420e4141343810b2ef3 100644
--- a/base/android/java/src/org/chromium/base/LocaleUtils.java
+++ b/base/android/java/src/org/chromium/base/LocaleUtils.java
@@ -19,14 +19,23 @@ public class LocaleUtils {
}
/**
- * @return the string for the given locale, translating
- * Android deprecated language codes into the modern ones
- * used by Chromium.
+ * @return The string for the given locale, translating Android deprecated language codes
+ * into the modern ones used by Chromium.
*/
public static String getLocale(Locale locale) {
- String language = locale.getLanguage();
+ String language = getLanguage(locale);
String country = locale.getCountry();
+ return country.isEmpty() ? language : language + "-" + country;
+ }
+
+ /**
+ * @return The language for the given locale, translating Android deprecated languages codes
+ * into modern ones used by Chromium.
+ */
+ public static String getLanguage(Locale locale) {
+ String language = locale.getLanguage();
+
// Android uses deprecated lanuages codes for Hebrew and Indonesian but Chromium uses the
// updated codes. Also, Android uses "tl" while Chromium uses "fil" for Tagalog/Filipino.
// So apply a mapping.
@@ -38,12 +47,12 @@ public class LocaleUtils {
} else if ("tl".equals(language)) {
language = "fil";
}
- return country.isEmpty() ? language : language + "-" + country;
+ return language;
}
/**
- * @return the default locale, translating Android deprecated
- * language codes into the modern ones used by Chromium.
+ * @return The default locale, translating Android deprecated language codes into the modern
+ * ones used by Chromium.
*/
@CalledByNative
public static String getDefaultLocale() {
@@ -51,8 +60,7 @@ public class LocaleUtils {
}
/**
- * Get the default country code set during install.
- * @return country code.
+ * @return The default country code set during install.
*/
@CalledByNative
private static String getDefaultCountryCode() {

Powered by Google App Engine
This is Rietveld 408576698