e335. listing all available locales.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 38 行

TXT
38
字号
Locale[] locales = Locale.getAvailableLocales();
    
    for (int i=0; i<locales.length; i++) {
        // Get the 2-letter language code
        String language = locales[i].getLanguage();
    
        // Get the 2-letter country code; may be equal to ""
        String country = locales[i].getCountry();
    
        // Get localized name suitable for display to the user
        String locName = locales[i].getDisplayName();
    }

Here's a sample of output using a default locale of Locale.ENGLISH: 
    Language Code, Country Code, Localized Name
    ar, , Arabic
    ar, AE, Arabic (United Arab Emirates)
    ar, BH, Arabic (Bahrain)
    ar, DZ, Arabic (Algeria)
    ar, EG, Arabic (Egypt)
    ar, IQ, Arabic (Iraq)
    ar, JO, Arabic (Jordan)
    ar, KW, Arabic (Kuwait)
    ar, LB, Arabic (Lebanon)

Here's a sample of output using a default locale of Locale.FRENCH: 
    Language Code, Country Code, Localized Name
    ar, , arabe
    ar, AE, arabe (Emirats Arabes Unis)
    ar, EG, arabe (Egypte)
    ar, IQ, arabe (Irak)
    ar, JO, arabe (Jordanie)
    ar, KW, arabe (Koweit)
    ar, LB, arabe (Liban)

 Related Examples 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?