Closed DKalachniuk closed 2 years ago
Hello @DKalachniuk,
sorry for the late response. Thanks for the report! We are currently trying to reproduce this and keep you updated.
Best regards
@winkelsdorf i find a solution:
if i setup phrase like this Phrase.shared.setup(distributionID: "", environmentSecret: "", localeOverride: Locale.current.languageCode) with localeOverride parameter then it works as expected
Glad you found a working solution for you! We are planning some changes to make those overrides easier. As soon as I know more I'll post an update here.
I got some users reporting something similar. In this particular case he has these settings
but they get the app in English, which is our default language, but we support Spanish and French too, so both should be picked before EN
I'll try @DKalachniuk suggestion and update the ticket if fixed
UPDATE: Instead of the code provided before, I did this:
let supportedLanguages = Bundle.main.localizations
let preferredLanguage = Locale.preferredLanguages.first { pref in supportedLanguages.contains { pref.starts(with: $0) }}
Phrase.shared.setup(distributionID: Constants.phraseAppOtaDistributionId,
environmentSecret: Constants.phraseAppOtaSecret)
environmentSecret: Constants.phraseAppOtaSecret,
localeOverride: preferredLanguage
)
This way it will respect the preferred language from the user, even using a custom region like es-MX
but only of those that are actually part of the bundle, so if some language is not supported it will take the next until one is found or then nil to have the default one.
@DKalachniuk: We were able to reproduce this problem and will address it in the next release.
@angelolloqui: Thank you for the given code. Could you try using just
let preferredLanguage = Bundle.main.preferredLocalizations.first
instead of your iterating code? It should give you the same result, a language code which fits the system/app preferences and the languages the bundle supports (in the right order).
@winkelsdorf it is not the same thing. I believe your suggested method will not contain the "regional languages". For example, if your main language is ES-MX, your method will return ES only, so the mexican customizations are discarded (I havent checked, but when I researched on this solution this was the only combination that worked in my case, combining regions and supported languages
@angelolloqui Thank you for your valuable feedback!
I now verified it to be working correctly, e.g. when the System is set to German
, the System Region is set to Austria
and the App Bundle contains de-AT
. Bundle.main.preferredLocalizations
then correctly returns de-AT
with de
as fallback in the returned array. If the bundle only supports de
, then only de
is returned, ignoring the region.
We are going to release a Beta of the upcoming 4.0 version of the SDK which implements that logic and fixes other side issues. But of course you will still be able to set an override like you did.
I welcome everybody to test our latest RC which implements some changes related to our language detection logic. See: https://github.com/phrase/ios-sdk/releases/tag/4.0.1-rc.1.
I am pleased to announce that v4.0.1 has just been released, which includes the improved language detection and fallback logic. I'm closing this ticket for now, if there are any questions about it, let us know - just reopen or create a new ticket.
Hello Phrase,
Could you please help us to investigate an issue. So in ou project we have 4 languages: de(default), en, it and fr The language of iphone is russian. I also chose English as prefered language of the app![IMG_DB9E5C9BE053-1](https://user-images.githubusercontent.com/2156751/134932001-2e3f86ba-e8e5-460e-a397-24c0fcc4a183.jpeg)
however when I open the app everything is in german... is it intended?
PhraseSDKMainBundleProxyDisabled is false and I also call Phrase.shared.updateTranslations method
Thank you