Create a MessageFormat for the given message and Locale.

@param msg the message to create a MessageFormat for
@param locale the Locale to create a MessageFormat for
@return the MessageFormat instance
192784
protected MessageFormat createMessageFormat(String msg, Locale locale) {
        return new MessageFormat((msg != null ? msg : ""), locale);
    }
993290
MessageResource loadResource(final Locale locale) {

        if(locale == null) {
            return defaultResource;
        }

        if(resources.containsKey(locale)) {
            return resources.get(locale);
        }

        MessageResource localeResource = null;
        synchronized (resources) {
            for(String path : getPropertyPath(locale)) {

                try {
                    final Properties props = new Properties();
                    props.load(new InputStreamReader(MessageResolver.class.getResourceAsStream(path), "UTF-8"));

                    localeResource = new MessageResource();

                    final Enumeration<?> keys = props.propertyNames();
                    while(keys.hasMoreElements()) {
                        String key = (String) keys.nextElement();
                        String value = props.getProperty(key);
                        localeResource.addMessage(key, value);
                    }

                    // ユーザのリソースの読み込み
                    if(appendUserResource) {
                        localeResource.addMessage(loadUserResource(path));
                    }

                    break;

                } catch(NullPointerException | IOException e) {
                    continue;
                }

            }

            if(localeResource == null) {
                // 該当するリソースが見つからない場合は、デフォルトの値を返す。
                localeResource = defaultResource;
            }

            resources.put(locale, localeResource);
        }

        return localeResource;

    }
777354
public String getMessage(final Locale locale, final String key, final String defaultValue) {
        String message = getMessage(locale, key);
        return message == null ? defaultValue : message;
    }
1057921
public String getName(final Locale locale) {
        return messageResolver.getMessage(locale, String.format("locale.%s.name", hexId));
    }
558462
public static String formatMessage(String msgKey) {
        String msg;
        try {
            msg = JaxbToolsConstants.messages.getString(msgKey);
        } catch (Exception ex) {
            // no FFDC required
            return msgKey;
        }

        return msg;
    }
976135
public @Nonnull StaticMessageSource addMessage(@Nonnull Locale locale, @Nonnull String code, @Nonnull String message) {
        ArgumentUtils.requireNonNull("locale", locale);
        if (StringUtils.isNotEmpty(code) && StringUtils.isNotEmpty(message)) {
            messageMap.put(new MessageKey(locale, code), message);
        }
        return this;
    }
409355
public function translateMessage(string $locale, string $namespace, string $message, array $args = []): string
    {
        $translation = $this->getStorage()->get($locale, $namespace, $message);
        if ($translation !== null) {
            $message = $translation[BundleStorageInterface::INDEX_PAIR_VALUE];
            $locale  = $translation[BundleStorageInterface::INDEX_PAIR_LOCALE];
        }

        return static::formatMessage($locale, $message, $args);
    }
219246
String formatMessage(int msgLogLevel, String module, String msg) {
        return getLevelTag(msgLogLevel) + module + ": " + msg;
    }
1369214
protected String resolveOnClic(Locale locale) {

        String confirmationMessage = getConfirmationMessage().key(locale);
        if ((getColumnForTexts() != null) && (getItem().get(getColumnForTexts()) != null)) {
            confirmationMessage = new MessageFormat(confirmationMessage, locale).format(
                new Object[] {getItem().get(getColumnForTexts())});
        }
        StringBuffer onClic = new StringBuffer(128);
        onClic.append("listAction('");
        onClic.append(getListId());
        onClic.append("', '");
        onClic.append(getId());
        onClic.append("', '");
        if ((getColumnForTexts() == null)
            || (getItem().get(getColumnForTexts()) == null)
            || confirmationMessage.equals(new MessageFormat(confirmationMessage, locale).format(new Object[] {""}))) {
            onClic.append("conf" + getId());
        } else {
            onClic.append(CmsStringUtil.escapeJavaScript(confirmationMessage));
        }
        onClic.append("', '");
        onClic.append(CmsStringUtil.escapeJavaScript(getItem().getId()));
        onClic.append("');");
        return onClic.toString();
    }
