diff options
-rw-r--r-- | REUSE.toml | 2 | ||||
-rw-r--r-- | build.gradle.kts | 18 | ||||
-rw-r--r-- | settings.gradle.kts | 3 | ||||
-rw-r--r-- | src/main/kotlin/commands/rome.kt | 12 | ||||
-rw-r--r-- | src/main/kotlin/util/textutil.kt | 4 | ||||
-rw-r--r-- | translations/en_us.json (renamed from src/main/resources/assets/firmament/lang/en_us.json) | 3 |
6 files changed, 33 insertions, 9 deletions
@@ -23,7 +23,7 @@ SPDX-License-Identifier = "GPL-3.0-or-later" SPDX-FileCopyrightText = ["Linnea Gräf <nea@nea.moe>", "Firmament Contributors"] [[annotations]] -path = "src/main/resources/assets/**/lang/*.json" +path = "translations/*.json" SPDX-License-Identifier = "CC0-1.0" SPDX-FileCopyrightText = ["Linnea Gräf <nea@nea.moe>", "Firmament Contributors"] diff --git a/build.gradle.kts b/build.gradle.kts index 4bcffe8..effa917 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,6 +9,7 @@ import com.google.devtools.ksp.gradle.KspTaskJvm import com.google.gson.JsonArray import moe.nea.licenseextractificator.LicenseDiscoveryTask +import moe.nea.mcautotranslations.gradle.CollectTranslations import net.fabricmc.loom.LoomGradleExtension import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.SubpluginOption @@ -24,6 +25,7 @@ plugins { alias(libs.plugins.loom) id("com.github.johnrengelman.shadow") version "8.1.1" id("moe.nea.licenseextractificator") + id("moe.nea.mc-auto-translations") version "0.0.1" } version = getGitTagInfo() @@ -110,6 +112,11 @@ fun innerJarsOf(name: String, dependency: Dependency): FileCollection { return project.files(task) } +val collectTranslations by tasks.registering(CollectTranslations::class) { + this.baseTranslations.from(file("translations/en_us.json")) + this.classes.from(sourceSets.main.get().kotlin.classesDirectory) +} + val compatSourceSets: MutableSet<SourceSet> = mutableSetOf() fun createIsolatedSourceSet(name: String, path: String = "compat/$name"): SourceSet { val ss = sourceSets.create(name) { @@ -146,6 +153,9 @@ fun createIsolatedSourceSet(name: String, path: String = "compat/$name"): Source tasks.shadowJar { from(ss.output) } + collectTranslations { + this.classes.from(sourceSets.main.get().kotlin.classesDirectory) + } return ss } @@ -300,6 +310,11 @@ loom { } } +mcAutoTranslations { + translationFunction.set("moe.nea.firmament.util.tr") + translationFunctionResolved.set("moe.nea.firmament.util.trResolved") +} + tasks.test { useJUnitPlatform() } @@ -356,6 +371,9 @@ tasks.processResources { } exclude("**/*.license") from(tasks.scanLicenses) + from(collectTranslations) { + into("assets/firmament/lang") + } } tasks.scanLicenses { diff --git a/settings.gradle.kts b/settings.gradle.kts index 36e7e3e..5c4a313 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,6 +25,9 @@ pluginManagement { name = "jitpack" url = uri("https://jitpack.io") } + maven { + url = uri("https://repo.nea.moe/releases") + } mavenCentral() gradlePluginPortal() } diff --git a/src/main/kotlin/commands/rome.kt b/src/main/kotlin/commands/rome.kt index 8fcbd77..39053d2 100644 --- a/src/main/kotlin/commands/rome.kt +++ b/src/main/kotlin/commands/rome.kt @@ -31,6 +31,7 @@ import moe.nea.firmament.util.accessors.messages import moe.nea.firmament.util.collections.InstanceList import moe.nea.firmament.util.collections.WeakCache import moe.nea.firmament.util.mc.SNbtFormatter +import moe.nea.firmament.util.tr import moe.nea.firmament.util.unformattedString @@ -262,15 +263,16 @@ fun firmamentCommand() = literal("firmament") { } thenLiteral("events") { thenExecute { - source.sendFeedback(Text.translatable("firmament.event.start")) + source.sendFeedback(tr("firmament.event.start", "Event Bus Readout:")) FirmamentEventBus.allEventBuses.forEach { eventBus -> - source.sendFeedback(Text.translatable( + val prefixName = eventBus.eventType.typeName.removePrefix("moe.nea.firmament") + source.sendFeedback(tr( "firmament.event.bustype", - eventBus.eventType.typeName.removePrefix("moe.nea.firmament"))) + "- $prefixName:")) eventBus.handlers.forEach { handler -> - source.sendFeedback(Text.translatable( + source.sendFeedback(tr( "firmament.event.handler", - handler.label)) + " * ${handler.label}")) } } } diff --git a/src/main/kotlin/util/textutil.kt b/src/main/kotlin/util/textutil.kt index a6a7e87..3687743 100644 --- a/src/main/kotlin/util/textutil.kt +++ b/src/main/kotlin/util/textutil.kt @@ -164,3 +164,7 @@ fun Text.transformEachRecursively(function: (Text) -> Text): Text { } } } + +fun tr(key: String, default: String): Text = error("Compiler plugin did not run.") +fun trResolved(key: String, vararg args: Any) = Text.translatable(key, *args) + diff --git a/src/main/resources/assets/firmament/lang/en_us.json b/translations/en_us.json index 125b49f..b8eae4a 100644 --- a/src/main/resources/assets/firmament/lang/en_us.json +++ b/translations/en_us.json @@ -21,9 +21,6 @@ "firmament.poweruser.entity.armor.item": " - %s", "firmament.poweruser.entity.passengers": "%s Passengers", "firmament.mixins.start": "Applied firmament mixins:", - "firmament.event.start": "Event Bus Readout:", - "firmament.event.bustype": " - %s:", - "firmament.event.handler": " * %s", "firmament.config.all-configs": "- All Configs -", "firmament.config.anniversary": "Anniversary Features", "firmament.config.anniversary.shiny-pigs": "Shiny Pigs Tracker", |