aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Widget.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Tag.kt5
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Template.kt4
3 files changed, 7 insertions, 4 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
index 41758d9b..e7b94cba 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
@@ -95,7 +95,7 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent() {
private var snOnCache: com.github.snabbdom.On? = null
private var snHooksCache: com.github.snabbdom.Hooks? = null
- private var lastLanguage: String? = null
+ protected var lastLanguage: String? = null
internal fun <T> singleRender(block: () -> T): T {
getRoot()?.renderDisabled = true
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
index ae26c5de..03686fa0 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
@@ -25,6 +25,7 @@ import com.github.snabbdom.VNode
import pl.treksoft.kvision.KVManager
import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.i18n.I18n
import pl.treksoft.kvision.panel.SimplePanel
/**
@@ -130,7 +131,7 @@ open class Tag(
/**
* Handlebars templates for i18n.
*/
- override var templates: Map<String, (Any?) -> String>? by refreshOnUpdate()
+ override var templates: Map<String, (Any?) -> String> by refreshOnUpdate(mapOf())
init {
@Suppress("LeakingThis")
@@ -138,6 +139,8 @@ open class Tag(
}
override fun render(): VNode {
+ if (templateData != null && lastLanguage != null && lastLanguage != I18n.language)
+ templateData = templateData
return if (content != null) {
val translatedContent = content?.let { translate(it) }
if (rich) {
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Template.kt b/src/main/kotlin/pl/treksoft/kvision/html/Template.kt
index 31155209..d430d8ff 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Template.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Template.kt
@@ -30,7 +30,7 @@ interface Template {
var content: String?
var rich: Boolean
var template: ((Any?) -> String)?
- val templates: Map<String, (Any?) -> String>?
+ val templates: Map<String, (Any?) -> String>
/**
* Handlebars template data object.
@@ -41,6 +41,6 @@ interface Template {
}
set(value) {
if (!rich) rich = true
- content = template?.invoke(value) ?: templates?.get(I18n.language)?.invoke(value)
+ content = template?.invoke(value) ?: templates.get(I18n.language)?.invoke(value)
}
}