Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 abstract class LocaleUtils { | |
| 13 | |
| 14 /** | |
| 15 * @return the default locale, translating Android deprecated | |
| 16 * language codes into the modern ones used by Chromium. | |
| 17 */ | |
| 18 public static String getDefaultLocale() { | |
|
Ted C
2014/09/09 17:51:00
Why did you need to move this from LocalizationUti
vivekg
2014/09/09 18:01:30
The reason I moved this is due to its usage in Res
Ted C
2014/09/09 18:36:19
Ah ha...I missed the ui part of the package. That
vivekg
2014/09/09 18:46:32
Sure, I will put a TODO there and mostly will make
| |
| 19 Locale locale = Locale.getDefault(); | |
| 20 String language = locale.getLanguage(); | |
| 21 String country = locale.getCountry(); | |
| 22 | |
| 23 // Android uses deprecated lanuages codes for Hebrew and Indonesian but Chromium uses the | |
| 24 // updated codes. Also, Android uses "tl" while Chromium uses "fil" for Tagalog/Filipino. | |
| 25 // So apply a mapping. | |
| 26 // See http://developer.android.com/reference/java/util/Locale.html | |
| 27 if ("iw".equals(language)) { | |
| 28 language = "he"; | |
| 29 } else if ("in".equals(language)) { | |
| 30 language = "id"; | |
| 31 } else if ("tl".equals(language)) { | |
| 32 language = "fil"; | |
| 33 } | |
| 34 return country.isEmpty() ? language : language + "-" + country; | |
| 35 } | |
| 36 } | |
| OLD | NEW |