Member-only story
Dynamic localization in SwiftUI on the fly
In this article we explore SwiftUI friendly solution for setting the default language during an application’s first-time launch and for changing the localization on the fly, without the need to restart the app or the navigation stack.
As more iOS developers shift towards adopting SwiftUI, they occasionally encounter setbacks due to the framework limitations in implementing complex solutions, particularly in production applications. And this is one of the issues that may arise at different points in the lifecycle of developing a complex application.
The problem
Typically, a multi-language iOS application automatically force adopts the language settings of the user’s iPhone, configurable via the iPhone’s Language & Region settings. That would be okay, but what if our application supports multiple languages and we still want some specific language to be displayed on the first launch (regardless the region settings)? And Xcode not providing native options for that? 🙁 Later on, the user decides to change the language — what we do? Transfer the user to settings and restart the application? Or provide an in-app dropdown with languages and reinstate / reset the…