From 2a196760ff712f0a8e331f20ae51f2d2bc5142c0 Mon Sep 17 00:00:00 2001 From: XiaoMoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Sat, 12 Oct 2024 21:14:17 +0800 Subject: [PATCH] added supported languages --- .../customcrops/common/locale/TranslationManager.java | 6 ++++-- common/src/main/resources/custom-crops.properties | 3 ++- {plugin => common}/src/main/resources/translations/en.yml | 2 +- .../src/main/resources/translations/zh_cn.yml | 0 gradle.properties | 3 +++ 5 files changed, 10 insertions(+), 4 deletions(-) rename {plugin => common}/src/main/resources/translations/en.yml (99%) rename {plugin => common}/src/main/resources/translations/zh_cn.yml (100%) diff --git a/common/src/main/java/net/momirealms/customcrops/common/locale/TranslationManager.java b/common/src/main/java/net/momirealms/customcrops/common/locale/TranslationManager.java index 388e29e..3688bb2 100644 --- a/common/src/main/java/net/momirealms/customcrops/common/locale/TranslationManager.java +++ b/common/src/main/java/net/momirealms/customcrops/common/locale/TranslationManager.java @@ -23,6 +23,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.translation.Translator; import net.momirealms.customcrops.common.helper.AdventureHelper; import net.momirealms.customcrops.common.plugin.CustomCropsPlugin; +import net.momirealms.customcrops.common.plugin.CustomCropsProperties; import net.momirealms.customcrops.common.util.Pair; import org.jetbrains.annotations.Nullable; @@ -38,7 +39,6 @@ import java.util.stream.Stream; public class TranslationManager { public static final Locale DEFAULT_LOCALE = Locale.ENGLISH; - private static final List locales = List.of("en", "zh_cn"); private static TranslationManager instance; private static Locale FORCE_LOCALE = null; @@ -63,7 +63,9 @@ public class TranslationManager { MiniMessageTranslator.translator().removeSource(this.registry); this.installed.clear(); } - for (String lang : locales) { + + String supportedLocales = CustomCropsProperties.getValue("lang"); + for (String lang : supportedLocales.split(",")) { this.plugin.getConfigManager().saveResource("translations/" + lang + ".yml"); } diff --git a/common/src/main/resources/custom-crops.properties b/common/src/main/resources/custom-crops.properties index 931312c..d56e5e0 100644 --- a/common/src/main/resources/custom-crops.properties +++ b/common/src/main/resources/custom-crops.properties @@ -17,4 +17,5 @@ gson=${gson_version} caffeine=${caffeine_version} exp4j=${exp4j_version} slf4j=${slf4j_version} -zstd-jni=${zstd_version} \ No newline at end of file +zstd-jni=${zstd_version} +lang=${lang} \ No newline at end of file diff --git a/plugin/src/main/resources/translations/en.yml b/common/src/main/resources/translations/en.yml similarity index 99% rename from plugin/src/main/resources/translations/en.yml rename to common/src/main/resources/translations/en.yml index d40a95b..2f9739c 100644 --- a/plugin/src/main/resources/translations/en.yml +++ b/common/src/main/resources/translations/en.yml @@ -1,4 +1,4 @@ -# Don"t change this +# Don't change this config-version: "41" season.spring: "Spring" diff --git a/plugin/src/main/resources/translations/zh_cn.yml b/common/src/main/resources/translations/zh_cn.yml similarity index 100% rename from plugin/src/main/resources/translations/zh_cn.yml rename to common/src/main/resources/translations/zh_cn.yml diff --git a/gradle.properties b/gradle.properties index a1347f9..4dc2853 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,6 +4,9 @@ project_version=3.6.16 config_version=41 project_group=net.momirealms +# Supported languages +lang=en,zh_cn + # Dependency settings paper_version=1.20.4 jetbrains_annotations_version=24.0.0