Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: get available locales in my project

I created several .strings files for my app's localization. Each one is corresponding to a locale. Now I want to get a list of all available locale in my app. Is there any function to help me do that??

E.g. if my app just supports English, Chinese, French the function can return [en, zh, fr]

like image 814
user1217180 Avatar asked Feb 11 '23 13:02

user1217180


1 Answers

swift:

var availableLanguages = NSBundle.mainBundle().localizations as [String]

objc:

NSArray *availableLanguages = [[NSBundle mainBundle] localizations];
like image 200
trickster77777 Avatar answered Feb 16 '23 02:02

trickster77777