643327
public void setContentLanguage(Locale locale) {
		checkCommitted();
		ContentLanguageHeader contentLanguageHeader =
			SipFactoryImpl.headerFactory.createContentLanguageHeader(locale);
		this.message.setContentLanguage(contentLanguageHeader);
	}
17369
public static Locale parseLocale(String localeString) {
    if (localeString == null) {
      return Locale.US;
    }
    String[] groups = localeString.split("[-_]");
    switch (groups.length) {
      case 1:
        return new Locale(groups[0]);
      case 2:
        return new Locale(groups[0], Ascii.toUpperCase(groups[1]));
      case 3:
        return new Locale(groups[0], Ascii.toUpperCase(groups[1]), groups[2]);
      default:
        throw new IllegalArgumentException("Malformed localeString: " + localeString);
    }
  }
21300
public Properties getAllMessages(Locale locale) {

		Properties props = new Properties();
		Properties mergedProps = null;
		if (locale == null) {
			locale = Locale.getDefault();
		}
		mergedProps = getMergedProperties(locale).getProperties();

		Set<Entry<Object, Object>> entries = mergedProps.entrySet();
		for (Entry<Object, Object> entry : entries) {
			String key = (String) entry.getKey();
			if (LocaleUtils.matchesFilter(key, filters)) {

				try {
					// Use the property encoding of the file
					String msg = getMessage(key, new Object[0], locale);
					
					// When war is deployed, the resource bundle are encoded in ISO 8859-1
					// and otherwise in UTF-8 
					// Check the following link for more detail https://grails.org/Internationalization
					if(!warDeployed){
						msg = new String(msg.getBytes(CHARSET_ISO_8859_1),
								CHARSET_UTF_8);
					}

					props.put(key, msg);
				} catch (NoSuchMessageException e) {
					// This is expected, so it's OK to have an empty catch
					// block.
					if (LOGGER.isDebugEnabled())
						LOGGER.debug("Message key [" + key + "] not found.");
				} catch (UnsupportedEncodingException e) {
					LOGGER.warn("Unable to convert value of message bundle associated to key '"
							+ key + "' because the charset is unknown");
				}
			}
		}
		return props;
	}
643633
protected final String toLocaleStr(Locale locale) {
    if (locale == Locale.ROOT) { return ""; }
    String language = locale.getLanguage();
    String country = locale.getCountry();
    String variant = locale.getVariant();
    if (language == "" && country == "" && variant == "") { return ""; }

    StringBuilder sb = new StringBuilder();
    if (variant != "") {
      sb.append(language).append('_').append(country).append('_').append(variant);
    } else if (country != "") {
      sb.append(language).append('_').append(country);
    } else {
      sb.append(language);
    }
    return sb.toString();
  }
1235363
public String toSyslogMessage(MessageFormat messageFormat) {
        switch (messageFormat) {
            case RFC_3164:
                return toRfc3164SyslogMessage();
            case RFC_5424:
                return toRfc5424SyslogMessage();
            case RFC_5425:
                return toRfc5425SyslogMessage();
            default:
                throw new IllegalStateException("Unsupported message format '" + messageFormat + "'");
        }
    }
722157
public static ListFormatter getInstance(Locale locale) {
        return getInstance(ULocale.forLocale(locale), Style.STANDARD);
    }
437791
public static MessageFormat pluralizeFormat(final String template, final Locale locale)
    {
        return withinLocale(new Callable<MessageFormat>()
        {
            public MessageFormat call() throws Exception
            {
                return pluralizeFormat(template);
            };
        }, locale);
    }
1046201
@Route(method = HttpMethod.GET, uri = "i18n/{key}")
    public Result getMessage(@Parameter("key") String key, @QueryParameter("locale") Locale locale) {
        String message;
        if (locale != null && !locale.equals(InternationalizationService.DEFAULT_LOCALE)) {
            message = service.get(locale, key);
        } else {
            message = service.get(context().request().languages(), key);
        }

        if (message != null) {
            return ok(message).as(MimeTypes.TEXT);
        } else {
            return notFound("No message for " + key).as(MimeTypes.TEXT);
        }
    }