设置土耳其语和英语语言环境:翻译土耳其字符拉丁当量 [英] Setting Turkish and English locale: translate Turkish characters to Latin equivalents

查看:842
本文介绍了设置土耳其语和英语语言环境:翻译土耳其字符拉丁当量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于设置土耳其语和英语语言环境:翻译土耳其字符拉丁当量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