Skip to content

Commit

Permalink
Fix some locale setting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Syer10 committed Jun 20, 2021
1 parent 5a19604 commit d65273d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/kotlin/ca/gosyer/data/translation/ResourceProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ class ResourceProvider @Inject constructor(
val languagePref = uiPreferences.language()
return if (languagePref.isSet()) {
languagePref.get().let {
val locale: Locale? = Locale.forLanguageTag(it)
if (locale != null) {
XmlResourceBundle.forLocale(locale)
if (it.isBlank()) {
getDefault()
} else {
XmlResourceBundle.forTag(it)
val locale: Locale = Locale.forLanguageTag(it)
Locale.setDefault(locale)
XmlResourceBundle.forLocale(locale)
}
}
} else XmlResourceBundle.forLocale(Locale.getDefault())
} else getDefault()
}

private fun getDefault() = XmlResourceBundle.forLocale(Locale.getDefault())
}

0 comments on commit d65273d

Please sign in to comment.