From 9583c1c3a242d29dcdadc3b5bc5586ff0d755d7f Mon Sep 17 00:00:00 2001 From: Liam Sage Date: Wed, 26 Nov 2025 22:02:37 +0100 Subject: [PATCH] Add dev logging for translation source operations Introduced isDevLoggingEnabled flag in Environment and added conditional internal logging to TransForgeTranslationSource for discovered languages and translation mapping. This helps with debugging and development visibility when DEBUG_LOGS is enabled. --- .../kotlin/cc/modlabs/klassicx/tools/Environment.kt | 2 ++ .../sources/TransForgeTranslationSource.kt | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/cc/modlabs/klassicx/tools/Environment.kt b/src/main/kotlin/cc/modlabs/klassicx/tools/Environment.kt index eb1a716..d36b9d0 100644 --- a/src/main/kotlin/cc/modlabs/klassicx/tools/Environment.kt +++ b/src/main/kotlin/cc/modlabs/klassicx/tools/Environment.kt @@ -71,4 +71,6 @@ object Environment { return getFloatOrNull(key) ?: default } + internal val isDevLoggingEnabled: Boolean + get() = getString("DEBUG_LOGS")?.toBoolean() == true } \ No newline at end of file diff --git a/src/main/kotlin/cc/modlabs/klassicx/translation/sources/TransForgeTranslationSource.kt b/src/main/kotlin/cc/modlabs/klassicx/translation/sources/TransForgeTranslationSource.kt index 5bc66b4..9070cbb 100644 --- a/src/main/kotlin/cc/modlabs/klassicx/translation/sources/TransForgeTranslationSource.kt +++ b/src/main/kotlin/cc/modlabs/klassicx/translation/sources/TransForgeTranslationSource.kt @@ -1,5 +1,7 @@ package cc.modlabs.klassicx.translation.sources +import cc.modlabs.klassicx.extensions.getInternalKlassicxLogger +import cc.modlabs.klassicx.tools.Environment.isDevLoggingEnabled import cc.modlabs.klassicx.translation.Translation import cc.modlabs.klassicx.translation.interfaces.TranslationSource import cc.modlabs.klassicx.translation.live.HelloEvent @@ -83,6 +85,10 @@ class TransForgeTranslationSource( val type = object : TypeToken>() {}.type val locales: List = gson.fromJson(response.body(), type) + if (isDevLoggingEnabled) { + getInternalKlassicxLogger().info("Discovered languages for translationId $translationId: ${locales.joinToString { "${it.locale}(enabled: ${it.enabled} - id: ${it.id} - ${it.createdAt})" }}") + } + locales .filter { it.enabled } .map { it.locale } @@ -115,7 +121,10 @@ class TransForgeTranslationSource( val data: Map = gson.fromJson(response.body(), type) ?: emptyMap() data.map { (key, value) -> - Translation( + if(isDevLoggingEnabled) { + getInternalKlassicxLogger().info("Translating $key to $value in $language") + } + Translation ( languageCode = language, messageKey = key, message = value