Without further ado, please see the code:
public static boolean isZh(Context context) { Locale locale = ().getConfiguration().locale; String language = (); if (("zh")) return true; else return false; }
PS: Android determines what language is currently using
Judgment of country:
Chinese:getResources().getConfiguration().().equals("CN")
Traditional Chinese:getResources().getConfiguration().().equals("TW")
English (English):getResources().getConfiguration().().equals("UK")
English (American):getResources().getConfiguration().().equals("US")
If you don't know the abbreviation of the current country, you can directly
(getResources().getConfiguration().());
Just print it out
Here is a way to determine whether it is Chinese or traditional Chinese:
public boolean isLunarSetting() { String language = getLanguageEnv(); if (language != null && (().equals("zh-CN") || ().equals("zh-TW"))) return true; else return false; }
private String getLanguageEnv() { Locale l = (); String language = (); String country = ().toLowerCase(); if ("zh".equals(language)) { if ("cn".equals(country)) { language = "zh-CN"; } else if ("tw".equals(country)) { language = "zh-TW"; } } else if ("pt".equals(language)) { if ("br".equals(country)) { language = "pt-BR"; } else if ("pt".equals(country)) { language = "pt-PT"; } } return language; }
String format = ((), .DATE_FORMAT);
The above is all the content of this article. I hope that the content of this article will help you study or work. I also hope to support me more!