All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.de.comahe.i18n4k.strings.CompositeLocalizedString.kt Maven / Gradle / Ivy

Go to download

i18n4k is a multiplatform (JVM, JS, native) library and code generator for Kotlin to handle internationalisation (i18n) in your program.

The newest version!
package de.comahe.i18n4k.strings

import de.comahe.i18n4k.Locale

/** A combination of two [LocalizedString] forming a new one */
class CompositeLocalizedString(
    private val string1: LocalizedString,
    private val string2: LocalizedString
) : LocalizedString {
    override fun toString(): String {
        return string1.toString() + string2.toString()
    }

    override fun toString(locale: Locale?): String {
        return string1.toString(locale) + string2.toString(locale)
    }
}

/** Combines the two [LocalizedString] into one */
operator fun LocalizedString.plus(other: LocalizedString): LocalizedString =
    CompositeLocalizedString(this, other)

/** Combines the [LocalizedString] and the [String] into a [LocalizedString] */
operator fun LocalizedString.plus(other: String): LocalizedString =
    CompositeLocalizedString(this, SimpleLocalizedString(other))




© 2015 - 2024 Weber Informatics LLC | Privacy Policy