Class BundledTranslations
java.lang.Object
dev.ua.theroer.magicutils.lang.BundledTranslations
Loads bundled MagicUtils translations from
/lang/<code>.json
classpath resources.
Files use flat dot-delimited keys and support JSON with comments
(including trailing commas). Keys starting with _ are treated
as translator-facing comments and dropped at load time.
Parsed resources are cached per language code since classpath resources are immutable during a JVM lifetime.
-
Method Summary
Modifier and TypeMethodDescriptionScans the classpath for bundledlang/*.jsonfiles and returns their language codes.availableNamespacedCodes(String namespace) Scans the classpath under/lang/<namespace>/and returns every available language code.static booleangetNamespacedTranslations(String namespace, String languageCode) Loads translations from/lang/<namespace>/<code>.jsoninside the calling plugin's classpath.getSections(String languageCode) Returns the translations grouped by section (the part before the first dot in each key).getTranslations(String languageCode) Returns the flatkey -> valuetranslation map for the given language code, loading from classpath on first access.
-
Method Details
-
getNamespacedTranslations
Loads translations from/lang/<namespace>/<code>.jsoninside the calling plugin's classpath. Useful for plugins that want to ship their own bundled translations alongside the MagicUtils core ones without polluting/lang/<code>.json.- Parameters:
namespace- plugin namespace (e.g."leavepulse")languageCode- language code- Returns:
- flat translation map, or empty when not found
-
availableNamespacedCodes
-
getTranslations
Returns the flatkey -> valuetranslation map for the given language code, loading from classpath on first access.- Parameters:
languageCode- language code (e.g."en")- Returns:
- unmodifiable flat translations, or an empty map when no bundled resource exists
-
getSections
Returns the translations grouped by section (the part before the first dot in each key). Compatible withLanguageConfig.applyTranslations().For example, the flat key
"magicutils.commands.no_permission"is stored under section"magicutils.commands"with relative key"no_permission".The
languagesection mapslanguage.name,language.code, etc. directly since it has no nested structure.- Parameters:
languageCode- language code- Returns:
- unmodifiable sectioned translations
-
exists
- Parameters:
languageCode- language code- Returns:
- true when a bundled resource exists for this code
-
availableCodes
-