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

commonMain.com.bselzer.gw2.v2.intl.translation.WvwAbilityTranslator.kt Maven / Gradle / Ivy

Go to download

Internalization support by mapping translations from Guild Wars 2 API models.

There is a newer version: 3.13.0
Show newest version
package com.bselzer.gw2.v2.intl.translation

import com.bselzer.gw2.v2.intl.model.Translation
import com.bselzer.gw2.v2.model.wvw.ability.WvwAbility
import com.bselzer.ktx.function.collection.addTo

class WvwAbilityTranslator : Translator {
    override fun texts(model: WvwAbility): List = buildList {
        add(model.name)
        add(model.description)
        model.ranks.forEach { rank -> add(rank.effect) }
    }

    override fun translations(default: WvwAbility, translated: WvwAbility, language: String) = buildList {
        Translation(
            default = default.name,
            translated = translated.name,
            language = language
        ).addTo(this)

        Translation(
            default = default.description,
            translated = translated.description,
            language = language
        ).addTo(this)

        default.ranks.zip(translated.ranks) { defaultRank, translatedRank ->
            Translation(
                default = defaultRank.effect,
                translated = translatedRank.effect,
                language = language
            ).addTo(this)
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy