rework language loading, allow language inheritance

This commit is contained in:
Bixilon 2022-10-10 16:50:36 +02:00
parent 326e8d994d
commit 08fe1267ac
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
30 changed files with 252 additions and 147 deletions

View File

@ -29,8 +29,8 @@ import de.bixilon.minosoft.assets.properties.version.AssetsVersionProperties
import de.bixilon.minosoft.config.profile.GlobalProfileManager
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatch
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
import de.bixilon.minosoft.data.language.LanguageManager.Companion.load
import de.bixilon.minosoft.data.language.MultiLanguageManager
import de.bixilon.minosoft.data.language.LanguageUtil
import de.bixilon.minosoft.data.language.manager.MultiLanguageManager
import de.bixilon.minosoft.data.registries.DefaultRegistries
import de.bixilon.minosoft.data.registries.versions.Versions
import de.bixilon.minosoft.gui.eros.Eros
@ -132,7 +132,7 @@ object Minosoft {
val language = ErosProfileManager.selected.general.language
ErosProfileManager.selected.general::language.profileWatch(this, true) {
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Loading language files (${language})" }
LANGUAGE_MANAGER.translators[ProtocolDefinition.MINOSOFT_NAMESPACE] = load(it, null, MINOSOFT_ASSETS_MANAGER, minosoft("language/"))
LANGUAGE_MANAGER.translators[ProtocolDefinition.MINOSOFT_NAMESPACE] = LanguageUtil.load(it, null, MINOSOFT_ASSETS_MANAGER, minosoft("language/"))
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Language files loaded!" }
}
}

View File

