Skip to content

Commit

Permalink
Merge pull request #3 from eevieapp/feature/fix-android-getLanguageTag
Browse files Browse the repository at this point in the history
fix: use forLanguageTag to create new Locale
  • Loading branch information
jakex7 authored Aug 1, 2023
2 parents 8471852 + 583d0e6 commit 2e43d92
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ class LocalizationSettingsModule internal constructor(context: ReactApplicationC
* if country is not available in locale, then use system defaults (even if it's not 100% correct, like "pl-US")
**/
private fun getLanguageTag(language: String): String {
// if language have format language_COUNTRY, then return it
if (Locale(language).country != "") return Locale(language).toLanguageTag()
val locale = Locale.forLanguageTag(language);

// if language has format language-COUNTRY, then return it
if (locale.country != "") return locale.toLanguageTag()
// fallback for system country
return "$language-${Locale.getDefault().country}"
return Locale(locale.language, Locale.getDefault().country).toLanguageTag()
}


Expand Down

0 comments on commit 2e43d92

Please sign in to comment.