I'm using the new string catalog feature of Xcode 15 to translate strings in my SwiftUI project (deployment target iOS 16.4+) that supports 2 languages: English and Arabic (I've added Arabic in the info tab in the main project settings).
What I want to do is to force return the user chosen language's translations for the strings regardless to the the system language, so if the user chooses Arabic in the App Settings screen, the app should return Arabic translations for all SwiftUI views and other strings (like alert messages for ex.).
This was working fine when I was using the old Localizable.strings file and using this modifier in the main ContentView of the app:
.environment(\.locale, Locale(identifier: "ar")) for Arabic or .environment(\.locale, Locale(identifier: "en")) for English.
The string catalog works fine with SwiftUI views, but it fails when I use this initializer: String(localized: "some_string", locale: Locale(identifier: "ar")) by returning only English translations when iOS system language is English and the user choice is Arabic (the locale modifier is set to Arabic in the main view: .environment(\.locale, Locale(identifier: "ar"))), and the same happens vice versa for English language. I'm calling the String(localized:locale:) initializer to translate some strings in the app that are not placed directly in SwiftUI views, like dynamic alert messages.
I know that I can return language specific translations by choosing App Language: the language in the Info tab under the Run menu in Scheme editor, but I want to leave it as is (which's System) to avoid breaking localization in various parts in the app.
Any thoughts on this issue would be appreciated.