public String message(String message) { if (_locale != _globalLocale) { synchronized (Messages.class) { init(); } } try { return _messages.getString(message); } catch (MissingResourceException except) { return message; } }
public Messages(String resourceName) { synchronized (Messages.class) { _locale = _globalLocale; _resourceName = resourceName + ".Messages"; ResourceBundle rb = (ResourceBundle) _rbBundles.get(_resourceName); if (rb == null) { init(); } else { _messages = rb; _formats = (Hashtable) _rbFormats.get(_resourceName); } } }
public String format(final String message, final Object... args) { init(); if (locale != _globalLocale) { synchronized (Messages.class) { init(); } } MessageFormat mf; final String msg; try { mf = (MessageFormat) formats.get(message); if (mf == null) { try { msg = messages.getString(message); } catch (final MissingResourceException except) { return message + (args != null ? " " + Arrays.toString(args) : ""); } mf = new MessageFormat(msg); formats.put(message, mf); } return mf.format(args); } catch (final Exception except) { return "An internal error occured while processing message " + message; } }
public String format(final String message, final Object... args) { init(); if (locale != _globalLocale) { synchronized (Messages.class) { init(); } } MessageFormat mf; final String msg; try { mf = (MessageFormat) formats.get(message); if (mf == null) { try { msg = messages.getString(message); } catch (final MissingResourceException except) { return message + (args != null ? " " + Arrays.toString(args) : ""); } mf = new MessageFormat(msg); formats.put(message, mf); } return mf.format(args); } catch (final Exception except) { return "An internal error occured while processing message " + message; } }
public String format(String message, Object... args) { if (_locale != _globalLocale) { synchronized (Messages.class) { init(); } } MessageFormat mf; String msg; try { mf = (MessageFormat) _formats.get(message); if (mf == null) { try { msg = _messages.getString(message); } catch (MissingResourceException except) { return message + (args != null ? " " + Arrays.toString(args) : ""); } mf = new MessageFormat(msg); _formats.put(message, mf); } return mf.format(args); } catch (Exception except) { return "An internal error occured while processing message " + message; } }