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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.base;
6
7 import java.util.Locale;
8
9 /**
10 * This class provides the locale related methods.
11 */
12 public class LocaleUtils {
13 /**
14 * Guards this class from being instantiated.
15 */
16 private LocaleUtils() {
17 }
18
19 /**
20 * @return the default locale, translating Android deprecated
21 * language codes into the modern ones used by Chromium.
22 */
23 public static String getDefaultLocale() {
24 Locale locale = Locale.getDefault();
25 String language = locale.getLanguage();
26 String country = locale.getCountry();
27
28 // Android uses deprecated lanuages codes for Hebrew and Indonesian but Chromium uses the
29 // updated codes. Also, Android uses "tl" while Chromium uses "fil" for Tagalog/Filipino.
30 // So apply a mapping.
31 // See http://developer.android.com/reference/java/util/Locale.html
32 if ("iw".equals(language)) {
33 language = "he";
34 } else if ("in".equals(language)) {
35 language = "id";
36 } else if ("tl".equals(language)) {
37 language = "fil";
38 }
39 return country.isEmpty() ? language : language + "-" + country;
40 }
41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698