From 3af2fec57581e0cb26580d83cd7f214614aa67c7 Mon Sep 17 00:00:00 2001 From: muriplz <46825658+muriplz@users.noreply.github.com> Date: Fri, 19 Jan 2024 05:07:01 +0100 Subject: [PATCH] Added translated message server side, with many languages --- build.gradle | 14 +++++--------- gradle.properties | 4 +++- .../java/com/kryeit/votifier/command/Vote.java | 5 +++-- src/main/resources/data/votifier/lang/de_de.json | 3 +++ src/main/resources/data/votifier/lang/en_us.json | 3 +++ src/main/resources/data/votifier/lang/es_es.json | 3 +++ src/main/resources/data/votifier/lang/fr_fr.json | 3 +++ src/main/resources/data/votifier/lang/hi_in.json | 3 +++ src/main/resources/data/votifier/lang/it_it.json | 3 +++ src/main/resources/data/votifier/lang/ja_jp.json | 3 +++ src/main/resources/data/votifier/lang/ko_kr.json | 3 +++ src/main/resources/data/votifier/lang/lv_lv.json | 3 +++ src/main/resources/data/votifier/lang/nb_no.json | 3 +++ src/main/resources/data/votifier/lang/nl_nl.json | 3 +++ src/main/resources/data/votifier/lang/pt_br.json | 3 +++ src/main/resources/data/votifier/lang/pt_pt.json | 3 +++ src/main/resources/data/votifier/lang/ru_ru.json | 3 +++ src/main/resources/data/votifier/lang/sv_se.json | 3 +++ src/main/resources/data/votifier/lang/tr_tr.json | 3 +++ src/main/resources/data/votifier/lang/zh_cn.json | 3 +++ src/main/resources/votifier.json | 2 +- 21 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 src/main/resources/data/votifier/lang/de_de.json create mode 100644 src/main/resources/data/votifier/lang/en_us.json create mode 100644 src/main/resources/data/votifier/lang/es_es.json create mode 100644 src/main/resources/data/votifier/lang/fr_fr.json create mode 100644 src/main/resources/data/votifier/lang/hi_in.json create mode 100644 src/main/resources/data/votifier/lang/it_it.json create mode 100644 src/main/resources/data/votifier/lang/ja_jp.json create mode 100644 src/main/resources/data/votifier/lang/ko_kr.json create mode 100644 src/main/resources/data/votifier/lang/lv_lv.json create mode 100644 src/main/resources/data/votifier/lang/nb_no.json create mode 100644 src/main/resources/data/votifier/lang/nl_nl.json create mode 100644 src/main/resources/data/votifier/lang/pt_br.json create mode 100644 src/main/resources/data/votifier/lang/pt_pt.json create mode 100644 src/main/resources/data/votifier/lang/ru_ru.json create mode 100644 src/main/resources/data/votifier/lang/sv_se.json create mode 100644 src/main/resources/data/votifier/lang/tr_tr.json create mode 100644 src/main/resources/data/votifier/lang/zh_cn.json diff --git a/build.gradle b/build.gradle index 05a5457..1fd2bf5 100644 --- a/build.gradle +++ b/build.gradle @@ -11,11 +11,10 @@ base { } repositories { - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. + maven { + name = 'Translations API' + url = 'https://maven.nucleoid.xyz' + } } loom { @@ -38,11 +37,8 @@ dependencies { // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - - // Uncomment the following line to enable the deprecated Fabric API modules. - // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. - // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" + modImplementation include("xyz.nucleoid:server-translations-api:${servertranslations_version}") } processResources { diff --git a/gradle.properties b/gradle.properties index a276584..ed0598c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,4 +14,6 @@ fabric_version=0.91.0+1.20.1 # Mod Properties mod_version=1.1 maven_group=com.kryeit -archives_base_name=votifier \ No newline at end of file +archives_base_name=votifier + +servertranslations_version=2.0.0+1.20 diff --git a/src/main/java/com/kryeit/votifier/command/Vote.java b/src/main/java/com/kryeit/votifier/command/Vote.java index fb768bc..d48e802 100644 --- a/src/main/java/com/kryeit/votifier/command/Vote.java +++ b/src/main/java/com/kryeit/votifier/command/Vote.java @@ -9,6 +9,7 @@ import net.minecraft.text.ClickEvent; import net.minecraft.text.Style; import net.minecraft.text.Text; +import xyz.nucleoid.server.translations.api.Localization; import java.util.function.Supplier; @@ -25,8 +26,8 @@ public static int execute(CommandContext context) { return 0; } - String link = LINK; - player.sendMessage(Text.literal("Voting site -> " + link) + String link = LINK.replace("%player%", player.getName().getString()); + player.sendMessage(Text.literal(Localization.raw("votifier.voting_site", player) + " -> " + link) .setStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link)))); return Command.SINGLE_SUCCESS; } diff --git a/src/main/resources/data/votifier/lang/de_de.json b/src/main/resources/data/votifier/lang/de_de.json new file mode 100644 index 0000000..37d5f3b --- /dev/null +++ b/src/main/resources/data/votifier/lang/de_de.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Abstimmungsseite" +} diff --git a/src/main/resources/data/votifier/lang/en_us.json b/src/main/resources/data/votifier/lang/en_us.json new file mode 100644 index 0000000..93a9020 --- /dev/null +++ b/src/main/resources/data/votifier/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Voting Site" +} \ No newline at end of file diff --git a/src/main/resources/data/votifier/lang/es_es.json b/src/main/resources/data/votifier/lang/es_es.json new file mode 100644 index 0000000..6d765f0 --- /dev/null +++ b/src/main/resources/data/votifier/lang/es_es.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Página de votación" +} \ No newline at end of file diff --git a/src/main/resources/data/votifier/lang/fr_fr.json b/src/main/resources/data/votifier/lang/fr_fr.json new file mode 100644 index 0000000..24ed33c --- /dev/null +++ b/src/main/resources/data/votifier/lang/fr_fr.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Site de vote" +} \ No newline at end of file diff --git a/src/main/resources/data/votifier/lang/hi_in.json b/src/main/resources/data/votifier/lang/hi_in.json new file mode 100644 index 0000000..84c8bb7 --- /dev/null +++ b/src/main/resources/data/votifier/lang/hi_in.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "मतदान साइट" +} \ No newline at end of file diff --git a/src/main/resources/data/votifier/lang/it_it.json b/src/main/resources/data/votifier/lang/it_it.json new file mode 100644 index 0000000..5e3ccef --- /dev/null +++ b/src/main/resources/data/votifier/lang/it_it.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Sito di Votazione" +} diff --git a/src/main/resources/data/votifier/lang/ja_jp.json b/src/main/resources/data/votifier/lang/ja_jp.json new file mode 100644 index 0000000..47f196c --- /dev/null +++ b/src/main/resources/data/votifier/lang/ja_jp.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "投票サイト" +} diff --git a/src/main/resources/data/votifier/lang/ko_kr.json b/src/main/resources/data/votifier/lang/ko_kr.json new file mode 100644 index 0000000..f832add --- /dev/null +++ b/src/main/resources/data/votifier/lang/ko_kr.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "투표 사이트" +} diff --git a/src/main/resources/data/votifier/lang/lv_lv.json b/src/main/resources/data/votifier/lang/lv_lv.json new file mode 100644 index 0000000..fcd0a28 --- /dev/null +++ b/src/main/resources/data/votifier/lang/lv_lv.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Balsošanas vietne" +} diff --git a/src/main/resources/data/votifier/lang/nb_no.json b/src/main/resources/data/votifier/lang/nb_no.json new file mode 100644 index 0000000..dcd15f3 --- /dev/null +++ b/src/main/resources/data/votifier/lang/nb_no.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Avstemningsnettsted" +} diff --git a/src/main/resources/data/votifier/lang/nl_nl.json b/src/main/resources/data/votifier/lang/nl_nl.json new file mode 100644 index 0000000..148f766 --- /dev/null +++ b/src/main/resources/data/votifier/lang/nl_nl.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Stemsite" +} \ No newline at end of file diff --git a/src/main/resources/data/votifier/lang/pt_br.json b/src/main/resources/data/votifier/lang/pt_br.json new file mode 100644 index 0000000..a8e24d1 --- /dev/null +++ b/src/main/resources/data/votifier/lang/pt_br.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Site de Votação" +} diff --git a/src/main/resources/data/votifier/lang/pt_pt.json b/src/main/resources/data/votifier/lang/pt_pt.json new file mode 100644 index 0000000..a8e24d1 --- /dev/null +++ b/src/main/resources/data/votifier/lang/pt_pt.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Site de Votação" +} diff --git a/src/main/resources/data/votifier/lang/ru_ru.json b/src/main/resources/data/votifier/lang/ru_ru.json new file mode 100644 index 0000000..6cd4f2e --- /dev/null +++ b/src/main/resources/data/votifier/lang/ru_ru.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Сайт Голосования" +} \ No newline at end of file diff --git a/src/main/resources/data/votifier/lang/sv_se.json b/src/main/resources/data/votifier/lang/sv_se.json new file mode 100644 index 0000000..811e30c --- /dev/null +++ b/src/main/resources/data/votifier/lang/sv_se.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Röstningssida" +} \ No newline at end of file diff --git a/src/main/resources/data/votifier/lang/tr_tr.json b/src/main/resources/data/votifier/lang/tr_tr.json new file mode 100644 index 0000000..38d996d --- /dev/null +++ b/src/main/resources/data/votifier/lang/tr_tr.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "Oylama Sitesi" +} \ No newline at end of file diff --git a/src/main/resources/data/votifier/lang/zh_cn.json b/src/main/resources/data/votifier/lang/zh_cn.json new file mode 100644 index 0000000..a27df46 --- /dev/null +++ b/src/main/resources/data/votifier/lang/zh_cn.json @@ -0,0 +1,3 @@ +{ + "votifier.voting_site": "投票网站" +} diff --git a/src/main/resources/votifier.json b/src/main/resources/votifier.json index c360819..01d48f9 100644 --- a/src/main/resources/votifier.json +++ b/src/main/resources/votifier.json @@ -3,5 +3,5 @@ "port": "8192", "debug": false, "command-after-voting": "/give %player% diamond 1", - "voting-link": "https://minecraft.net/?vote=true" + "voting-link": "https://minecraft.net/?vote=true?user=%player%" } \ No newline at end of file