public void set(SearchBookContentsResult result) { pageNumberView.setText(result.getPageNumber()); String snippet = result.getSnippet(); if (snippet.length() > 0) { if (result.getValidSnippet()) { String lowerQuery = SearchBookContentsResult.getQuery().toLowerCase(Locale.getDefault()); String lowerSnippet = snippet.toLowerCase(Locale.getDefault()); Spannable styledSnippet = new SpannableString(snippet); StyleSpan boldSpan = new StyleSpan(Typeface.BOLD); int queryLength = lowerQuery.length(); int offset = 0; while (true) { int pos = lowerSnippet.indexOf(lowerQuery, offset); if (pos < 0) { break; } styledSnippet.setSpan(boldSpan, pos, pos + queryLength, 0); offset = pos + queryLength; } snippetView.setText(styledSnippet); } else { // This may be an error message, so don't try to bold the query terms within it snippetView.setText(snippet); } } else { snippetView.setText(""); } }
@SuppressWarnings("deprecation") // InputMethodSubtype.getLocale() deprecated in API 24 private void recordKeyboardLocaleUma() { InputMethodManager imm = (InputMethodManager) mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE); List<InputMethodInfo> ims = imm.getEnabledInputMethodList(); ArrayList<String> uniqueLanguages = new ArrayList<>(); for (InputMethodInfo method : ims) { List<InputMethodSubtype> submethods = imm.getEnabledInputMethodSubtypeList(method, true); for (InputMethodSubtype submethod : submethods) { if (submethod.getMode().equals("keyboard")) { String language = submethod.getLocale().split("_")[0]; if (!uniqueLanguages.contains(language)) { uniqueLanguages.add(language); } } } } RecordHistogram.recordCountHistogram("InputMethod.ActiveCount", uniqueLanguages.size()); InputMethodSubtype currentSubtype = imm.getCurrentInputMethodSubtype(); Locale systemLocale = Locale.getDefault(); if (currentSubtype != null && currentSubtype.getLocale() != null && systemLocale != null) { String keyboardLanguage = currentSubtype.getLocale().split("_")[0]; boolean match = systemLocale.getLanguage().equalsIgnoreCase(keyboardLanguage); RecordHistogram.recordBooleanHistogram("InputMethod.MatchesSystemLanguage", match); } }
/** * Finds a suitable analyser class for file name. * * @param file The file name to get the analyzer for * @return the analyzer factory to use */ public static FileAnalyzerFactory find(String file) { String path = file; int i; // Get basename of the file first. if (((i = path.lastIndexOf(File.separatorChar)) > 0) && (i + 1 < path.length())) { path = path.substring(i + 1); } int dotpos = path.lastIndexOf('.'); if (dotpos >= 0) { FileAnalyzerFactory factory; // Try matching the prefix. if (dotpos > 0) { factory = pre.get(path.substring(0, dotpos).toUpperCase(Locale.getDefault())); if (factory != null) { return factory; } } // Now try matching the suffix. We kind of consider this order (first // prefix then suffix) to be workable although for sure there can be // cases when this does not work. factory = ext.get(path.substring(dotpos + 1).toUpperCase(Locale.getDefault())); if (factory != null) { return factory; } } // file doesn't have any of the prefix or extensions we know, try full match return FILE_NAMES.get(path.toUpperCase(Locale.getDefault())); }
/** This method must be called in a context synchronized on {@link #translationsStatistics}. */ private static LanguageEntry getSortedLanguageByLocale(Locale locale) { for (LanguageEntry entry : sortedLanguages) { if (entry.locale.equals(locale)) { return entry; } } // No exact match found, try to match only by language and country for (LanguageEntry entry : sortedLanguages) { if (entry.locale.getCountry().equals(locale.getCountry()) && entry.locale.getLanguage().equals(locale.getLanguage())) { return entry; } } // No match found on language and country, try to match only by language for (LanguageEntry entry : sortedLanguages) { if (entry.locale.getLanguage().equals(locale.getLanguage())) { return entry; } } // No match found on language, try a last desperate match only by country if (!locale.getCountry().isEmpty()) { for (LanguageEntry entry : sortedLanguages) { if (entry.locale.getCountry().equals(locale.getCountry())) { return entry; } } } // No match found, return null return null; }
/** @tests java.lang.String#compareToIgnoreCase(java.lang.String) */ public void test_compareToIgnoreCaseLjava_lang_String() { // Test for method int // java.lang.String.compareToIgnoreCase(java.lang.String) assertTrue( "Returned incorrect value for first < second", "aaaaab".compareToIgnoreCase("aaaaac") < 0); assertEquals( "Returned incorrect value for first = second", 0, "aaaaac".compareToIgnoreCase("aaaaac")); assertTrue( "Returned incorrect value for first > second", "aaaaac".compareToIgnoreCase("aaaaab") > 0); assertEquals("Considered case to not be of importance", 0, "A".compareToIgnoreCase("a")); assertTrue("0xbf should not compare = to 'ss'", "\u00df".compareToIgnoreCase("ss") != 0); assertEquals("0x130 should compare = to 'i'", 0, "\u0130".compareToIgnoreCase("i")); assertEquals("0x131 should compare = to 'i'", 0, "\u0131".compareToIgnoreCase("i")); Locale defLocale = Locale.getDefault(); try { Locale.setDefault(new Locale("tr", "")); assertEquals( "Locale tr: 0x130 should compare = to 'i'", 0, "\u0130".compareToIgnoreCase("i")); assertEquals( "Locale tr: 0x131 should compare = to 'i'", 0, "\u0131".compareToIgnoreCase("i")); } finally { Locale.setDefault(defLocale); } try { "fixture".compareToIgnoreCase(null); fail("No NPE"); } catch (NullPointerException e) { } }
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { if (name == null) { throw new NullPointerException( JAXPValidationMessageFormatter.formatMessage( Locale.getDefault(), "FeatureNameNull", null)); } if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { fSecurityManager = value ? new SecurityManager() : null; fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); return; } try { fXMLSchemaLoader.setFeature(name, value); } catch (XMLConfigurationException e) { String identifier = e.getIdentifier(); if (e.getType() == XMLConfigurationException.NOT_RECOGNIZED) { throw new SAXNotRecognizedException( SAXMessageFormatter.formatMessage( Locale.getDefault(), "feature-not-recognized", new Object[] {identifier})); } else { throw new SAXNotSupportedException( SAXMessageFormatter.formatMessage( Locale.getDefault(), "feature-not-supported", new Object[] {identifier})); } } }
@Test public void testParseLocaleStringSunnyDay() throws Exception { Locale expectedLocale = Locale.UK; Locale locale = StringUtils.parseLocaleString(expectedLocale.toString()); assertNotNull("When given a bona-fide Locale string, must not return null.", locale); assertEquals(expectedLocale, locale); }
@Override public String getString(String key, Locale locale) { ResourceBundle bundle = resourceBundles.get(locale.getISO3Language()); if (bundle == null) { try { bundle = ResourceBundle.getBundle(languageBundleName, locale); resourceBundles.put(locale.getISO3Language(), bundle); } catch (MissingResourceException e) { bundle = resourceBundles.get(FALLBACK_LANGUAGE_ISO); } } try { String value = bundle.getString(key); if (LOG.isDebugEnabled()) { LOG.debug( "Key '" + key + "' with ISO " + locale.getISO3Language() + " resulted in value: " + value); } return value; } catch (MissingResourceException e) { return "Missing text for key " + key; } }
/** {@inheritDoc} */ public synchronized void removeColumn(TalendColumn column) { ResourceBundle rb = ResourceBundle.getBundle("TalendBridge", Locale.getDefault()); int index = columnsList.indexOf(column); if (index == -1) { return; } if (columnImpls.get(column).isKey() && (!rowList.isEmpty() || !rowdraft.isEmpty())) { throw new IllegalStateException( String.format( Locale.getDefault(), rb.getString("exception.cannotRemoveKey"), column.getName(), name)); } TalendColumnImpl c; for (index = index + 1; index < columnsList.size(); index++) { c = columnsList.get(index); c.index--; } for (TalendRowImpl row : rowList) { row.setValue(column, null, true); } columnsList.remove((TalendColumnImpl) column); columns.remove(column.getName()); columnImpls.remove(column); }
/** @return 01092010 */ public static String getDateNumeric() { String year = getYear(); String month = getMonth(); String day = getDayOfMonth(); String dn = year + month + day; if (mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("item.date.locale") == null) mpv5.db.objects.User.getCurrentUser() .getProperties() .changeProperty("item.date.locale", Locale.getDefault().toString()); try { Locale l = TypeConversion.stringToLocale( mpv5.db.objects.User.getCurrentUser() .getProperties() .getProperty("item.date.locale")); if (l.equals(Locale.GERMAN) || l.equals(Locale.GERMANY)) { dn = day + month + year; } } catch (Exception e) { Log.Debug(e); } finally { return dn; } }
protected PlayDfeApiContext( Context context, AndroidAuthenticator authenticator, Cache cache, String appPackageName, String appVersionString, int apiVersion, Locale locale, String mccmnc, String clientId, String loggingId) { this.mHeaders = new HashMap(); this.mContext = context; this.mAuthenticator = authenticator; this.mCache = cache; this.mHeaders.put( "X-DFE-Device-Id", Long.toHexString(((Long) PlayG.androidId.get()).longValue())); this.mHeaders.put("Accept-Language", locale.getLanguage() + "-" + locale.getCountry()); if (!TextUtils.isEmpty(mccmnc)) { this.mHeaders.put("X-DFE-MCCMNC", mccmnc); } if (!TextUtils.isEmpty(clientId)) { this.mHeaders.put("X-DFE-Client-Id", clientId); } if (!TextUtils.isEmpty(clientId)) { this.mHeaders.put("X-DFE-Logging-Id", loggingId); } this.mHeaders.put( "User-Agent", makeUserAgentString(appPackageName, appVersionString, apiVersion)); checkUrlRules(); }
private static String initGeckoEnvironment() { final Context context = GeckoAppShell.getApplicationContext(); GeckoLoader.loadMozGlue(context); setState(State.MOZGLUE_READY); final Locale locale = Locale.getDefault(); final Resources res = context.getResources(); if (locale.toString().equalsIgnoreCase("zh_hk")) { final Locale mappedLocale = Locale.TRADITIONAL_CHINESE; Locale.setDefault(mappedLocale); Configuration config = res.getConfiguration(); config.locale = mappedLocale; res.updateConfiguration(config, null); } String[] pluginDirs = null; try { pluginDirs = GeckoAppShell.getPluginDirectories(); } catch (Exception e) { Log.w(LOGTAG, "Caught exception getting plugin dirs.", e); } final String resourcePath = context.getPackageResourcePath(); GeckoLoader.setupGeckoEnvironment(context, pluginDirs, context.getFilesDir().getPath()); GeckoLoader.loadSQLiteLibs(context, resourcePath); GeckoLoader.loadNSSLibs(context, resourcePath); GeckoLoader.loadGeckoLibs(context, resourcePath); setState(State.LIBS_READY); return resourcePath; }
public static void main(String[] args) { Locale[] locales = Locale.getAvailableLocales(); int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; Map map = new HashMap(locales.length); int conflicts = 0; for (int i = 0; i < locales.length; i++) { Locale loc = locales[i]; int hc = loc.hashCode(); min = Math.min(hc, min); max = Math.max(hc, max); Integer key = new Integer(hc); if (map.containsKey(key)) { conflicts++; System.out.println("conflict: " + (Locale) map.get(key) + ", " + loc); } else { map.put(key, loc); } } System.out.println( locales.length + " locales: conflicts=" + conflicts + ", min=" + min + ", max=" + max + ", diff=" + (max - min)); if (conflicts >= (locales.length / 10)) { throw new RuntimeException( "too many conflicts: " + conflicts + " per " + locales.length + " locales"); } }
@Test public void testLocale() throws Exception { Locale locale = getLocale(); String filename = "org/jboss/resteasy/plugins/providers/multipart/i18n/Messages.i18n_" + locale.toString() + ".properties"; if (!before(locale, filename)) { System.out.println(getClass() + ": " + filename + " not found."); return; } Assert.assertEquals( getExpected(BASE + "00", "couldFindNoContentDispositionHeader"), Messages.MESSAGES.couldFindNoContentDispositionHeader()); Assert.assertEquals( getExpected(BASE + "05", "couldNotParseContentDisposition", field), Messages.MESSAGES.couldNotParseContentDisposition(field)); Assert.assertEquals( getExpected(BASE + "20", "hadToWriteMultipartOutput", multipartOutput, writer, getClass()), Messages.MESSAGES.hadToWriteMultipartOutput(multipartOutput, writer, getClass())); Assert.assertEquals( getExpected( BASE + "35", "receivedGenericType", reader, getClass().getGenericSuperclass(), getClass()), Messages.MESSAGES.receivedGenericType( reader, getClass().getGenericSuperclass(), getClass())); Assert.assertEquals( getExpected(BASE + "60", "urlEncoderDoesNotSupportUtf8"), Messages.MESSAGES.urlEncoderDoesNotSupportUtf8()); }
@Override public String getDescription(Locale locale) { if (locale != null && locale.equals(Locale.KOREAN)) return "다른 로거로부터 패턴 매칭되는 특정 로그들만 수집합니다."; if (locale != null && locale.equals(Locale.JAPANESE)) return "他のロガーからパターンマッチングされる特定ログだけ収集します。"; if (locale != null && locale.equals(Locale.CHINESE)) return "从其他数据采集器提取符合指定特征的数据。"; return "Select logs from logger using text matching"; }
/** {@inheritDoc} */ public void commit() { ResourceBundle rb = ResourceBundle.getBundle("TalendBridge", Locale.getDefault()); if (waitToTruncate == true) { rowList.clear(); return; } for (TalendRowImpl row : rowdraft) { if ((index.size() - 1) > 0 && index.contains(row.getKeySet())) { throw new IllegalStateException( String.format(Locale.getDefault(), rb.getString("exception.duplicateKey"), name)); } } rowList.addAll(rowdraft); for (TalendRowImpl row : rowdraft) { if (row.presentInTable == false) { // index.put(row.getKeySet(), 1); index.add(row.getKeySet()); } row.presentInTable = true; row.save(); } rowdraft.clear(); }
/** * Creates and returns a FacesMessage for the specified Locale. * * @param context - the <code>FacesContext</code> for the current request * @param messageId - the key of the message in the resource bundle * @param params - substittion parameters * @return a localized <code>FacesMessage</code> with the severity of FacesMessage.SEVERITY_ERROR */ protected static FacesMessage getMessage( FacesContext context, String messageId, Object... params) { if (context == null || messageId == null) { throw new NullPointerException(" context " + context + " messageId " + messageId); } Locale locale; // viewRoot may not have been initialized at this point. if (context.getViewRoot() != null) { locale = context.getViewRoot().getLocale(); } else { locale = Locale.getDefault(); } if (null == locale) { throw new NullPointerException(" locale is null "); } FacesMessage message = getMessage(locale, messageId, params); if (message != null) { return message; } locale = Locale.getDefault(); return (getMessage(locale, messageId, params)); }
/** * Sets -javaagent and JRE arguments as SUN environment variable. * * @param parameters The parameters for starting the AUT * @return the _JAVA_OPTIONS environment variable including -javaagent and jre arguments */ protected String setJavaOptions(Map parameters) { StringBuffer sb = new StringBuffer(); if (isRunningFromExecutable(parameters)) { Locale locale = (Locale) parameters.get(IStartAut.LOCALE); // set agent and locals sb.append(JAVA_OPTIONS_INTRO); if (org.eclipse.jubula.tools.utils.MonitoringUtil.shouldAndCanRunWithMonitoring(parameters)) { String monAgent = getMonitoringAgent(parameters); if (monAgent != null) { sb.append(monAgent).append(StringConstants.SPACE); } } sb.append(StringConstants.QUOTE) .append("-javaagent:") // $NON-NLS-1$ .append(getAbsoluteAgentJarPath()) .append(StringConstants.QUOTE); if (locale != null) { sb.append(StringConstants.SPACE).append(JAVA_COUNTRY_PROPERTY).append(locale.getCountry()); sb.append(StringConstants.SPACE) .append(JAVA_LANGUAGE_PROPERTY) .append(locale.getLanguage()); } } else { if (org.eclipse.jubula.tools.utils.MonitoringUtil.shouldAndCanRunWithMonitoring(parameters)) { String monAgent = getMonitoringAgent(parameters); if (monAgent != null) { sb.append(JAVA_OPTIONS_INTRO).append(monAgent); } } } return sb.toString(); }
public void setProperty(String name, Object object) throws SAXNotRecognizedException, SAXNotSupportedException { if (name == null) { throw new NullPointerException( JAXPValidationMessageFormatter.formatMessage( Locale.getDefault(), "ProperyNameNull", null)); } if (name.equals(SECURITY_MANAGER)) { fSecurityManager = (SecurityManager) object; fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); return; } else if (name.equals(XMLGRAMMAR_POOL)) { throw new SAXNotSupportedException( SAXMessageFormatter.formatMessage( Locale.getDefault(), "property-not-supported", new Object[] {name})); } try { fXMLSchemaLoader.setProperty(name, object); } catch (XMLConfigurationException e) { String identifier = e.getIdentifier(); if (e.getType() == XMLConfigurationException.NOT_RECOGNIZED) { throw new SAXNotRecognizedException( SAXMessageFormatter.formatMessage( Locale.getDefault(), "property-not-recognized", new Object[] {identifier})); } else { throw new SAXNotSupportedException( SAXMessageFormatter.formatMessage( Locale.getDefault(), "property-not-supported", new Object[] {identifier})); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate Started"); setContentView(R.layout.alarm_controller); prefs = PreferenceManager.getDefaultSharedPreferences(this); tpAlarm = (TimePicker) findViewById(R.id.tpAlarm); chkSnooze = (CheckBox) findViewById(R.id.chkSnooze); etxtSnoozeMin = (EditText) findViewById(R.id.etxtSnoozeMin); Button button = (Button) findViewById(R.id.btnSetAlarm); button.setOnClickListener(setAlarmListener); btnSetTone = (Button) findViewById(R.id.btnSetTone); btnSetTone.setOnClickListener(setTone); tpAlarm.setCurrentHour(prefs.getInt(M_HOUR, 0)); tpAlarm.setCurrentMinute(prefs.getInt(M_MINT, 0)); chkSnooze.setChecked(prefs.getBoolean(M_SNOOZE, false)); etxtSnoozeMin.setText(prefs.getString(SNOOZE_T, "0")); Locale loc = new Locale("en"); Log.i(TAG, Arrays.toString(loc.getAvailableLocales())); }
/** * Creates an NL fragment project along with the locale specific properties files. * * @throws CoreException * @throws IOException * @throws InvocationTargetException * @throws InterruptedException */ private void internationalizePlugins(List plugins, List locales, Map overwrites) throws CoreException, IOException, InvocationTargetException, InterruptedException { Set created = new HashSet(); for (Iterator it = plugins.iterator(); it.hasNext(); ) { IPluginModelBase plugin = (IPluginModelBase) it.next(); for (Iterator iter = locales.iterator(); iter.hasNext(); ) { Locale locale = (Locale) iter.next(); IProject project = getNLProject(plugin, locale); if (created.contains(project) || overwriteWithoutAsking || !project.exists() || OVERWRITE == overwrites.get(project.getName())) { if (!created.contains(project) && project.exists()) { project.delete(true, getProgressMonitor()); } if (!created.contains(project)) { createNLFragment(plugin, project, locale); created.add(project); project.getFolder(RESOURCE_FOLDER_PARENT).create(false, true, getProgressMonitor()); } project .getFolder(RESOURCE_FOLDER_PARENT) .getFolder(locale.toString()) .create(true, true, getProgressMonitor()); createLocaleSpecificPropertiesFile(project, plugin, locale); } } } }
/** * Gets the display name for the specified Timezone ID. If the ID matches the list of IDs that * need to be have their default display names overriden, use the pre-set display name from * R.arrays. * * @param id The timezone ID. * @param daylightTime True for daylight time, false for standard time * @return The display name of the timezone. This will just use the default display name, except * that certain timezones have poor defaults, and should use the pre-set override labels from * R.arrays. */ private String getDisplayName(TimeZone tz, boolean daylightTime) { if (mOverrideIds == null || mOverrideLabels == null) { // Just in case they somehow didn't get loaded correctly. return tz.getDisplayName(daylightTime, TimeZone.LONG, Locale.getDefault()); } for (int i = 0; i < mOverrideIds.length; i++) { if (tz.getID().equals(mOverrideIds[i])) { if (mOverrideLabels.length > i) { return mOverrideLabels[i]; } Log.e( TAG, "timezone_rename_ids len=" + mOverrideIds.length + " timezone_rename_labels len=" + mOverrideLabels.length); break; } } // If the ID doesn't need to have the display name overridden, or if the labels were // malformed, just use the default. return tz.getDisplayName(daylightTime, TimeZone.LONG, Locale.getDefault()); }
/** * Determine the text being shown for given panel. * * @param panel * @return The text shown, i18n. */ public Map getHtmlCode(Panel panel) { PanelSession pSession = SessionManager.getPanelSession(panel); Map m = (Map) pSession.getAttribute(ATTR_TEXT); if (m != null) return m; HTMLText text = load(panel.getInstance()); if (text != null) return text.getText(); try { HTMLText textToCreate = new HTMLText(); textToCreate.setPanelInstance(panel.getInstance()); Locale[] locales = LocaleManager.lookup().getPlatformAvailableLocales(); for (int i = 0; i < locales.length; i++) { Locale locale = locales[i]; ResourceBundle i18n = localeManager.getBundle("org.jboss.dashboard.ui.panel.advancedHTML.messages", locale); textToCreate.setText(locale.getLanguage(), i18n.getString("defaultContent")); } textToCreate.save(); } catch (Exception e) { log.error("Error creating empty text for panel: ", e); } text = load(panel.getInstance()); if (text != null) return text.getText(); log.error("Current HTML code is null for panel " + panel); return null; }
private void initializeLanguageDialog() { TreeMap<String, String> items = new TreeMap<String, String>(); for (String localeCode : mAppLanguages) { Locale loc; if (localeCode.length() > 2) { loc = new Locale(localeCode.substring(0, 2), localeCode.substring(3, 5)); } else { loc = new Locale(localeCode); } items.put(loc.getDisplayName(), loc.toString()); } mLanguageDialogLabels = new CharSequence[items.size() + 1]; mLanguageDialogValues = new CharSequence[items.size() + 1]; mLanguageDialogLabels[0] = getResources().getString(R.string.language_system); mLanguageDialogValues[0] = ""; int i = 1; for (Map.Entry<String, String> e : items.entrySet()) { mLanguageDialogLabels[i] = e.getKey(); mLanguageDialogValues[i] = e.getValue(); i++; } mLanguageSelection = (ListPreference) getPreferenceScreen().findPreference("language"); mLanguageSelection.setEntries(mLanguageDialogLabels); mLanguageSelection.setEntryValues(mLanguageDialogValues); }
public static void LoadApplication(Context context, String runtimeDataDir, String[] apks) { synchronized (lock) { if (!initialized) { System.loadLibrary("monodroid"); Locale locale = Locale.getDefault(); String language = locale.getLanguage() + "-" + locale.getCountry(); String filesDir = context.getFilesDir().getAbsolutePath(); String cacheDir = context.getCacheDir().getAbsolutePath(); String dataDir = context.getApplicationInfo().dataDir + "/lib"; ClassLoader loader = context.getClassLoader(); Runtime.init( language, apks, runtimeDataDir, new String[] { filesDir, cacheDir, dataDir, }, loader, new java.io.File( android.os.Environment.getExternalStorageDirectory(), "Android/data/" + context.getPackageName() + "/files/.__override__") .getAbsolutePath(), MonoPackageManager_Resources.Assemblies); initialized = true; } } }
static { Locale locale = Locale.getDefault(); String lang = locale.getLanguage(); if (lang.equals("en")) { formatterMonth = FastDateFormat.getInstance("MMM dd", locale); formatterYear = FastDateFormat.getInstance("dd.MM.yy", locale); formatterYearMax = FastDateFormat.getInstance("dd.MM.yyyy", locale); chatDate = FastDateFormat.getInstance("MMMM d", locale); chatFullDate = FastDateFormat.getInstance("MMMM d, yyyy", locale); } else { formatterMonth = FastDateFormat.getInstance("dd MMM", locale); formatterYear = FastDateFormat.getInstance("dd.MM.yy", locale); formatterYearMax = FastDateFormat.getInstance("dd.MM.yyyy", locale); chatDate = FastDateFormat.getInstance("d MMMM", locale); chatFullDate = FastDateFormat.getInstance("d MMMM yyyy", locale); } formatterWeek = FastDateFormat.getInstance("EEE", locale); if (lang != null) { if (DateFormat.is24HourFormat(ApplicationLoader.applicationContext)) { formatterDay = FastDateFormat.getInstance("HH:mm", locale); } else { if (lang.toLowerCase().equals("ar")) { formatterDay = FastDateFormat.getInstance("h:mm a", locale); } else { formatterDay = FastDateFormat.getInstance("h:mm a", Locale.US); } } } else { formatterDay = FastDateFormat.getInstance("h:mm a", Locale.US); } }
@Override public List<String> defaultLanguageCodes() { final TreeSet<String> set = new TreeSet<String>(); set.add(Locale.getDefault().getLanguage()); final TelephonyManager manager = (TelephonyManager) myApplication.getSystemService(Context.TELEPHONY_SERVICE); if (manager != null) { final String country0 = manager.getSimCountryIso().toLowerCase(); final String country1 = manager.getNetworkCountryIso().toLowerCase(); for (Locale locale : Locale.getAvailableLocales()) { final String country = locale.getCountry().toLowerCase(); if (country != null && country.length() > 0 && (country.equals(country0) || country.equals(country1))) { set.add(locale.getLanguage()); } } if ("ru".equals(country0) || "ru".equals(country1)) { set.add("ru"); } else if ("by".equals(country0) || "by".equals(country1)) { set.add("ru"); } else if ("ua".equals(country0) || "ua".equals(country1)) { set.add("ru"); } } set.add("multi"); return new ArrayList<String>(set); }
@Override public String getDisplayName(Locale locale) { if (locale != null && locale.equals(Locale.KOREAN)) return "로그 선택자"; if (locale != null && locale.equals(Locale.JAPANESE)) return "ログセレクター"; if (locale != null && locale.equals(Locale.CHINESE)) return "数据筛选器"; return "Log Selector"; }
public static String loadMessage(final String code, final Object[] parameters) { // default message String errorMessage = ""; try { // get access to the error messages bundle final ResourceBundle messagesBundle = ResourceBundle.getBundle(ERRORS_BUNDLE, Locale.getDefault()); // construct the error message errorMessage = code + " - " + messagesBundle.getString(MESSAGE_PREFIX + code); // get access to the error message parameters bundle final ResourceBundle parametersBundle = ResourceBundle.getBundle(PARAMETERS_BUNDLE, Locale.getDefault()); // loop for all parameters for (int i = 0; i < parameters.length; i++) { // get parameter value final String parameterValue = parametersBundle.getString(PARAMETER_PREFIX + (String) parameters[i]); // replace parameter placeholder in the error message string errorMessage = errorMessage.replaceAll("\\{" + (i + 1) + "}", parameterValue); } } catch (Exception e) { // log the exception LOGGER.warning(e); } return errorMessage; }
@Override public void prepareModule() throws Exception { Context ctx = (Context) super.getServletRequest().getSession().getAttribute(ProfileConstants.context); Integer merchantid = ctx.getMerchantid(); ReferenceService rservice = (ReferenceService) ServiceFactory.getService(ServiceFactory.ReferenceService); Locale locale = getLocale(); String country = locale.getCountry(); if (locale.getVariant().equals("EUR")) { country = "X1"; } Map packages = ShippingUtil.buildPackageMap(moduleid, locale); if (packages != null) { setPackageMap(packages); } // get merchant configs MerchantService mservice = (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService); ConfigurationResponse config = mservice.getConfigurationByModule(moduleid, merchantid); this.setConfigurations(config); }