diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 644783935..3a44ca23b 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -186,7 +186,8 @@ public class PlotSquared { DefaultCaptionProvider.forClassLoaderFormatString( this.getClass().getClassLoader(), "lang/messages_%s.json" - ) + ), + TranslatableCaption.DEFAULT_NAMESPACE ); // the path in our jar file // Load caption map try { @@ -1534,7 +1535,8 @@ public class PlotSquared { } /** - * Register a caption map + * Register a caption map. The namespace needs be equal to the namespace used for + * the {@link TranslatableCaption}s inside the map. * * @param namespace Namespace * @param captionMap Map instance diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/load/CaptionLoader.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/load/CaptionLoader.java index b4e0b2d2e..ac191dc8f 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/caption/load/CaptionLoader.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/load/CaptionLoader.java @@ -32,9 +32,9 @@ import com.plotsquared.core.configuration.caption.CaptionMap; import com.plotsquared.core.configuration.caption.LocalizedCaptionMap; import com.plotsquared.core.configuration.caption.PerUserLocaleCaptionMap; import com.plotsquared.core.configuration.caption.TranslatableCaption; -import org.checkerframework.checker.nullness.qual.NonNull; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.checkerframework.checker.nullness.qual.NonNull; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -76,15 +76,18 @@ public final class CaptionLoader { private final Locale defaultLocale; private final Function localeExtractor; private final DefaultCaptionProvider captionProvider; + private final String namespace; private CaptionLoader( final @NonNull Locale internalLocale, final @NonNull Function<@NonNull Path, @NonNull Locale> localeExtractor, - final @NonNull DefaultCaptionProvider captionProvider + final @NonNull DefaultCaptionProvider captionProvider, + final @NonNull String namespace ) { this.defaultLocale = internalLocale; this.localeExtractor = localeExtractor; this.captionProvider = captionProvider; + this.namespace = namespace; Map temp; try { temp = this.captionProvider.loadDefaults(internalLocale); @@ -107,9 +110,10 @@ public final class CaptionLoader { public static @NonNull CaptionLoader of( final @NonNull Locale internalLocale, final @NonNull Function<@NonNull Path, @NonNull Locale> localeExtractor, - final @NonNull DefaultCaptionProvider captionProvider + final @NonNull DefaultCaptionProvider captionProvider, + final @NonNull String namespace ) { - return new CaptionLoader(internalLocale, localeExtractor, captionProvider); + return new CaptionLoader(internalLocale, localeExtractor, captionProvider, namespace); } /** @@ -209,7 +213,10 @@ public final class CaptionLoader { save(file, map); // update the file using the modified map } return new LocalizedCaptionMap(locale, map.entrySet().stream() - .collect(Collectors.toMap(entry -> TranslatableCaption.of(entry.getKey()), Map.Entry::getValue))); + .collect(Collectors.toMap( + entry -> TranslatableCaption.of(this.namespace, entry.getKey()), + Map.Entry::getValue) + )); } }