Refine search
/** * @see org.alfresco.service.cmr.rule.RuleType#getDisplayLabel() */ public String getDisplayLabel() { return I18NUtil.getMessage(this.name + "." + "display-label"); }
/** * Sets current Locale from string */ public void setLocale(String localeStr) { Locale newLocale = I18NUtil.parseLocale(localeStr); I18NUtil.setLocale(newLocale); }
/** * Get message from registered resource bundle. * * @param messageKey message key * @return localised message string, null if not found */ public static String getMessage(String messageKey) { return getMessage(messageKey, getLocale()); }
/** * @return the map of all available messages for the current locale */ public static Map<String, String> getAllMessages() { return getLocaleProperties(getLocale()); }
/** * Test getting a parameterised message */ public void testGetMessageWithParams() { // Register the bundle I18NUtil.registerResourceBundle(BASE_RESOURCE_NAME); // Check the default value assertEquals(VALUE_PARAMS, I18NUtil.getMessage(MSG_PARAMS, new Object[]{PARAM_VALUE})); // Change the locale and re-test I18NUtil.setLocale(new Locale("fr", "FR")); // Check the default value assertEquals(VALUE_FR_PARAMS, I18NUtil.getMessage(MSG_PARAMS, new Object[]{PARAM_VALUE})); // Check values when overriding the locale assertEquals(VALUE_PARAMS, I18NUtil.getMessage(MSG_PARAMS, Locale.getDefault(), new Object[]{PARAM_VALUE})); }
@Override protected void setUp() throws Exception { // Re-set the current locale to be the default Locale.setDefault(Locale.ENGLISH); I18NUtil.setLocale(Locale.getDefault()); }
public void testLocaleParsing() { assertEquals(Locale.FRANCE, I18NUtil.parseLocale("fr_FR")); assertEquals(new Locale("en", "GB", "cockney"), I18NUtil.parseLocale("en_GB_cockney")); assertEquals(new Locale("en", "GB", ""), I18NUtil.parseLocale("en_GB")); assertEquals(new Locale("en", "", ""), I18NUtil.parseLocale("en")); assertEquals(Locale.getDefault(), I18NUtil.parseLocale("")); } }
@Override public Locale resolveLocale(HttpServletRequest request) { Locale locale = Locale.getDefault(); // set language locale from browser header if available final String acceptLang = request.getHeader("Accept-Language"); if (acceptLang != null && acceptLang.length() != 0) { StringTokenizer t = new StringTokenizer(acceptLang, ",; "); // get language and convert to java locale format String language = t.nextToken().replace('-', '_'); locale = I18NUtil.parseLocale(language); } // set locale onto Alfresco thread local I18NUtil.setLocale(locale); return locale; } }
/** * Test the set and get methods */ public void testSetAndGet() { // Check that the default locale is returned assertEquals(Locale.getDefault(), I18NUtil.getLocale()); // Set the locals I18NUtil.setLocale(Locale.CANADA_FRENCH); assertEquals(Locale.CANADA_FRENCH, I18NUtil.getLocale()); // Reset the locale I18NUtil.setLocale(null); assertEquals(Locale.getDefault(), I18NUtil.getLocale()); }
/** * Get the content local language only (ignore the country and variant) for the current thread.<br/> * This will revert to {@link #getLocale()} if no value has been defined. * * @return Returns the content locale language */ public static Locale getContentLocaleLang() { Locale locale = threadContentLocaleLang.get(); if (locale == null) { if (threadContentLocale.get() != null) { locale = new Locale(threadContentLocale.get().getLanguage()); } else { // Revert to the normal locale lang locale = new Locale(getLocale().getLanguage()); } threadContentLocaleLang.set(locale); } return locale; }
I18NUtil.setLocale(Locale.GERMAN); I18NUtil.setLocale(Locale.ITALY); assertEquals(AddFeaturesActionExecuter.PARAM_CONSTRAINT, constraintName); I18NUtil.setLocale(Locale.getDefault());
properties = ResourceBundle.getBundle(BASE_RESOURCE_NAME, new Locale("fr", "FR")); assertNotNull(properties); I18NUtil.registerResourceBundle(BASE_RESOURCE_NAME); I18NUtil.setLocale(new Locale("fr", "FR"));
Locale loc1 = I18NUtil.parseLocale(langList.get(0)); Locale loc2 = I18NUtil.parseLocale(langList.get(1)); Locale loc3 = I18NUtil.parseLocale(langList.get(2)); assertFalse("Missing Translation List false. Locale " + loc2.toString() + " or " + loc3.toString() + " found", missing.contains(loc2) || missing.contains(loc3));
@Before public void before() { super.before(); contentLocaleToRestore = I18NUtil.getContentLocale(); localeToRestore = I18NUtil.getLocale(); Locale.setDefault(Locale.ENGLISH); MLPropertyInterceptor.setMLAware(false); }
private void dumpNodeStore(Locale locale) { System.out.println(locale.getDisplayLanguage() + " LOCALE: "); I18NUtil.setLocale(locale); System.out.println(NodeStoreInspector.dumpNodeStore((NodeService) applicationContext.getBean("NodeService"), storeRef)); }
public Locale getLocale() { return I18NUtil.getLocale(); }
/** * Gets the user's locale. * * @param userId the user id * @return the default locale or the user's preferred locale, if available */ public Locale getUserLocaleOrDefault(String userId) { if (userId != null && personService.personExists(userId)) { String localeString = AuthenticationUtil.runAsSystem(() -> (String) preferenceService.getPreference(userId, "locale")); if (localeString != null) { return I18NUtil.parseLocale(localeString); } } return I18NUtil.getLocale(); } }
throws TemplateException Locale currentLocale = I18NUtil.getLocaleOrNull(); Locale currentContentLocale = I18NUtil.getContentLocaleOrNull(); I18NUtil.setLocale(locale); I18NUtil.setLocale(currentLocale); I18NUtil.setContentLocale(currentContentLocale);
public void setLocale(Locale locale) { I18NUtil.setLocale(locale); }