@ -51,6 +51,24 @@ interface AssetsManager {
*/
fun getOrNull(path: ResourceLocation): InputStream?
fun getAllOrNull(path: ResourceLocation): List<InputStream>? {
val list = mutableListOf<InputStream>()
getAll(path, list)
if (list.isEmpty()) {
return null
}
return list
}
@Throws(FileNotFoundException::class)
fun getAll(path: ResourceLocation): List<InputStream> {
return getAllOrNull(path) ?: throw FileNotFoundException("Can not find any assets matching $path!")
}
fun getAll(path: ResourceLocation, list: MutableList<InputStream>) {
list += getOrNull(path) ?: return
}
/**
* Loads all assets
*/

View File

@ -75,6 +75,13 @@ class PriorityAssetsManager(
return null
}
override fun getAll(path: ResourceLocation, list: MutableList<InputStream>) {
val managers = this.managers[path.namespace] ?: return
for (manager in managers) {
manager.getAll(path, list)
}
}
override fun load(latch: CountUpAndDownLatch) {
for ((_, managers) in managers) {
for (manager in managers) {

View File

@ -20,7 +20,7 @@ import de.bixilon.minosoft.config.profile.profiles.account.AccountProfile
import de.bixilon.minosoft.config.profile.profiles.account.AccountProfileManager
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager.delegate
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager.mapDelegate
import de.bixilon.minosoft.data.language.LanguageManager
import de.bixilon.minosoft.data.language.LanguageUtil
import de.bixilon.minosoft.data.registries.ResourceLocation
import java.util.*
@ -28,7 +28,7 @@ class GeneralC {
/**
* Language to use for eros. This is also the fallback language for other profiles
*/
var language: String by delegate(Locale.getDefault()?.fullName ?: LanguageManager.FALLBACK_LANGUAGE)
var language: String by delegate(Locale.getDefault()?.fullName ?: LanguageUtil.FALLBACK_LANGUAGE)
@get:JsonProperty("account_profile") private var _accountProfile: String? by delegate(null)

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.data.accounts
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.util.KUtil.toResourceLocation

View File

@ -1,92 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.language
import de.bixilon.kutil.collections.CollectionUtil.synchronizedListOf
import de.bixilon.kutil.exception.ExceptionUtil.tryCatch
import de.bixilon.minosoft.assets.AssetsManager
import de.bixilon.minosoft.assets.util.FileUtil.readAsString
import de.bixilon.minosoft.assets.util.FileUtil.readJsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.versions.Version
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.data.text.TextComponent
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
import java.io.FileNotFoundException
class LanguageManager(
private val languages: MutableList<Language> = synchronizedListOf(),
) : Translator {
override fun canTranslate(key: ResourceLocation?): Boolean {
for (language in languages) {
if (language.canTranslate(key)) {
return true
}
}
return false
}
override fun translate(key: ResourceLocation?, parent: TextComponent?, vararg data: Any?): ChatComponent {
for (language in languages) {
if (!language.canTranslate(key)) {
continue
}
return language.translate(key, parent, *data)
}
if (data.isEmpty()) {
return ChatComponent.of(key.toString(), null, parent)
}
return ChatComponent.of(key.toString() + "->" + data.contentToString(), null, parent)
}
companion object {
const val FALLBACK_LANGUAGE = "en_US"
fun load(language: String, version: Version?, assetsManager: AssetsManager, path: ResourceLocation = ResourceLocation("lang/")): LanguageManager {
fun loadMinecraftLanguage(language: String): Language {
val data: MutableMap<ResourceLocation, String> = mutableMapOf()
if (version != null && version.versionId >= ProtocolVersions.V_18W02A) {
for ((key, value) in assetsManager[ResourceLocation(path.namespace, path.path + "${language.lowercase()}.json")].readJsonObject()) {
data[ResourceLocation(key)] = value.toString()
}
} else {
val lines = assetsManager[ResourceLocation(path.namespace, path.path + "${language.lowercase()}.lang")].readAsString().lineSequence()
for (line in lines) {
if (line.isBlank() || line.startsWith("#")) {
continue
}
val split = line.split('=', limit = 2)
data[ResourceLocation(split[0])] = split[1].replace("\\n", "\n")
}
}
return Language(language, data)
}
val languages: MutableList<Language> = mutableListOf()
if (language != FALLBACK_LANGUAGE) {
tryCatch(FileNotFoundException::class.java, executor = { languages += loadMinecraftLanguage(language) })
}
languages += loadMinecraftLanguage(FALLBACK_LANGUAGE)
return LanguageManager(languages)
}
}
}

View File

@ -13,11 +13,28 @@
package de.bixilon.minosoft.data.language
import de.bixilon.kutil.exception.ExceptionUtil
import de.bixilon.kutil.json.JsonObject
import de.bixilon.minosoft.assets.AssetsManager
import de.bixilon.minosoft.assets.util.FileUtil.readAsString
import de.bixilon.minosoft.assets.util.FileUtil.readJsonObject
import de.bixilon.minosoft.data.language.lang.Language
import de.bixilon.minosoft.data.language.lang.LanguageData
import de.bixilon.minosoft.data.language.lang.LanguageList
import de.bixilon.minosoft.data.language.manager.LanguageManager
import de.bixilon.minosoft.data.language.translate.Translated
import de.bixilon.minosoft.data.language.translate.Translator
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.versions.Version
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.data.text.TextComponent
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import de.bixilon.minosoft.util.KUtil.minosoft
import de.bixilon.minosoft.util.KUtil.toResourceLocation
import java.io.FileNotFoundException
object LanguageUtil {
const val FALLBACK_LANGUAGE = "en_us"
fun String?.i18n(): Translated {
@ -27,4 +44,76 @@ object LanguageUtil {
}
return Translated(resourceLocation)
}
fun loadJsonLanguage(json: JsonObject): LanguageData {
val data: LanguageData = mutableMapOf()
for ((key, value) in json) {
val path = ResourceLocation(key).path
data[path] = value.toString().correctValue()
}
return data
}
fun loadLanguage(lines: Sequence<String>): LanguageData {
val data: LanguageData = mutableMapOf()
for (line in lines) {
if (line.isBlank() || line.startsWith("#")) {
continue
}
val (key, value) = line.split('=', limit = 2)
val path = ResourceLocation(key).path
data[path] = value.correctValue()
}
return data
}
private fun String.correctValue(): String {
return this.replace("\\n", "\n")
}
fun getFallbackTranslation(key: ResourceLocation?, parent: TextComponent?, vararg data: Any?): ChatComponent {
if (data.isEmpty()) {
return ChatComponent.of(key.toString(), null, parent)
}
return ChatComponent.of(key.toString() + "->" + data.contentToString(), null, parent)
}
fun loadLanguage(language: String, assetsManager: AssetsManager, json: Boolean, path: ResourceLocation): Translator {
val assets = assetsManager.getAll(ResourceLocation(path.namespace, path.path + language + if (json) ".json" else ".lang"))
val languages: MutableList<Language> = mutableListOf()
for (asset in assets) {
val data = if (json) loadJsonLanguage(asset.readJsonObject()) else loadLanguage(asset.readAsString().lineSequence())
languages += Language(language, data)
}
if (languages.size == 1) {
return languages.first()
}
return LanguageList(languages)
}
fun load(language: String, version: Version?, assetsManager: AssetsManager, path: ResourceLocation = ResourceLocation("lang/")): Translator {
val name = language.lowercase()
val json = version != null && version.jsonLanguage
val languages: MutableList<Translator> = mutableListOf()
if (name != FALLBACK_LANGUAGE) {
ExceptionUtil.tryCatch(FileNotFoundException::class.java, executor = { languages += loadLanguage(name, assetsManager, json, path) })
}
languages += loadLanguage(FALLBACK_LANGUAGE, assetsManager, json, path)
if (languages.size == 1) {
return languages.first()
}
return LanguageManager(languages)
}
}

View File

@ -10,8 +10,10 @@
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.language
package de.bixilon.minosoft.data.language.lang
import de.bixilon.minosoft.data.language.LanguageUtil
import de.bixilon.minosoft.data.language.translate.Translator
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.text.BaseComponent
import de.bixilon.minosoft.data.text.ChatComponent
@ -19,21 +21,15 @@ import de.bixilon.minosoft.data.text.TextComponent
class Language(
val name: String,
private val data: Map<ResourceLocation, String>,
private val data: LanguageData,
) : Translator {
override fun canTranslate(key: ResourceLocation?): Boolean {
return data.containsKey(key)
return data.containsKey(key?.namespace)
}
override fun translate(key: ResourceLocation?, parent: TextComponent?, vararg data: Any?): ChatComponent {
val placeholder = this.data[key]
if (placeholder == null) {
if (data.isEmpty()) {
return ChatComponent.of(key.toString(), null, parent)
}
return ChatComponent.of(key.toString() + "->" + data.contentToString(), null, parent)
}
val placeholder = this.data[key?.path] ?: return LanguageUtil.getFallbackTranslation(key, parent, data)
val ret = BaseComponent()

View File

@ -11,9 +11,6 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.language
package de.bixilon.minosoft.data.language.lang
annotation class Description(
val nameKey: String,
val translationKey: String,
)
typealias LanguageData = MutableMap<String, String>

View File

@ -0,0 +1,43 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.language.lang
import de.bixilon.minosoft.data.language.LanguageUtil
import de.bixilon.minosoft.data.language.translate.Translator
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.data.text.TextComponent
class LanguageList(
private val list: MutableList<Language>,
) : Translator {
override fun canTranslate(key: ResourceLocation?): Boolean {
for (language in list) {
if (language.canTranslate(key)) {
return true
}
}
return false
}
override fun translate(key: ResourceLocation?, parent: TextComponent?, vararg data: Any?): ChatComponent {
for (language in list) {
if (language.canTranslate(key)) {
return language.translate(key, parent, data)
}
}
return LanguageUtil.getFallbackTranslation(key, parent, data)
}
}

View File

@ -0,0 +1,45 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.language.manager
import de.bixilon.kutil.collections.CollectionUtil.synchronizedListOf
import de.bixilon.minosoft.data.language.LanguageUtil
import de.bixilon.minosoft.data.language.translate.Translator
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.data.text.TextComponent
class LanguageManager(
private val languages: MutableList<Translator> = synchronizedListOf(),
) : Translator {
override fun canTranslate(key: ResourceLocation?): Boolean {
for (language in languages) {
if (language.canTranslate(key)) {
return true
}
}
return false
}
override fun translate(key: ResourceLocation?, parent: TextComponent?, vararg data: Any?): ChatComponent {
for (language in languages) {
if (!language.canTranslate(key)) {
continue
}
return language.translate(key, parent, *data)
}
return LanguageUtil.getFallbackTranslation(key, parent, data)
}
}

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -11,12 +11,12 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.language
package de.bixilon.minosoft.data.language.manager
import de.bixilon.minosoft.data.language.translate.Translator
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.data.text.TextComponent
import java.util.*
class MultiLanguageManager(
val translators: MutableMap<String, Translator> = mutableMapOf(),
@ -32,8 +32,4 @@ class MultiLanguageManager(
return translators[key.namespace]?.translate(key, parent, *data) ?: ChatComponent.of("$key: ${data.contentToString()}")
}
fun loadLanguage(language: Locale) {
}
}

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.language
package de.bixilon.minosoft.data.language.translate
import de.bixilon.minosoft.data.registries.ResourceLocation

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2022 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.language
package de.bixilon.minosoft.data.language.translate
import de.bixilon.minosoft.data.registries.ResourceLocation

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.language
package de.bixilon.minosoft.data.language.translate
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.text.ChatComponent

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.data.registries
import de.bixilon.kutil.string.StringUtil.isLowercase
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import java.util.*

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.registries.effects
import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.kutil.json.JsonUtil.asJsonObject
import de.bixilon.kutil.json.JsonUtil.toJsonObject
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.effects.attributes.EntityAttributeModifier
import de.bixilon.minosoft.data.registries.registries.Registries

View File

@ -23,7 +23,7 @@ import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.entities.data.EntityDataField
import de.bixilon.minosoft.data.entities.entities.Entity
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.items.SpawnEggItem
import de.bixilon.minosoft.data.registries.registries.Registries

View File

@ -17,7 +17,7 @@ import de.bixilon.kutil.primitive.IntUtil.toInt
import de.bixilon.minosoft.data.Rarities
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.entities.entities.player.Hands
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.blocks.BlockState
import de.bixilon.minosoft.data.registries.factory.clazz.MultiClassFactory

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.data.registries.statistics
import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem

View File

@ -57,6 +57,10 @@ class Version(
return name
}
operator fun compareTo(versionId: Int): Int {
return this.versionId.compareTo(versionId)
}
val flattened: Boolean get() = versionId >= ProtocolDefinition.FLATTING_VERSION_ID
val hasOffhand: Boolean get() = versionId >= V_15W31A
val maxPacketLength get() = if (versionId < ProtocolVersions.V_1_17_1_RC2) 1 shl 21 else 1 shl 23
@ -64,4 +68,5 @@ class Version(
val hasAttackCooldown get() = versionId >= ProtocolVersions.V_15W34A
val requiresSignedChat get() = versionId >= ProtocolVersions.V_22W17A
val supportsRGBChat get() = versionId >= ProtocolVersions.V_20W17A
val jsonLanguage get() = versionId >= ProtocolVersions.V_18W02A
}

View File

@ -18,7 +18,7 @@ import de.bixilon.kutil.json.JsonUtil.toJsonList
import de.bixilon.kutil.json.JsonUtil.toJsonObject
import de.bixilon.kutil.primitive.BooleanUtil.toBoolean
import de.bixilon.kutil.url.URLUtil.toURL
import de.bixilon.minosoft.data.language.Translator
import de.bixilon.minosoft.data.language.translate.Translator
import de.bixilon.minosoft.data.text.events.click.ClickEvent
import de.bixilon.minosoft.data.text.events.click.ClickEvents
import de.bixilon.minosoft.data.text.events.click.OpenURLClickEvent

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger and contributors
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -15,8 +15,8 @@ package de.bixilon.minosoft.data.text
import com.fasterxml.jackson.core.JacksonException
import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.Translator
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.language.translate.Translator
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.text

View File

@ -18,7 +18,7 @@ import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.config.profile.GlobalProfileManager
import de.bixilon.minosoft.config.profile.ProfileManager
import de.bixilon.minosoft.config.profile.profiles.Profile
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.gui.eros.controller.DialogController
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.gui.eros.main.account
import de.bixilon.minosoft.data.accounts.Account
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.ResourceLocationAble
import org.kordamp.ikonli.Ikon

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -14,7 +14,7 @@
package de.bixilon.minosoft.gui.eros.main.play.server.type.types
import de.bixilon.minosoft.config.profile.profiles.eros.server.entries.Server
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.gui.eros.main.play.server.card.ServerCard
import org.kordamp.ikonli.Ikon

View File

@ -30,7 +30,8 @@ import de.bixilon.minosoft.data.chat.ChatTextPositions
import de.bixilon.minosoft.data.entities.entities.player.local.LocalPlayerEntity
import de.bixilon.minosoft.data.entities.entities.player.local.PlayerPrivateKey
import de.bixilon.minosoft.data.entities.entities.player.tab.TabList
import de.bixilon.minosoft.data.language.LanguageManager
import de.bixilon.minosoft.data.language.LanguageUtil
import de.bixilon.minosoft.data.language.translate.Translator
import de.bixilon.minosoft.data.physics.CollisionDetector
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.ResourceLocationAble
@ -84,7 +85,7 @@ class PlayConnection(
lateinit var assetsManager: AssetsManager
private set
val tags: MutableMap<ResourceLocation, Map<ResourceLocation, Tag<Any>>> = synchronizedMapOf()
lateinit var language: LanguageManager
lateinit var language: Translator
@Deprecated("will be removed once split into modules")
@ -202,7 +203,7 @@ class PlayConnection(
state = PlayConnectionStates.LOADING
language = LanguageManager.load(profiles.connection.language ?: profiles.eros.general.language, version, assetsManager)
language = LanguageUtil.load(profiles.connection.language ?: profiles.eros.general.language, version, assetsManager)
player = LocalPlayerEntity(account, this, privateKey)

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.protocol.network.connection.play
import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.util.KUtil.toResourceLocation

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.protocol.network.connection.play.clientsettings
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatch
import de.bixilon.minosoft.data.language.LanguageManager
import de.bixilon.minosoft.data.language.LanguageUtil
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
import de.bixilon.minosoft.protocol.packets.c2s.play.SettingsC2SP
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
@ -64,7 +64,7 @@ class ClientSettingsManager(
return
}
this.language = language
connection.language = LanguageManager.load(language, connection.version, connection.assetsManager)
connection.language = LanguageUtil.load(language, connection.version, connection.assetsManager)
sendClientSettings()
}

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -13,7 +13,7 @@
package de.bixilon.minosoft.protocol.network.connection.status
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.language.translate.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.util.KUtil.toResourceLocation