设置土耳其语和英语语言环境:翻译土耳其字符拉丁当量土耳其、当量、英语、字符

由网友(▍窒息旳鬼魅)分享简介:我想翻译我的土耳其串用英语和土耳其语的区域设置为小写。我这样做:I want to translate my Turkish strings to lowercase in both English and Turkish locale. I'm doing this:String myString="YAŞAT...

我想翻译我的土耳其串用英语和土耳其语的区域设置为小写。我这样做:

I want to translate my Turkish strings to lowercase in both English and Turkish locale. I'm doing this:

String myString="YAŞAT BAYRI";
Locale trlocale= new Locale("tr-TR");
Locale enLocale = new Locale("en_US");

Log.v("mainlist", "en source: " +myString.toLowerCase(enLocale));
Log.v("mainlist", "tr source: " +myString.toLowerCase(trlocale));

的输出是:

en source: yaşar bayri

tr source: yaşar bayri

不过,我希望有一个像这样的输出:

But I want to have an output like this:

en source: yasar bayri

tr source: yaşar bayrı

这是可能在Java中?

Is this possible in Java?

推荐答案

如果您使用的是区域设置的构造函数,你可以而且必须设置语言,国家和变体单独的参数:

If you are using the Locale constructor, you can and must set the language, country and variant as separate arguments:

new Locale(language)
new Locale(language, country)
new Locale(language, country, variant)

所以,您的测试程序将创建区域设置的语言TR-TR和EN_US。为了您的测试程序,可以使用新的语言环境(TR,TR)新的区域设置(恩,美国)

如果您使用的是Java 1.7+,那么你也可以使用解析语言标记 Locale.forLanguageTag

If you are using Java 1.7+, then you can also parse a language tag using Locale.forLanguageTag:

String myString="YASAT BAYRI";
Locale trlocale= Locale.forLanguageTag("tr-TR");
Locale enLocale = Locale.forLanguageTag("en_US");

创建一个具有语言相应的小写字符串。

Creates strings that have the appropriate lower case for the language.

阅读全文

相关推荐

最新文章