Fixed country name for the few countries not in k-i18n Region

This commit is contained in:
dankito 2024-12-12 22:35:51 +01:00
parent 428d4040e6
commit 92785af8f5
2 changed files with 8 additions and 3 deletions

View file

@ -250,6 +250,6 @@ enum class Country(val alpha2Code: String, val alpha3Code: String?, val englishN
Yemen("YE", "YEM", "Yemen"),
Zambia("ZM", "ZMB", "Zambia"),
Zimbabwe("ZW", "ZWE", "Zimbabwe"),
_1A("1A", null, "Kosovo"),
XI("XI", null, "United Kingdom (Northern Ireland)"),
Kosovo("1A", null, "Kosovo"),
NorthernIreland("XI", null, "United Kingdom (Northern Ireland)"),
}

View file

@ -197,7 +197,7 @@ class CodeGenerator {
else if (firstColumn == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") return "ExcelSpreadsheet"
else if (firstColumn == "application/vnd.oasis.opendocument.spreadsheet") return "OpenDocumentSpreadsheet"
val column = if (type == CodeListType.IsoCountryCodes) i18nRegionsByCode[firstColumn]?.name ?: firstColumn
val column = if (type == CodeListType.IsoCountryCodes) i18nRegionsByCode[firstColumn]?.name ?: fixCountryName(row[2])
else if (type == CodeListType.IsoCurrencyCodes) i18nCurrenciesByCode[firstColumn]?.name ?: fixCurrencyName(row[2]) // as fallback use currency's English name from Zugferd list
else if (columns.first().name == "Scheme ID") row[1] // ISO 6523 Scheme Identifier codes
else row[0] // default case: the code is in the first column
@ -211,6 +211,11 @@ class CodeGenerator {
else name
}
private fun fixCountryName(countryName: Any?): String = when (countryName) {
"United Kingdom (Northern Ireland)" -> "NorthernIreland"
else -> countryName.toString()
}
private fun fixCurrencyName(currencyName: Any?): String = when (currencyName) {
"Sierra Leone (new valuation 2022)" -> "SierraLeone_NewValuation2022"
"Bolívar Soberano, new valuation" -> "BolivarSoberano_NewValuation"