translation

This commit is contained in:
nea
2022-08-27 15:41:16 +02:00
parent 2019473c50
commit d9353ff54c
7 changed files with 51 additions and 27 deletions

View File

@@ -1,3 +1,5 @@
root = true
[*] [*]
charset = utf-8 charset = utf-8
end_of_line = lf end_of_line = lf
@@ -7,4 +9,7 @@ insert_final_newline = true
max_line_length = 120 max_line_length = 120
[{*.kt,*.kts}] [*.kt]
ij_kotlin_name_count_to_use_star_import = 99999
ij_kotlin_name_count_to_use_star_import_for_members = 99999
ij_kotlin_imports_layout = *, |, kotlinx.**, kotlin.**, net.minecraft.**, moe.nea.notenoughupdates.**, |, $*

View File

@@ -13,7 +13,7 @@ fun neuCommand() = literal("neu") {
thenLiteral("reload") { thenLiteral("reload") {
thenLiteral("fetch") { thenLiteral("fetch") {
thenExecute { thenExecute {
source.sendFeedback(Text.literal("Trying to redownload the repository")) // TODO better reporting source.sendFeedback(Text.translatable("notenoughupdates.repo.reload.network")) // TODO better reporting
RepoManager.launchAsyncUpdate() RepoManager.launchAsyncUpdate()
} }
} }

View File

@@ -1,31 +1,31 @@
package moe.nea.notenoughupdates.gui package moe.nea.notenoughupdates.gui
import moe.nea.notenoughupdates.repo.RepoManager
import net.minecraft.text.Text import net.minecraft.text.Text
import moe.nea.notenoughupdates.repo.RepoManager
fun repoGui(): ConfigGui<RepoManager.Config> { fun repoGui(): ConfigGui<RepoManager.Config> {
return ConfigGui(RepoManager) { return ConfigGui(RepoManager) {
title(Text.literal("NotEnoughUpdates Repo Settings")) title(Text.translatable("notenoughupdates.gui.repo.title"))
toggle(Text.literal("Auto Update"), RepoManager.Config::autoUpdate) toggle(Text.translatable("notenoughupdates.gui.repo.autoupdate"), RepoManager.Config::autoUpdate)
textfield( textfield(
Text.literal("Repo Username"), Text.translatable("notenoughupdates.gui.repo.username"),
Text.literal("<github user>"), Text.translatable("notenoughupdates.gui.repo.hint.username"),
RepoManager.Config::user, RepoManager.Config::user,
maxLength = 255 maxLength = 255
) )
textfield( textfield(
Text.literal("Repo Name"), Text.translatable("notenoughupdates.gui.repo.reponame"),
Text.literal("<repo name>"), Text.translatable("notenoughupdates.gui.repo.hint.reponame"),
RepoManager.Config::repo RepoManager.Config::repo
) )
textfield( textfield(
Text.literal("Repo Branch"), Text.translatable("notenoughupdates.gui.repo.branch"),
Text.literal("<repo branch>"), Text.translatable("notenoughupdates.gui.repo.hint.branch"),
RepoManager.Config::branch RepoManager.Config::branch
) )
button( button(
Text.literal("Reset to Defaults"), Text.translatable("notenoughupdates.gui.repo.reset.label"),
Text.literal("Reset"), Text.translatable("notenoughupdates.gui.repo.reset"),
) { ) {
RepoManager.config.user = "NotEnoughUpdates" RepoManager.config.user = "NotEnoughUpdates"
RepoManager.config.repo = "NotEnoughUpdates-REPO" RepoManager.config.repo = "NotEnoughUpdates-REPO"

View File

@@ -5,11 +5,14 @@ import io.github.cottonmc.cotton.gui.client.CottonHud
import io.github.moulberry.repo.IReloadable import io.github.moulberry.repo.IReloadable
import io.github.moulberry.repo.NEURepository import io.github.moulberry.repo.NEURepository
import io.github.moulberry.repo.data.NEUItem import io.github.moulberry.repo.data.NEUItem
import java.io.PrintWriter
import java.nio.file.Path
import java.util.concurrent.ConcurrentHashMap
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import moe.nea.notenoughupdates.NotEnoughUpdates import kotlin.io.path.absolutePathString
import moe.nea.notenoughupdates.util.LegacyTagParser import kotlin.io.path.writer
import moe.nea.notenoughupdates.util.appendLore import net.minecraft.client.resource.language.I18n
import net.minecraft.datafixer.Schemas import net.minecraft.datafixer.Schemas
import net.minecraft.datafixer.TypeReferences import net.minecraft.datafixer.TypeReferences
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
@@ -18,11 +21,9 @@ import net.minecraft.nbt.NbtCompound
import net.minecraft.nbt.NbtOps import net.minecraft.nbt.NbtOps
import net.minecraft.text.Text import net.minecraft.text.Text
import net.minecraft.util.Identifier import net.minecraft.util.Identifier
import java.io.PrintWriter import moe.nea.notenoughupdates.NotEnoughUpdates
import java.nio.file.Path import moe.nea.notenoughupdates.util.LegacyTagParser
import java.util.concurrent.ConcurrentHashMap import moe.nea.notenoughupdates.util.appendLore
import kotlin.io.path.absolutePathString
import kotlin.io.path.writer
object ItemCache : IReloadable { object ItemCache : IReloadable {
val dfuLog = Path.of("logs/dfulog.txt") val dfuLog = Path.of("logs/dfulog.txt")
@@ -60,7 +61,7 @@ object ItemCache : IReloadable {
val modernItemTag = oldItemTag.transformFrom10809ToModern() val modernItemTag = oldItemTag.transformFrom10809ToModern()
?: return ItemStack(Items.PAINTING).apply { ?: return ItemStack(Items.PAINTING).apply {
setCustomName(Text.literal(this@asItemStackNow.displayName)) setCustomName(Text.literal(this@asItemStackNow.displayName))
appendLore(listOf(Text.literal("Exception rendering item: $skyblockItemId"))) appendLore(listOf(Text.translatable("notenoughupdates.repo.brokenitem", skyblockItemId)))
} }
val itemInstance = ItemStack.fromNbt(modernItemTag) val itemInstance = ItemStack.fromNbt(modernItemTag)
if (itemInstance.nbt?.contains("Enchantments") == true) { if (itemInstance.nbt?.contains("Enchantments") == true) {
@@ -98,12 +99,13 @@ object ItemCache : IReloadable {
CottonHud.remove(RepoManager.progressBar) CottonHud.remove(RepoManager.progressBar)
return@launch return@launch
} }
RepoManager.progressBar.reportProgress("Recache Items", 0, items.size) val recacheItems = I18n.translate("notenoughupdates.repo.cache")
RepoManager.progressBar.reportProgress(recacheItems, 0, items.size)
CottonHud.add(RepoManager.progressBar) CottonHud.add(RepoManager.progressBar)
var i = 0 var i = 0
items.values.forEach { items.values.forEach {
it.asItemStack() // Rebuild cache it.asItemStack() // Rebuild cache
RepoManager.progressBar.reportProgress("Recache Items", i++, items.size) RepoManager.progressBar.reportProgress(recacheItems, i++, items.size)
} }
CottonHud.remove(RepoManager.progressBar) CottonHud.remove(RepoManager.progressBar)
} }

View File

@@ -69,7 +69,7 @@ object RepoDownloadManager {
* Downloads the latest repository from github, setting [latestSavedVersionHash]. * Downloads the latest repository from github, setting [latestSavedVersionHash].
* @return true, if an update was performed, false, otherwise (no update needed, or wasn't able to complete update) * @return true, if an update was performed, false, otherwise (no update needed, or wasn't able to complete update)
*/ */
suspend fun downloadUpdate(): Boolean = withContext(CoroutineName("Repo Update Check")) { suspend fun downloadUpdate(force: Boolean): Boolean = withContext(CoroutineName("Repo Update Check")) {
val latestSha = requestLatestGithubSha() val latestSha = requestLatestGithubSha()
if (latestSha == null) { if (latestSha == null) {
logger.warn("Could not request github API to retrieve latest REPO sha.") logger.warn("Could not request github API to retrieve latest REPO sha.")

View File

@@ -55,11 +55,11 @@ object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Co
}) })
} }
fun launchAsyncUpdate() { fun launchAsyncUpdate(force: Boolean = false) {
NotEnoughUpdates.coroutineScope.launch { NotEnoughUpdates.coroutineScope.launch {
progressBar.reportProgress("Downloading", 0, null) progressBar.reportProgress("Downloading", 0, null)
CottonHud.add(progressBar) CottonHud.add(progressBar)
RepoDownloadManager.downloadUpdate() RepoDownloadManager.downloadUpdate(force)
progressBar.reportProgress("Download complete", 1, 1) progressBar.reportProgress("Download complete", 1, 1)
reload() reload()
} }

View File

@@ -2,7 +2,24 @@
"notenoughupdates": { "notenoughupdates": {
"repo": { "repo": {
"reload": { "reload": {
"network": "Trying to redownload the repository",
"disk": "Reloading repository from disk. This may lag a bit." "disk": "Reloading repository from disk. This may lag a bit."
},
"cache": "Recaching items",
"brokenitem": "Failed to render item: %s"
},
"gui": {
"repo": {
"title": "NotEnoughUpdates Repo Settings",
"autoupdate": "Auto Update",
"username": "Repo Username",
"hint.username": "NotEnoughUpdates",
"reponame": "Repo Name",
"hint.reponame": "NotEnoughUpdates-REPO",
"branch": "Repo Branch",
"hint.branch": "dangerous",
"reset": "Reset",
"reset.label": "Reset to Defaults"
} }
} }
} }