phrase / ios-sdk

Phrase Over the Air iOS SDK
https://phrase.com
Other
14 stars 3 forks source link

Uses default language even though the list of preferred languages contains a valid language (that is not the default language) #27

Closed mariaschmiterlow closed 2 years ago

mariaschmiterlow commented 3 years ago

Hello Phrase!

Summary: If the first item in the list of preferred languages is not supported by the app (or Phrase) it seems like Phrase OTA defaults to the default language even though the list contains languages that are supported (but is not the default language).

Example: This example is taken from our app and please let me know if I have misunderstood something about the setup.

This is our configuration for our iOS project, i.e we support two languages "en-US" and "sv" where "en-US" is the default one.

Skärmavbild 2021-01-20 kl  12 56 37

And the same goes for our Xcode project

Skärmavbild 2021-01-20 kl  12 58 24

We have also configured the OTA configuration to fallback to language without region if necessary.

Skärmavbild 2021-01-20 kl  12 59 13

This works perfectly fine if you have any of our two supported languages as the first supported language (here is an example where Swedish "sv-SE" is the preferred language and Norwegian is the secondary language). All strings coming from Phrase OTA is in Swedish. IMG_0045

But if you change the order in the example above (having Norwegian as first preferred language and Swedish as secondary) all strings coming from Phrase OTA are in English (default language). IMG_0041

This is not aligned with the Apple's documentation on how this is handled in iOS (see this entry: https://developer.apple.com/library/archive/qa/qa1828/_index.html#//apple_ref/doc/uid/DTS40014938) and it doesn't follow how the native UI components works.

This is an example from our app (when the user as Norwegian as first language and Swedish as second) where we use the native ASAuthorizationAppleIDButton for Apple sign in but custom UIButtons with localised string from Phrase OTA for the other two buttons. The Apple button is handling the secondary language (Swedish that is) correctly but the translations from Phrase OTA gives us the default language English.

IMG_0047

To me it looks like that Phrase OTA only looks for the first preferred language and don't take the other languages into account at all. Or have we missed anything in the configuration of our projects?

Thanks for your help!

winkelsdorf commented 3 years ago

Hello @mariaschmiterlow,

Thank you for the detailed report. Yes, that is correct - we use the first preferredLanguage. So, you are not missing anything out in your project's configuration. I have forwarded this to the team as a suggestion for improvement. There may also be similarities to ticket #17.

Unfortunately, I cannot make a statement about whether and how this feature can be implemented.

mariaschmiterlow commented 3 years ago

Thanks @winkelsdorf for your answer and confirming that nothing is wrong with our project setup!

I read through #17 and even though the issues are (probably) not the same they might contain similar touchpoint if/when fixed (but since I don't know your codebase that is ofc hard for me to answer).

Thanks anyway for forwarding it and answering my question! I'll keep an eye on the issue for the future.

winkelsdorf commented 3 years ago

You're welcome @mariaschmiterlow and sorry for the delay in responding to your query!

winkelsdorf commented 2 years ago

I welcome you to test this with our latest RC, where we adjusted the language detection logic: https://github.com/phrase/ios-sdk/releases/tag/4.0.1-rc.1

winkelsdorf commented 2 years ago

I am pleased to announce that v4.0.1 has just been released, which includes an 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.

mariaschmiterlow commented 2 years ago

Thanks @winkelsdorf for updating the issue and a RC to test out. We will look into it and hopefully it will solve the issue we saw previously 👍 Thanks again for getting back!

winkelsdorf commented 2 years ago

With pleasure @mariaschmiterlow! Among many other improvements, the new logic should cover exactly this use case, I look forward to your feedback.

mariaschmiterlow commented 1 year ago

Hi again @winkelsdorf We have now updated Phrase in our codebase and ensured that the issue ☝️ is actually fixed with the new release! Thanks a lot 🙏 And many thanks for keeping us in the loop!

And sorry for the late feedback! I had hopes to get this in much earlier but it wasn't possible 🙂