I have a project setup with several supported languages (en, fr, de, it). The development language is en. The user has the ability to change the language in the app, which then calls OneSkyOTAPlugin.setLanguage(_:) with the new language. This works great if you have called OneSkyOTAPlugin.checkForUpdate() and successfully downloaded all the translations. However, the issue comes when you don't have internet connection.
All of the translations files are added into the Xcode project at each build, so that in the case the user installs the app and launches it without an internet connection, or OneSky is down when the user installs the app, the user still has a somewhat up-to-date set of translations available to them. As long as the user doesn't change the language in the app, everything is fine. If the user changes the language, the fallback logic breaks it seems.
Here's the scenario:
User installs app and launches with the device's language set to English.
The translations fail to download, for whatever reason.
User changes the app's language from English to Italian (device's language is still in English) which triggers setLanguage("it").
OneSky tries to get translations for "it-IT" (fails), then tries to get translation for "it" (fails), then tries to get translations for development language "en" (fails). These all fail because the translations never downloaded.
OneSky then tries to fall back to the main bundle to look for translations, but only seems to only look in the main bundle with the device's language ("en") instead of the language set by setLanguage(_:) ("it").
So it seems, at least from an outside perspective, that setLanguage(_:) is only good for looking up translations in the downloaded copy of the translations. If you haven't downloaded the translations, then it falls back to the main bundle using the device's language instead of setLanguage(_:).
In the scenario above, I would expect the framework to look up strings in this order:
1) Look for "it-IT" in the downloaded translations. If that fails,
2) Look for "it" in the downloaded translations. If that fails,
3) Look for the development in the downloaded translations. If that fails,
4) Look for "it-IT" in the main bundle. If that fails,
5) Look for "it" in the main bundle. If that fails,
6) Look for the development language in the main bundle. If that fails,
I have a project setup with several supported languages (en, fr, de, it). The development language is en. The user has the ability to change the language in the app, which then calls
OneSkyOTAPlugin.setLanguage(_:)
with the new language. This works great if you have calledOneSkyOTAPlugin.checkForUpdate()
and successfully downloaded all the translations. However, the issue comes when you don't have internet connection.All of the translations files are added into the Xcode project at each build, so that in the case the user installs the app and launches it without an internet connection, or OneSky is down when the user installs the app, the user still has a somewhat up-to-date set of translations available to them. As long as the user doesn't change the language in the app, everything is fine. If the user changes the language, the fallback logic breaks it seems.
Here's the scenario:
setLanguage("it")
.setLanguage(_:)
("it").So it seems, at least from an outside perspective, that
setLanguage(_:)
is only good for looking up translations in the downloaded copy of the translations. If you haven't downloaded the translations, then it falls back to the main bundle using the device's language instead ofsetLanguage(_:)
.In the scenario above, I would expect the framework to look up strings in this order: 1) Look for "it-IT" in the downloaded translations. If that fails, 2) Look for "it" in the downloaded translations. If that fails, 3) Look for the development in the downloaded translations. If that fails, 4) Look for "it-IT" in the main bundle. If that fails, 5) Look for "it" in the main bundle. If that fails, 6) Look for the development language in the main bundle. If that fails,