15123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka/* 25123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * Copyright (C) 2013 The Android Open Source Project 35123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * 45123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * Licensed under the Apache License, Version 2.0 (the "License"); 55123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * you may not use this file except in compliance with the License. 65123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * You may obtain a copy of the License at 75123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * 85123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * http://www.apache.org/licenses/LICENSE-2.0 95123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * 105123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * Unless required by applicable law or agreed to in writing, software 115123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * distributed under the License is distributed on an "AS IS" BASIS, 125123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * See the License for the specific language governing permissions and 145123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * limitations under the License. 155123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka */ 165123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka 175123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataokapackage com.android.inputmethod.latin.userdictionary; 185123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka 195123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataokaimport com.android.inputmethod.latin.R; 205b91b551e5ffaf2c2e691dfbd434f21c82293986Jean Chalardimport com.android.inputmethod.latin.common.LocaleUtils; 215123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka 225123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataokaimport android.content.Context; 235123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataokaimport android.text.TextUtils; 245123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka 255123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataokaimport java.util.Locale; 265123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka 275123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka/** 285123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * Utilities of the user dictionary settings 295123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka * TODO: We really want to move these utilities to a static library. 305123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka */ 315123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataokapublic class UserDictionarySettingsUtils { 325123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka public static String getLocaleDisplayName(Context context, String localeStr) { 335123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka if (TextUtils.isEmpty(localeStr)) { 345123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka // CAVEAT: localeStr should not be null because a null locale stands for the system 355123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka // locale in UserDictionary.Words.addWord. 365123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka return context.getResources().getString(R.string.user_dict_settings_all_languages); 375123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka } 385123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka final Locale locale = LocaleUtils.constructLocaleFromString(localeStr); 395123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka final Locale systemLocale = context.getResources().getConfiguration().locale; 405123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka return locale.getDisplayName(systemLocale); 415123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka } 425123427532c1f219be0f333cfeb822c95eabc039Satoshi Kataoka} 43