-
Notifications
You must be signed in to change notification settings - Fork 498
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
feb6b62
to
78f6985
Compare
private fun getLanguage(): String { | ||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||
LocaleList.getDefault().getFirstMatch(supportedLanguages)?.language ?: Locale.getDefault().language | ||
val cclLanguage: String by lazy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please check if the language changes when the device language changes while using the App?
I suspect that the value is cached , because this val
is for the whole App
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, it won't change. Getting it each time has impact on performance, so let me find a different solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this work?
fun getCclLanguage(): String {
val currentDeviceLang = Locale.getDefault().language
if (currentSupportedLang[currentDeviceLang].isNullOrEmpty()) {
currentSupportedLang[currentDeviceLang] = supportedLang()
}
return currentSupportedLang[currentDeviceLang]!!
}
private val currentSupportedLang = mutableMapOf<String, String>()
private fun supportedLang(): String = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> {
LocaleList.getDefault().getFirstMatch(supportedLanguages)?.language
?: Locale.getDefault().language.also {
Timber.d("Using default language $it")
}
}
else -> Locale.getDefault().language
}.also { Timber.d("Language is $it") }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried several things. The only thing that would work is a broadcast receiver for the locale change, but is it worth it? will be reset on next app start, and since we do not calculate the wallet info again, the new language may not be there right away anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using map as above did not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the setting is Spanish, English, German, the app will be in English
If the setting is Spanish, German, English, the app will be in German
getDefault will return Spanish in both cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until walletInfo is recalculated, the new language is not available anyway, so it may even be worse to update immediately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean to update on locale change in this case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep an eye on that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, update the language and trigger a new calculation on locale change
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us merge it for now , We should test it when languages are there
No description provided.