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:net.pms.configuration.PmsConfigurationTest.java
/** * Test Logging Configuration defaults/*from w w w . j av a 2 s. c o m*/ */ @Test public void testLoggingConfigurationDefaults() { // Test defaults and valid values where applicable assertFalse("LogSearchCaseSensitiveDefault", configuration.getGUILogSearchCaseSensitive()); assertFalse("LogSearchMultiLineDefault", configuration.getGUILogSearchMultiLine()); assertFalse("LogSearchRegEx", configuration.getGUILogSearchRegEx()); assertTrue("LogFileNameValid", FileUtil.isValidFileName(configuration.getDefaultLogFileName())); assertEquals("LogFileNameDefault", configuration.getDefaultLogFileName(), "debug.log"); File file = new File(configuration.getDefaultLogFileFolder()); assertTrue("DefaultLogFileFolder", file.isDirectory()); file = new File(configuration.getDefaultLogFilePath()); assertTrue("DefaultLogFilePath", configuration.getDefaultLogFilePath().endsWith("debug.log")); assertFalse("LoggingBufferedDefault", configuration.getLoggingBuffered()); assertEquals("LoggingFilterConsoleDefault", configuration.getLoggingFilterConsole(), Level.INFO); assertEquals("LoggingFilterLogsTabDefault", configuration.getLoggingFilterLogsTab(), Level.INFO); assertEquals("LoggingLogsTabLinebufferDefault", configuration.getLoggingLogsTabLinebuffer(), 1000); assertTrue("LoggingLogsTabLinebufferLegal", configuration.getLoggingLogsTabLinebuffer() >= PmsConfiguration.LOGGING_LOGS_TAB_LINEBUFFER_MIN && configuration .getLoggingLogsTabLinebuffer() <= PmsConfiguration.LOGGING_LOGS_TAB_LINEBUFFER_MAX); assertEquals("LoggingSyslogFacilityDefault", configuration.getLoggingSyslogFacility(), "USER"); assertEquals("LoggingSyslogHostDefault", configuration.getLoggingSyslogHost(), ""); assertEquals("LoggingSyslogPortDefault", configuration.getLoggingSyslogPort(), 514); assertFalse("LoggingUseSyslogDefault", configuration.getLoggingUseSyslog()); assertEquals("getLanguageLocaleDefault", configuration.getLanguageLocale(), Languages.toLocale(Locale.getDefault())); assertEquals("getLanguageTagDefault", configuration.getLanguageTag(), Languages.toLanguageTag(Locale.getDefault())); configuration.getConfiguration().setProperty("language", ""); assertEquals("getLanguageLocaleDefault", configuration.getLanguageLocale(), Languages.toLocale(Locale.getDefault())); assertEquals("getLanguageTagDefault", configuration.getLanguageTag(), Languages.toLanguageTag(Locale.getDefault())); configuration.getConfiguration().setProperty("language", "en-GB"); assertEquals("getLanguageLocaleBritishEnglish", configuration.getLanguageLocale(), Locale.forLanguageTag("en-GB")); assertEquals("getLanguageTagBritishEnglish", configuration.getLanguageTag(), "en-GB"); configuration.getConfiguration().setProperty("language", "en"); assertEquals("getLanguageLocaleEnglish", configuration.getLanguageLocale(), Locale.forLanguageTag("en-US")); assertEquals("getLanguageTagEnglish", configuration.getLanguageTag(), "en-US"); configuration.getConfiguration().setProperty("language", "zh"); assertEquals("getLanguageLocaleChinese", configuration.getLanguageLocale(), Locale.forLanguageTag("zh-Hant")); assertEquals("getLanguageTagChinese", configuration.getLanguageTag(), "zh-Hant"); configuration.setLanguage(Locale.UK); assertEquals("setLanguageUK", configuration.getLanguageLocale(), Locale.forLanguageTag("en-GB")); configuration.setLanguage(Locale.SIMPLIFIED_CHINESE); assertEquals("setLanguageSimplifiedChinese", configuration.getLanguageLocale(), Locale.forLanguageTag("zh-Hans")); configuration.setLanguage(Locale.TRADITIONAL_CHINESE); assertEquals("setLanguageTraditionalChinese", configuration.getLanguageLocale(), Locale.forLanguageTag("zh-Hant")); Locale locale = null; configuration.setLanguage(locale); assertEquals("setLanguageNull", configuration.getLanguageLocale(), Locale.forLanguageTag("zh-Hant")); String code = null; configuration.setLanguage(code); assertEquals("setLanguageNull", configuration.getLanguageLocale(), Locale.forLanguageTag("zh-Hant")); configuration.setLanguage(""); assertEquals("setLanguageEmpty", configuration.getLanguageLocale(), Locale.forLanguageTag("zh-Hant")); configuration.setLanguage("en"); assertEquals("setLanguageEnglish", configuration.getLanguageLocale(), Locale.forLanguageTag("en-US")); }
From source file:com.erudika.scoold.utils.LanguageUtils.java
/** * Returns a non-null locale for a given language code. * @param langCode the 2-letter language code * @return a locale. default is English/* w ww . j av a 2s . co m*/ */ public Locale getProperLocale(String langCode) { if (StringUtils.startsWith(langCode, "zh")) { if ("zh_tw".equalsIgnoreCase(langCode)) { return Locale.TRADITIONAL_CHINESE; } else { return Locale.SIMPLIFIED_CHINESE; } } String lang = StringUtils.substring(langCode, 0, 2); lang = (StringUtils.isBlank(lang) || !ALL_LOCALES.containsKey(lang)) ? "en" : lang.trim().toLowerCase(); return ALL_LOCALES.get(lang); }
From source file:com.example.android.uvdemo.MainActivity.java
private void getAddress(Double lat, Double lng) { Geocoder gc = new Geocoder(MainActivity.this, Locale.TRADITIONAL_CHINESE); List<Address> lstAddress; String countryname = "", adminarea = "", locality = "", postalcode = ""; try {//from ww w . ja v a 2 s. c o m lstAddress = gc.getFromLocation(lat, lng, 1); countryname = lstAddress.get(0).getCountryName(); adminarea = lstAddress.get(0).getAdminArea();// City locality = lstAddress.get(0).getLocality();// District postalcode = lstAddress.get(0).getPostalCode(); Log.v(TAG, "========================================="); Log.v(TAG, "getAddress : " + "\nCountry : " + countryname + "\n City : " + adminarea + "\n District : " + locality + "\n PostalCode : " + postalcode + "\n LatLng : " + lat + " , " + lng); Log.v(TAG, "========================================="); } catch (IOException e) { e.printStackTrace(); } }
From source file:hk.idv.kenson.jrconsole.Console.java
/** * //from ww w .j av a2s. c o m * @param localeString * @return */ private static Locale getLocale(String localeString) { if ("default".equals(localeString)) return Locale.getDefault(); if ("canada".equals(localeString)) return Locale.CANADA; if ("canada_french".equals(localeString)) return Locale.CANADA_FRENCH; if ("china".equals(localeString)) return Locale.CHINA; if ("chinese".equals(localeString)) return Locale.CHINESE; if ("english".equals(localeString)) return Locale.ENGLISH; if ("franch".equals(localeString)) return Locale.FRANCE; if ("german".equals(localeString)) return Locale.GERMAN; if ("germany".equals(localeString)) return Locale.GERMANY; if ("italian".equals(localeString)) return Locale.ITALIAN; if ("italy".equals(localeString)) return Locale.ITALY; if ("japan".equals(localeString)) return Locale.JAPAN; if ("japanese".equals(localeString)) return Locale.JAPANESE; if ("korea".equals(localeString)) return Locale.KOREA; if ("korean".equals(localeString)) return Locale.KOREAN; if ("prc".equals(localeString)) return Locale.PRC; if ("simplified_chinese".equals(localeString)) return Locale.SIMPLIFIED_CHINESE; if ("taiwan".equals(localeString)) return Locale.TAIWAN; if ("traditional_chinese".equals(localeString)) return Locale.TRADITIONAL_CHINESE; if ("uk".equals(localeString)) return Locale.UK; if ("us".equals(localeString)) return Locale.US; String parts[] = localeString.split("_", -1); if (parts.length == 1) return new Locale(parts[0]); else if (parts.length == 2) return new Locale(parts[0], parts[1]); else return new Locale(parts[0], parts[1], parts[2]); }
From source file:com.jackpan.TaiwanpetadoptionApp.HeadpageActivity.java
@Override public void onConnected(Bundle bundle) { if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return;/*w w w . j a v a2 s. c o m*/ } mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if (mLastLocation != null) { Geocoder gc = new Geocoder(HeadpageActivity.this, Locale.TRADITIONAL_CHINESE); List<Address> lstAddress = null; try { lstAddress = gc.getFromLocation(mLastLocation.getLatitude(), mLastLocation.getLongitude(), 1); String returnAddress = lstAddress.get(0).getAddressLine(0); Log.d(TAG, returnAddress); MyGAManager.setGaEvent(HeadpageActivity.this, "Location", "Location_now", returnAddress); } catch (IOException e) { e.printStackTrace(); } } else { Log.d(TAG, "NO Location"); } }
From source file:org.pluroid.pluroium.PlurkHelper.java
public boolean addResponse(String plurkId, String qualifier, String content) { boolean result = false; try {//w ww . jav a 2 s . co m HashMap<String, String> params = new HashMap<String, String>(); params.put("api_key", API_KEY); params.put("plurk_id", plurkId); params.put("qualifier", qualifier); params.put("content", content); Configuration conf = context.getResources().getConfiguration(); String lang = "en"; if (conf.locale == Locale.TRADITIONAL_CHINESE) { lang = "tr_ch"; } params.put("lang", lang); Response resp = performRequest(getApiUri(RESPOND_PLURK_URL), params); if (resp.statusCode == HttpStatus.SC_OK) { result = true; } } catch (Exception e) { Log.e(TAG, "addResponse failed!", e); } finally { connMgr.shutdown(); } return result; }
From source file:com.borax12.materialdaterangepicker.date.MonthView.java
protected void drawMonthDayLabels(Canvas canvas) { int y = getMonthHeaderSize() - (MONTH_DAY_LABEL_TEXT_SIZE / 2); int dayWidthHalf = (mWidth - mEdgePadding * 2) / (mNumDays * 2); for (int i = 0; i < mNumDays; i++) { int x = (2 * i + 1) * dayWidthHalf + mEdgePadding; int calendarDay = (i + mWeekStart) % mNumDays; mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay); Locale locale = Locale.getDefault(); String localWeekDisplayName = mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale);// www .j ava2s.c o m String weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1); if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE) || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) { int len = localWeekDisplayName.length(); weekString = localWeekDisplayName.substring(len - 1, len); } if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) { if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { int len = localWeekDisplayName.length(); weekString = localWeekDisplayName.substring(len - 2, len - 1); } else { // I know this is duplication, but it makes the code easier to grok by // having all hebrew code in the same block weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1); } } canvas.drawText(weekString, x, y, mMonthDayLabelPaint); } }
From source file:com.customdatepicker.date.MonthView.java
/** * Return a 1 or 2 letter String for use as a weekday label * * @param day The day for which to generate a label * @return The weekday label/*from w w w. j a v a2 s . c om*/ */ private String getWeekDayLabel(Calendar day) { Locale locale = Locale.getDefault(); // Localised short version of the string is not available on API < 18 if (Build.VERSION.SDK_INT < 18) { String dayName = new SimpleDateFormat("E", locale).format(day.getTime()); String dayLabel = dayName.toUpperCase(locale).substring(0, 1); // Chinese labels should be fetched right to left if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE) || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) { int len = dayName.length(); dayLabel = dayName.substring(len - 1, len); } // Most hebrew labels should select the second to last character if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) { if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { int len = dayName.length(); dayLabel = dayName.substring(len - 2, len - 1); } else { // I know this is duplication, but it makes the code easier to grok by // having all hebrew code in the same block dayLabel = dayName.toUpperCase(locale).substring(0, 1); } } // Catalan labels should be two digits in lowercase if (locale.getLanguage().equals("ca")) dayLabel = dayName.toLowerCase().substring(0, 2); // Correct single character label in Spanish is X if (locale.getLanguage().equals("es") && day.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) dayLabel = "X"; return dayLabel; } // Getting the short label is a one liner on API >= 18 if (weekDayLabelFormatter == null) { weekDayLabelFormatter = new SimpleDateFormat("EEEEE", locale); } return weekDayLabelFormatter.format(day.getTime()); }
From source file:com.borax12.materialdaterangepicker.single.date.MonthView.java
/** * Return a 1 or 2 letter String for use as a weekday label * @param day The day for which to generate a label * @return The weekday label/* www. j a va2 s . com*/ */ private String getWeekDayLabel(Calendar day) { Locale locale = Locale.getDefault(); // Localised short version of the string is not available on API < 18 if (Build.VERSION.SDK_INT < 18) { String dayName = new SimpleDateFormat("E", locale).format(day.getTime()); String dayLabel = dayName.toUpperCase(locale).substring(0, 1); // Chinese labels should be fetched right to left if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE) || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) { int len = dayName.length(); dayLabel = dayName.substring(len - 1, len); } // Most hebrew labels should select the second to last character if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) { if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { int len = dayName.length(); dayLabel = dayName.substring(len - 2, len - 1); } else { // I know this is duplication, but it makes the code easier to grok by // having all hebrew code in the same block dayLabel = dayName.toUpperCase(locale).substring(0, 1); } } // Catalan labels should be two digits in lowercase if (locale.getLanguage().equals("ca")) dayLabel = dayName.toLowerCase().substring(0, 2); // Correct single character label in Spanish is X if (locale.getLanguage().equals("es") && day.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) dayLabel = "X"; return dayLabel; } // Getting the short label is a one liner on API >= 18 return new SimpleDateFormat("EEEEE", locale).format(day.getTime()); }
From source file:com.jarklee.materialdatetimepicker.date.MonthView.java
/** * Return a 1 or 2 letter String for use as a weekday label * * @param day The day for which to generate a label * @return The weekday label/*from ww w .j a va2 s .com*/ */ private String getWeekDayLabel(Calendar day) { Locale locale = getLocale(); // Localised short version of the string is not available on API < 18 if (Build.VERSION.SDK_INT < 18) { String dayName = new SimpleDateFormat("E", locale).format(day.getTime()); String dayLabel = dayName.toUpperCase(locale).substring(0, 1); // Chinese labels should be fetched right to left if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE) || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) { int len = dayName.length(); dayLabel = dayName.substring(len - 1, len); } // Most hebrew labels should select the second to last character if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) { if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { int len = dayName.length(); dayLabel = dayName.substring(len - 2, len - 1); } else { // I know this is duplication, but it makes the code easier to grok by // having all hebrew code in the same block dayLabel = dayName.toUpperCase(locale).substring(0, 1); } } // Catalan labels should be two digits in lowercase if (locale.getLanguage().equals("ca")) dayLabel = dayName.toLowerCase().substring(0, 2); // Correct single character label in Spanish is X if (locale.getLanguage().equals("es") && day.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) dayLabel = "X"; return dayLabel; } // Getting the short label is a one liner on API >= 18 return new SimpleDateFormat("EEEEE", locale).format(day.getTime()); }