/** * Constructs a new {@code MessageFormat} using the specified pattern and {@code locale}. * * @param template * the pattern. * @param locale * the locale. * @throws IllegalArgumentException * if the pattern cannot be parsed. */ public MessageFormat(String template, Locale locale) { this.locale = locale; applyPattern(template); }
/** * Translate a text string based on our i18n files. * @since 3.1 */ public static String i18n(ResourceBundle messages, String key, Object... messageArguments) { MessageFormat formatter = new MessageFormat(""); formatter.applyPattern(messages.getString(key).replaceAll("'", "''")); return formatter.format(messageArguments); }
messageFormat.applyPattern(replaceEscapeChars(pattern)); return messageFormat.format(args);
messageFormat.applyPattern(replaceEscapeChars(pattern)); return messageFormat.format(args);
/** * Replace MessageFormat(String, Locale) constructor (not available until JDK 1.4). * @param pattern string * @param locale Locale * @return MessageFormat */ private MessageFormat createMessageFormat(final String pattern, final Locale locale) { final MessageFormat result = new MessageFormat(pattern); if (locale != null) { result.setLocale(locale); result.applyPattern(pattern); } return result; }
public final void applyPattern(final String pattern) { if (registry == null) { super.applyPattern(pattern); toPattern = super.toPattern(); return; super.applyPattern(stripCustom.toString()); toPattern = insertFormats(super.toPattern(), foundDescriptions); if (containsElements(foundFormats)) {
MessageFormat messageFormat = new MessageFormat(""); messageFormat.setLocale(bundle.getLocale()); messageFormat.applyPattern(value); try {
super.applyPattern(pattern); toPattern = super.toPattern(); return; super.applyPattern(stripCustom.toString()); toPattern = insertFormats(super.toPattern(), foundDescriptions); if (containsElements(foundFormats)) {
&& translationLanguage.equalsConsiderVariantsIfSpecified(motherTongue) && language != motherTongue && !translations.isEmpty()) { formatter.applyPattern(messages.getString("false_friend_hint")); String tokensAsString = StringUtils.join(patternTokens, " ").replace('|', '/'); Object[] messageArguments = {tokensAsString,
/** * Replace MessageFormat(String, Locale) constructor (not available until JDK 1.4). * @param pattern string * @param locale Locale * @return MessageFormat */ private MessageFormat createMessageFormat(final String pattern, final Locale locale) { final MessageFormat result = new MessageFormat(pattern); if (locale != null) { result.setLocale(locale); result.applyPattern(pattern); } return result; }
format.applyPattern(pattern); lastKey = key;
private String createError(String key, String[] arguments) { MessageFormat mf = new MessageFormat(""); mf.applyPattern(respage.getString(key)); return key + ": " + mf.format(arguments); }
public static String formatString(String string, Object... messageArguments) { if (messageArguments != null) { MessageFormat formatter = new MessageFormat(""); formatter.applyPattern(string.replace("'", "''")); string = formatter.format(messageArguments); } string = addColors(string); return string; }
public String getMessage(String key, Object[] args, boolean escapeSingleQuotes) { String pattern = getMessage(key); if (escapeSingleQuotes) pattern = pattern.replaceAll("'", "''"); // NOI18N String message; synchronized (mf) { mf.applyPattern(pattern); message = mf.format(args); } return message; }
public String getMessage(String key, Object[] args, boolean escapeSingleQuotes) { String pattern = getMessage(key); if (escapeSingleQuotes) pattern = pattern.replaceAll("'", "''"); // NOI18N String message; synchronized (mf) { mf.applyPattern(pattern); message = mf.format(args); } return message; }
public String getMessage(String key, Object[] messageArguments) { MessageFormat formatter = new MessageFormat(""); formatter.setLocale(this.messages.getLocale()); formatter.applyPattern(this.messages.getString(key)); return formatter.format(messageArguments); }
public void setInitialContext(InitialRenderContext context) { super.setInitialContext(context); String outputTemplate = outputMessages.getString(getLocaleKey() + ".print"); formatter = new MessageFormat(""); formatter.applyPattern(outputTemplate); }
public void setInitialContext(InitialRenderContext context) { super.setInitialContext(context); String outputTemplate = outputMessages.getString(getLocaleKey() + ".print"); formatter = new MessageFormat(""); formatter.applyPattern(outputTemplate); }
public static String getStringFormat(String s, Object[] args) { MessageFormat formatter = new MessageFormat(""); formatter.setLocale(Locale.getDefault()); formatter.applyPattern(getXJString(s)); return formatter.format(args); }
private static MessageFormat buildMessageFormat(String pattern, Locale locale) { MessageFormatKey key = new MessageFormatKey(pattern, locale); MessageFormat format = messageFormats.get(key); if (format == null) { format = new MessageFormat(pattern); format.setLocale(locale); format.applyPattern(pattern); messageFormats.put(key, format); } return format; }