2011-01-14 07:12:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.inputmethod.latin;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.res.Resources;
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
public class SubtypeLocale {
|
|
|
|
private static String[] sExceptionKeys;
|
|
|
|
private static String[] sExceptionValues;
|
|
|
|
|
|
|
|
private SubtypeLocale() {
|
|
|
|
// Intentional empty constructor for utility class.
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void init(Context context) {
|
|
|
|
final Resources res = context.getResources();
|
|
|
|
sExceptionKeys = res.getStringArray(R.array.subtype_locale_exception_keys);
|
|
|
|
sExceptionValues = res.getStringArray(R.array.subtype_locale_exception_values);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getFullDisplayName(Locale locale) {
|
2012-03-29 12:01:19 +00:00
|
|
|
final String localeCode = locale.toString();
|
2011-01-14 07:12:36 +00:00
|
|
|
for (int index = 0; index < sExceptionKeys.length; index++) {
|
2012-03-29 12:01:19 +00:00
|
|
|
if (sExceptionKeys[index].equals(localeCode)) {
|
|
|
|
final String value = sExceptionValues[index];
|
|
|
|
if (value.indexOf("%s") >= 0) {
|
|
|
|
final String languageName = locale.getDisplayLanguage(locale);
|
|
|
|
return String.format(value, languageName);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
2011-01-14 07:12:36 +00:00
|
|
|
}
|
|
|
|
return locale.getDisplayName(locale);
|
|
|
|
}
|
|
|
|
}
|