commonMain.com.michaeltroger.latintocyrillic.alphabets.CustomAlphabet.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of latin-to-cyrillic Show documentation
Show all versions of latin-to-cyrillic Show documentation
A Kotlin Multiplatform Library for Latin to Cyrillic transliteration
The newest version!
package com.michaeltroger.latintocyrillic.alphabets
internal class CustomAlphabet(latin: List, cyrillic: List) : LatinCyrillicAlphabet() {
init {
require(latin.size == cyrillic.size) {
"Latin and Cyrillic alphabets must have same size. But have: Latin:${latin.size}/Cyrillic:${cyrillic.size}"
}
latin.forEach {
require(it.isNotEmpty() && it.length < 3) {
"Only 1 or 2 latin characters allowed to describe a letter in alphabet. But were:${it.length}/Letter:${it}\""
}
}
}
override val latinToCyrillicAlphabet: Map by lazy {
var i = 0
latin.associateWith {
cyrillic[i++].toString()
}
}
}