Skip to content

Commit

Permalink
Add format API
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Oct 5, 2020
1 parent aa04597 commit 02aa6eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/net/citizensnpcs/api/util/Translator.java
Expand Up @@ -67,8 +67,9 @@ private ResourceBundle getDefaultBundle() {

private MessageFormat getFormatter(String unreplaced) {
MessageFormat formatter = messageFormatCache.get(unreplaced);
if (formatter == null)
if (formatter == null) {
messageFormatCache.put(unreplaced, formatter = new MessageFormat(unreplaced));
}
return formatter;
}

Expand Down Expand Up @@ -216,6 +217,11 @@ public static void addTranslations(TranslationProvider... providers) {
addTranslations(Arrays.asList(providers));
}

public static String format(String msg, Object... objects) {
MessageFormat formatter = instance.getFormatter(msg);
return formatter.format(objects);
}

private static Properties getDefaultBundleProperties() {
Properties defaults = new Properties();
InputStream in = null;
Expand Down

0 comments on commit 02aa6eb

Please sign in to comment.