Setting Turkish and English locale: translate Turkish characters to Latin equivalents

前端 未结 5 1106
别跟我提以往
别跟我提以往 2021-02-04 02:29

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 Lo         


        
5条回答
  •  野的像风
    2021-02-04 03:27

    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)
    

    Therefore, your test program creates locales with the language "tr-TR" and "en_US". For your test program, you can use new Locale("tr", "TR") and new Locale("en", "US").

    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.

提交回复
热议问题