List of usage examples for java.util Locale TRADITIONAL_CHINESE
Locale TRADITIONAL_CHINESE
To view the source code for java.util Locale TRADITIONAL_CHINESE.
Click Source Link
From source file:Main.java
public static void main(String[] args) { Locale locale = Locale.TRADITIONAL_CHINESE; System.out.println("Locale1:" + locale); // print the country of this locale System.out.println("Country:" + locale.getCountry()); }
From source file:Main.java
public static String getDefaultLocale() { switch (Locale.getDefault().getLanguage()) { case "zh": switch (Locale.getDefault().getCountry()) { case "CN": return Locale.SIMPLIFIED_CHINESE.toString(); default:/*from ww w. j av a2 s.c o m*/ return Locale.TRADITIONAL_CHINESE.toString(); } case "ja": return Locale.JAPANESE.toString(); default: return Locale.ENGLISH.toString(); } }
From source file:Main.java
public static void setLocale(String lang, Resources res) { Locale myLocale;//from w w w . j a v a 2 s. com if (lang.equalsIgnoreCase("zh-rTW")) { myLocale = Locale.TRADITIONAL_CHINESE; } else if (lang.equalsIgnoreCase("zh-rCN") || lang.equalsIgnoreCase("zh")) { myLocale = Locale.SIMPLIFIED_CHINESE; } else if (lang.equalsIgnoreCase("pt-rBR") || lang.equalsIgnoreCase("pt")) { myLocale = new Locale("pt", "BR"); } else if (lang.equalsIgnoreCase("pt-rPT")) { myLocale = new Locale("pt", "PT"); } else { myLocale = new Locale(lang); } DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale; res.updateConfiguration(conf, dm); }
From source file:ph.fingra.statisticsweb.controller.CommonController.java
@RequestMapping(method = RequestMethod.POST, value = "/changeLocaleByAjax") public @ResponseBody String changeLocale(@RequestParam("lang") String lang, HttpServletRequest request, HttpServletResponse response) {//w w w . j ava 2 s . com LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request); Locale locale = null; if (lang.equals("ko")) { locale = Locale.KOREA; } else if (lang.equals("cn")) { locale = Locale.CHINA; } else if (lang.equals("hk")) { locale = Locale.TRADITIONAL_CHINESE; } else if (lang.equals("ja")) { locale = Locale.JAPAN; } else { locale = Locale.ENGLISH; } localeResolver.setLocale(request, response, locale); return null; }
From source file:com.alibaba.dubbo.governance.web.common.interceptor.LocaleValve.java
public void invoke(PipelineContext pipelineContext) throws Exception { TurbineRunData rundata = getTurbineRunData(request); if (ignoreTarget(rundata.getTarget())) { pipelineContext.invokeNext();// w w w .j av a 2s. com return; } // String[] temp = rundata.getCookies().getStrings("locale"); String locale = null; if (temp != null) { if (temp.length > 1) { locale = temp[temp.length - 1]; } else if (temp.length == 1) { locale = temp[0]; } } if (locale == null || "".equals(locale)) { locale = "zh"; } Locale newLocale = Locale.SIMPLIFIED_CHINESE; if ("en".equals(locale)) { newLocale = Locale.ENGLISH; } else if ("zh".equals(locale)) { newLocale = Locale.SIMPLIFIED_CHINESE; } else if ("zh_TW".equals(locale)) { newLocale = Locale.TRADITIONAL_CHINESE; } LocaleUtil.setLocale(newLocale); pipelineContext.invokeNext(); }
From source file:org.liberty.android.fantastischmemo.AMActivity.java
private void updateInterfaceLanguage() { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); String localeSetting = settings.getString(AMPrefKeys.INTERFACE_LOCALE_KEY, "AUTO"); Locale locale;/*ww w. j a va 2 s. c o m*/ /* Force to use the a language */ if (localeSetting.equals("EN")) { locale = Locale.US; } else if (localeSetting.equals("SC")) { locale = Locale.SIMPLIFIED_CHINESE; } else if (localeSetting.equals("TC")) { locale = Locale.TRADITIONAL_CHINESE; } else if (localeSetting.equals("CS")) { locale = new Locale("CS"); } else if (localeSetting.equals("PL")) { locale = new Locale("PL"); } else if (localeSetting.equals("RU")) { locale = new Locale("RU"); } else if (localeSetting.equals("DE")) { locale = new Locale("DE"); } else if (localeSetting.equals("KO")) { locale = new Locale("KO"); } else if (localeSetting.equals("FR")) { locale = new Locale("FR"); } else if (localeSetting.equals("PT")) { locale = new Locale("PT"); } else if (localeSetting.equals("JA")) { locale = new Locale("JA"); } else if (localeSetting.equals("ES")) { locale = new Locale("ES"); } else if (localeSetting.equals("IT")) { locale = Locale.ITALIAN; } else { locale = Locale.getDefault(); } Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); }
From source file:io.github.mkjung.ivi.VLCApplication.java
@Override public void onCreate() { super.onCreate(); // Are we using advanced debugging - locale? mSettings = PreferenceManager.getDefaultSharedPreferences(this); String p = mSettings.getString("set_locale", ""); if (!p.equals("")) { Locale locale;/*from w w w .j av a2s . c o m*/ // workaround due to region code if (p.equals("zh-TW")) { locale = Locale.TRADITIONAL_CHINESE; } else if (p.startsWith("zh")) { locale = Locale.CHINA; } else if (p.equals("pt-BR")) { locale = new Locale("pt", "BR"); } else if (p.equals("bn-IN") || p.startsWith("bn")) { locale = new Locale("bn", "IN"); } else { /** * Avoid a crash of * java.lang.AssertionError: couldn't initialize LocaleData for locale * if the user enters nonsensical region codes. */ if (p.contains("-")) p = p.substring(0, p.indexOf('-')); locale = new Locale(p); } Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getResources().updateConfiguration(config, getResources().getDisplayMetrics()); } instance = this; // Initialize the database soon enough to avoid any race condition and crash MediaDatabase.getInstance(); // Prepare cache folder constants AudioUtil.prepareCacheFolder(this); sTV = AndroidDevices.isAndroidTv() || !AndroidDevices.hasTsp(); Dialog.setCallbacks(VLCInstance.get(), mDialogCallbacks); // Disable remote control receiver on Fire TV. // if (!AndroidDevices.hasTsp()) // AndroidDevices.setRemoteControlReceiverEnabled(false); }
From source file:org.videolan.vlc.VLCApp.java
public void onCreate() { // Are we using advanced debugging - locale? mSettings = PreferenceManager.getDefaultSharedPreferences(context); String p = mSettings.getString("set_locale", ""); if (!p.equals("")) { Locale locale;// w ww. ja v a 2 s .c o m // workaround due to region code if (p.equals("zh-TW")) { locale = Locale.TRADITIONAL_CHINESE; } else if (p.startsWith("zh")) { locale = Locale.CHINA; } else if (p.equals("pt-BR")) { locale = new Locale("pt", "BR"); } else if (p.equals("bn-IN") || p.startsWith("bn")) { locale = new Locale("bn", "IN"); } else { /** * Avoid a crash of * java.lang.AssertionError: couldn't initialize LocaleData for locale * if the user enters nonsensical region codes. */ if (p.contains("-")) p = p.substring(0, p.indexOf('-')); locale = new Locale(p); } Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); } // Initialize the database soon enough to avoid any race condition and crash // MediaDatabase.getInstance(); // Prepare cache folder constants AudioUtil.prepareCacheFolder(context); sTV = AndroidDevices.isAndroidTv() || !AndroidDevices.hasTsp(); Dialog.setCallbacks(VLCInstance.get(), mDialogCallbacks); // Disable remote control receiver on Fire TV. if (!AndroidDevices.hasTsp()) AndroidDevices.setRemoteControlReceiverEnabled(false); }
From source file:org.videolan.vlc.VLCApplication.java
@Override public void onCreate() { super.onCreate(); // Are we using advanced debugging - locale? mSettings = PreferenceManager.getDefaultSharedPreferences(this); String p = mSettings.getString("set_locale", ""); if (!p.equals("")) { Locale locale;// ww w .ja v a2 s .c o m // workaround due to region code if (p.equals("zh-TW")) { locale = Locale.TRADITIONAL_CHINESE; } else if (p.startsWith("zh")) { locale = Locale.CHINA; } else if (p.equals("pt-BR")) { locale = new Locale("pt", "BR"); } else if (p.equals("bn-IN") || p.startsWith("bn")) { locale = new Locale("bn", "IN"); } else { /** * Avoid a crash of * java.lang.AssertionError: couldn't initialize LocaleData for locale * if the user enters nonsensical region codes. */ if (p.contains("-")) p = p.substring(0, p.indexOf('-')); locale = new Locale(p); } Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getResources().updateConfiguration(config, getResources().getDisplayMetrics()); } instance = this; // Initialize the database soon enough to avoid any race condition and crash MediaDatabase.getInstance(); // Prepare cache folder constants AudioUtil.prepareCacheFolder(this); sTV = AndroidDevices.isAndroidTv() || !AndroidDevices.hasTsp(); if (!VLCInstance.testCompatibleCPU(this)) return; Dialog.setCallbacks(VLCInstance.get(), mDialogCallbacks); // Disable remote control receiver on Fire TV. if (!AndroidDevices.hasTsp()) AndroidDevices.setRemoteControlReceiverEnabled(false); if (Permissions.canReadStorage()) discoverStorages(getMLInstance()); }
From source file:com.example.android.animationsdemo.RecentQueryActivity.java
public void getAddressByLocation(Location location) { String result = "No Result"; try {/* ww w.j av a2 s .com*/ if (location != null) { Double longitude = location.getLongitude(); //? Double latitude = location.getLatitude(); //? //Geocoder: Android 8 ? Geocoder gc = new Geocoder(this, Locale.TRADITIONAL_CHINESE); //?:?? //?? List<Address> lstAddress = gc.getFromLocation(latitude, longitude, 5); if (lstAddress.size() > 0) { result = ""; for (int i = 0; i < lstAddress.size(); i++) { result = result + i + " : " + "\n"; result = result + "Address: " + lstAddress.get(0).getAddressLine(0) + "\n"; result = result + "Locality: " + lstAddress.get(0).getLocality() + "\n"; result = result + "AdminArea: " + lstAddress.get(0).getAdminArea() + "\n"; result = result + "Country: " + lstAddress.get(0).getCountryName() + "\n"; result = result + "PostalCode: " + lstAddress.get(0).getPostalCode() + "\n"; result = result + "Feature: " + lstAddress.get(0).getFeatureName() + "\n\n"; //result = result + lstAddress.get(i).getAddressLine(0) + "\n"; //result = result + lstAddress.get(i).getPostalCode() + "\n"; } } resultTextView.setText(result); } } catch (Exception e) { DKLog.e(TAG, Trace.getCurrentMethod() + e.toString()); } }