/** Returns the default locale, either {@link #getLocale} or * {@link Locales#getCurrent} (never null). * It is useful when you wan to get a locale for this input. * @since 5.0.10 */ protected Locale getDefaultLocale() { return _locale != null ? _locale : Locales.getCurrent(); }
/** Converts a string that consists of language, country and variant * to a locale. * * <p>A shortcut: getLocale(localeString, (char)0). */ public static final Locale getLocale(String localeString) { return getLocale(localeString, (char)0); }
/** Cleans up what has been set in {@link #setup}. * Some invocation are not undo-able, so this method only does the basic * cleanups. * * @param old the value must be the one returned by the last call to * {@link #setup}. */ public static final void cleanup(ServletRequest request, Object old) { if (old != Objects.UNKNOWN) { Locales.setThreadLocal((Locale) old); markSetup(request, false); } }
myLocate(String file, Locale locale, Locator locator, boolean asStream) { if (locale == null) locale = Locales.getCurrent(); jslash >= 0 ? file.indexOf('.', jslash + 1): file.indexOf('.'); final String ext = jdot >= 0 ? file.substring(jdot): ""; final int jul = Locales.indexOfUnderline(file, jslash >= 0 ? jslash + 1: 0); final String base = file.substring(0, jul >= 0 && (jdot < 0 || jul < jdot) ? jul: sb.append(secs[k]); l = Locales.getLocale(sb.toString(), '_'); } else { l = null;
public void reloadMessages(Locale locale) throws IOException { if (locale == null) locale = Locales.getCurrent(); final StringBuffer sb = new StringBuffer(4096); final Locale oldl = Locales.setThreadLocal(locale); try { final Execution exec = Executions.getCurrent(); sb.append(Devices.loadJavaScript(exec, "~./js/zk/lang/msgzk*.js")); sb.append(Wpds.outLocaleJavaScript()); for (LanguageDefinition langdef : LanguageDefinition.getByDeviceType(getType())) for (MessageLoader loader : langdef.getMessageLoaders()) loader.load(sb, exec); } finally { Locales.setThreadLocal(oldl); } Clients.response("zk.reload", new AuScript(null, sb.toString())); } }
/** Carry over the info stored in the constructor to * the current thread. */ public void carryOver() { ExecutionsCtrl.setCurrent(_exec); final ExecutionCtrl execCtrl = (ExecutionCtrl) _exec; execCtrl.onActivate(); if (Locales.getThreadLocal() == null) Locales.setThreadLocal(_locale); else _locale = null; if (TimeZones.getThreadLocal() == null) TimeZones.setThreadLocal(_timeZone); else _timeZone = null; final Page page = _exec.getDesktop().getFirstPage(); if (page != null) execCtrl.setCurrentPage(page); }
/** Returns the index of '_' preceding the country part. * It is similar to s.indexOf('_'), except it detects country part * (which must be only two letter in lower cases. */ public static int indexOfUnderline(String s) { return indexOfUnderline(s, 0); } }
private static final Locale getLocale() { return Locales.getCurrent(); } /** Creates a MessageFormat with the given pattern and uses it to
/** * Logs a message and a throwable object at the giving level * by giving a message code and NO format argument. * * @param t the throwable object; null to ignore */ public final void log(Level level, int code, Throwable t) { final Locale l = Locales.setThreadLocal(null); try { log(level, Messages.get(code), t); } finally { Locales.setThreadLocal(l); } }
/** Sets the locale used to identify the symbols of this number input element. * <p>Default: null (i.e., {@link Locales#getCurrent}, the current locale * is assumed) * @since 5.0.8 */ public void setLocale(String locale) { setLocale(locale != null && locale.length() > 0 ? Locales.getLocale(locale) : null); }
private static final Locale getLocale() { return Locales.getCurrent(); }
/** * Logs a message and a throwable object at the giving level * by giving a message code and ONE format argument. * * @param t the throwable object; null to ignore */ public final void log(Level level, int code, Object fmtArg, Throwable t) { final Locale l = Locales.setThreadLocal(null); try { log(level, Messages.get(code, fmtArg), t); } finally { Locales.setThreadLocal(l); } } /**
/** Sets the locale used to identify the format of this timebox. * <p>Default: null (i.e., {@link Locales#getCurrent}, the current locale * is assumed) * @since 5.0.7 */ public void setLocale(String locale) { setLocale(locale != null && locale.length() > 0 ? Locales.getLocale(locale) : null); }
/** Converts all of the characters in this String to upper case using the rules of the current Locale. * @see Locales#getCurrent * @since 5.0.7 */ public static String toLowerCase(String s) { return s != null ? s.toLowerCase(Locales.getCurrent()): null; } /** Converts all of the characters in this String to upper case using the rules of the current Locale.
/** * Logs a message and a throwable object at the giving level * by giving a message code and multiple format arguments. * * @param t the throwable object; null to ignore */ public final void log(Level level, int code, Object[] fmtArgs, Throwable t) { final Locale l = Locales.setThreadLocal(null); try { log(level, Messages.get(code, fmtArgs), t); } finally { Locales.setThreadLocal(l); } } /**
/** Sets the locale used to identify the format of this datebox. * <p>Default: null (i.e., {@link Locales#getCurrent}, the current locale * is assumed) * @since 5.0.7 */ public void setLocale(String locale) { setLocale(locale != null && locale.length() > 0 ? Locales.getLocale(locale) : null); }
/** Converts all of the characters in this String to upper case using the rules of the current Locale. * @see Locales#getCurrent * @since 5.0.7 */ public static String toUpperCase(String s) { return s != null ? s.toUpperCase(Locales.getCurrent()): null; } /** Returns a copy of the string, with leading and trailing whitespace omitted.
/** Cleans up the info carried from onPiggyback to the current thread. * <p>Note: {@link #carryOver} and {@link #cleanup} must be * called in the same thread. */ public void cleanup() { ((ExecutionCtrl) _exec).onDeactivate(); ExecutionsCtrl.setCurrent(null); if (_locale != null) Locales.setThreadLocal(null); if (_timeZone != null) TimeZones.setThreadLocal(null); } }
return getLocale(new Locale(lang, cnt, var));
private static final DateFormat getDateFormat(boolean dateOnly) { final Locale locale = Locales.getCurrent(); return dateOnly ? DateFormat.getDateInstance(DateFormat.DEFAULT, locale): DateFormat.getDateTimeInstance( DateFormat.DEFAULT, DateFormat.DEFAULT, locale); } }