[ad_1]
I am utilizing the brand new string catalog characteristic of XCode 15
to translate SwiftUI Strings, the challenge helps 2 languages: English and Arabic (I’ve added Arabic within the data tab in the primary challenge settings).
What I wish to do is to pressure return the proper translations for the strings regardless to the the system language, so if the person chooses Arabic in App Settings display screen, the app ought to return Arabic translations for all SwiftUI
views and different strings (like alert messages for ex.).
This was working tremendous once I was utilizing the previous Localizable.strings
file by simply including this modifier to the primary ContentView
of the app:
.atmosphere(.locale, Locale(identifier: "ar"))
for Araibc or .atmosphere(.locale, Locale(identifier: "en"))
for English.
The string catalog works tremendous with SwiftUI
views, however it fails once I use String(localized: "some_string", locale: Locale(identifier: "ar"))
by returning solely English translations. I am calling this methodology to translate some strings within the app that aren’t positioned straight in SwiftUI
views, like dynamic alert messages.
I do know that I can return these Arabic translations by selecting App Language: Arabic
within the data
tab underneath the Run
menu in Scheme
editor, however I wish to depart it as is (which’s System) to keep away from breaking localization in numerous components within the app.
Any ideas on this difficulty can be appreciated.
[ad_2]