Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Essentials/src/main/java/com/earth2me/essentials/I18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
public class I18n implements net.ess3.api.II18n {
private static final String MESSAGES = "messages";
private static final Pattern NODOUBLEMARK = Pattern.compile("''");
// A color tag is invisible once rendered, so a translation with whitespace on
// both sides of one shows a double space in chat. Many locales carry this.
private static final Pattern SPACED_COLOR_TAG = Pattern.compile("\\s+(</?(?:primary|secondary)>)\\s+");
private static volatile ExecutorService BUNDLE_LOADER_EXECUTOR = Executors.newFixedThreadPool(2);
private static final ResourceBundle NULL_BUNDLE = new ResourceBundle() {
@SuppressWarnings("NullableProblems")
Expand Down Expand Up @@ -193,7 +196,7 @@ private String translate(final Locale locale, final String string) {
}

private String format(final Locale locale, final String string, final Object... objects) {
String format = translate(locale, string);
String format = SPACED_COLOR_TAG.matcher(translate(locale, string)).replaceAll(" $1");

MessageFormat messageFormat = messageFormatCache.computeIfAbsent(locale, l -> new HashMap<>()).get(format);
if (messageFormat == null) {
Expand Down