Add mc auto translations
[no changelog]
This commit is contained in:
@@ -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"]
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -25,6 +25,9 @@ pluginManagement {
|
||||
name = "jitpack"
|
||||
url = uri("https://jitpack.io")
|
||||
}
|
||||
maven {
|
||||
url = uri("https://repo.nea.moe/releases")
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
@@ -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}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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",
|
||||
Reference in New Issue
Block a user