Skip to content

Commit

Permalink
Always generate a *.lang file for the mainLanguage
Browse files Browse the repository at this point in the history
Even if there's no *.mo file for that language.
  • Loading branch information
floscher committed Jan 13, 2018
1 parent a3839cd commit d93bfe0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/kotlin/i18n/io/LangWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ class LangWriter {
// Otherwise collect all the msgids from all the files.
val originalMsgIds = languageMaps.get(originLang)?.keys ?: languageMaps.flatMap { it.value.keys }
langFileDir.mkdirs()
languageMaps.entries.forEach { langEntry ->
languageMaps
// Adds a *.lang file for the original language even if no *.mo or *.po file is available
.plus(if (!languageMaps.containsKey(originLang)) mapOf(originLang to originalMsgIds.associate{ Pair(it, it.id) }) else mapOf())
.entries.forEach { langEntry ->

BufferedOutputStream(FileOutputStream(File(langFileDir, "${langEntry.key}.lang"))).use { stream ->
originalMsgIds.filter { it.id.numPlurals <= 0 }.forEach { msgid ->

Expand Down

0 comments on commit d93bfe0

Please sign in to comment.