From ed65bc0c62ca99a118057db7ad54c4ccc14d52d0 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Wed, 2 Dec 2015 18:22:41 -0800 Subject: Fix special handling of a fake language code "tl". My previous CL 92280cd309b0f5967dd253280962d8581844db89 [1] had a silly mistake that "tl" is converted to "fil" but "tl_PH" is not. [1] I94f203bddceb9c87710cb187cc3cc0ee6d9092a5 With this CL, the compatibility rewrite-rule from "tl" to "fil" starts working regardless of the existence of countly/variant subtags in locale string. So far the only affected platfrom is API Level 23. Bug: 20696126 Change-Id: Ica9cd2baac002c406f92331aadd7725d7424046a --- .../android/internal/inputmethod/InputMethodUtils.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/java/com/android/internal/inputmethod/InputMethodUtils.java b/core/java/com/android/internal/inputmethod/InputMethodUtils.java index 742173b9b5b3..a5b20f5b367b 100644 --- a/core/java/com/android/internal/inputmethod/InputMethodUtils.java +++ b/core/java/com/android/internal/inputmethod/InputMethodUtils.java @@ -377,17 +377,17 @@ public class InputMethodUtils { } // TODO: Use {@link Locale#toLanguageTag()} and {@link Locale#forLanguageTag(languageTag)}. String[] localeParams = localeStr.split("_", 3); + if (localeParams.length >= 1 && "tl".equals(localeParams[0])) { + // Convert a locale whose language is "tl" to one whose language is "fil". + // For example, "tl_PH" will get converted to "fil_PH". + // Versions of Android earlier than Lollipop did not support three letter language + // codes, and used "tl" (Tagalog) as the language string for "fil" (Filipino). + // On Lollipop and above, the current three letter version must be used. + localeParams[0] = "fil"; + } // The length of localeStr is guaranteed to always return a 1 <= value <= 3 // because localeStr is not empty. if (localeParams.length == 1) { - if (localeParams.length >= 1 && "tl".equals(localeParams[0])) { - // Convert a locale whose language is "tl" to one whose language is "fil". - // For example, "tl_PH" will get converted to "fil_PH". - // Versions of Android earlier than Lollipop did not support three letter language - // codes, and used "tl" (Tagalog) as the language string for "fil" (Filipino). - // On Lollipop and above, the current three letter version must be used. - localeParams[0] = "fil"; - } return new Locale(localeParams[0]); } else if (localeParams.length == 2) { return new Locale(localeParams[0], localeParams[1]); -- cgit v1.2.3-59-g8ed1b