gpt4 book ai didi

android - 如何在 Locale.class 中添加语言

转载 作者:搜寻专家 更新时间:2023-11-01 07:44:03 25 4
gpt4 key购买 nike

我在 Locale.class 中找不到印度尼西亚语,如何添加该语言?所以我的代码下面显示红色文本,因为找不到该语言。

public static Locale getUserLocale() {
int currentLanguage = SpUtil.getInstance().getInt("currentLanguage", 0);

Locale myLocale = Locale.INDONESIA;// error
switch (currentLanguage) {
case 0:
myLocale = Locale.INDONESIA; // error
break;
case 1:
myLocale = Locale.ENGLISH;
break;

}
return myLocale;
}

这里是 Locale.class 的摘录:

public final class Locale implements Cloneable, Serializable {
public static final Locale CANADA = null;
public static final Locale CANADA_FRENCH = null;
public static final Locale CHINA = null;
public static final Locale CHINESE = null;
public static final Locale ENGLISH = null;
public static final Locale FRANCE = null;
public static final Locale FRENCH = null;
public static final Locale GERMAN = null;
public static final Locale GERMANY = null;
public static final Locale ITALIAN = null;
public static final Locale ITALY = null;
public static final Locale JAPAN = null;
public static final Locale JAPANESE = null;
public static final Locale KOREA = null;
public static final Locale KOREAN = null;
public static final Locale PRC = null;
public static final char PRIVATE_USE_EXTENSION = 'x';
public static final Locale ROOT = null;
public static final Locale SIMPLIFIED_CHINESE = null;
public static final Locale TAIWAN = null;
public static final Locale TRADITIONAL_CHINESE = null;
public static final Locale UK = null;
public static final char UNICODE_LOCALE_EXTENSION = 'u';
public static final Locale US = null;

public Locale(String language, String country, String variant) {
throw new RuntimeException("Stub!");
}

最佳答案

您可以使用印度尼西亚语,印度尼西亚 (in_ID) 来自

https://web.archive.org/web/20120814113314/http://colincooper.net/blog/2011/02/17/android-supported-language-and-locales/

类似

Locale INDONESIA = new Locale("in", "ID");

然后分配使用

myLocale = INDONESIA;

关于android - 如何在 Locale.class 中添加语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48493725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com