Post

Replies

Boosts

Views

Activity

Reply to Programmatic way to find the language of an application
Hi @eskimo, it seems this solution Bundle.main gets you application bundle. preferredLocalizations is a list of languages your application bundle supports in user-preferred order. The first element will be the language your application is running in. is not working as expected, is returning English everytime because English is the first element, even if application language is French, for example. Here is the source code, could you please take a look at it? Not sure if we are doing something wrong or there is something wrong in the CoreFoundation side. Many thanks for your help! CFArrayRef cfAllLanguages = CFBundleCopyBundleLocalizations(cfBundle) CFArrayRef cfPrefLang = CFBundleCopyPreferredLocalizationsFromArray(cfAllLanguages); --- this should return language of the application but it returns En each time CFArrayRef cfLocalPrefLang = CFBundleCopyLocalizationsForPreferences(cfAllLanguages,cfPrefLang); CFArrayRef cfDefaultLang = CFBundleCopyLocalizationsForPreferences(cfAllLanguages,NULL); CFStringRef lss = (CFStringRef)CFArrayGetValueAtIndex(cfAllLanguages, 0); Thank you!
Topic: Programming Languages SubTopic: General Tags:
Apr ’22