I have localized my app into 4 different languages.
I did’t use String catalog and followed an old Localizable.strings approach.
I want to specify programmatically what languages should be available for the user.
Let’s say I want this kind of a method in my AppDelegate:
func setPreferredLanguages(_ languages: [String]) {
/// ...
}
So if I call setPreferredLanguages(["en, de"]), user won’t be able to see other than English and German languages in system’s Settings -> My app -> Language(preferred language).
I am searching for a way to "hide" localizations in a runtime.
I need to provide only 2 out of 4 languages to the end user but without actual deleting .lproj files.
2
Answers
I think these 2 langs u wanna show should be the local lang of user and also English as additional lang yeah ? But at the same time u should thinking about if the user local lang is already English then u should not showing any lang as additional for selecting right?
So u may get the device lang and then check if its different then english and show which lang it is and also english at the same time.
For example;
You cannot modify the list of available localisations with code.
iOS obtains the list of languages shown in Settings -> My app -> Language(preferred language) by reading your app bundle. Your app may not be running and may never have been run before the user accesses these settings.
You can remove 2 of your localisations without actually deleting the lproj files by excluding them from the target in Xcode.