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

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

Issue 548023002: Migrate ResourceExtractor.java inside org.chromium.base package. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rolling the AOSP deps Created 6 years, 3 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
new file mode 100644
index 0000000000000000000000000000000000000000..31d4127340c1ac2408e1871160b1ea3239307320
--- /dev/null
+++ b/base/android/java/src/org/chromium/base/LocaleUtils.java
@@ -0,0 +1,41 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.base;
+
+import java.util.Locale;
+
+/**
+ * This class provides the locale related methods.
+ */
+public class LocaleUtils {
+ /**
+ * Guards this class from being instantiated.
+ */
+ private LocaleUtils() {
+ }
+
+ /**
+ * @return the default locale, translating Android deprecated
+ * language codes into the modern ones used by Chromium.
+ */
+ public static String getDefaultLocale() {
+ Locale locale = Locale.getDefault();
+ String language = locale.getLanguage();
+ String country = locale.getCountry();
+
+ // 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.
+ // See http://developer.android.com/reference/java/util/Locale.html
+ if ("iw".equals(language)) {
+ language = "he";
+ } else if ("in".equals(language)) {
+ language = "id";
+ } else if ("tl".equals(language)) {
+ language = "fil";
+ }
+ return country.isEmpty() ? language : language + "-" + country;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698