Use specific localization in Cocoa application

How can you use the cocoa application to use a specific locale / localization different from what the current locale says?

There are several localizations in my application, and I would like to be able to choose the localization that the application uses in the configuration file. How can I determine cocoa which of the localizations to use?

+1
source share
4 answers

Hmmm, maybe AppleLocale expects "en", not "en_US"?

'en' works for me in the terminal, so ... I don’t understand why this should not be the same line for you when you install it in your application

defaults write com.mycompany.myproduct AppleLocale 'en'

+2
source

Set the AppleLanguages array to the default for the application user who should use the one you prefer to use, and set the corresponding AppleLocale string to the default values. Having said that, why use a localization that is not the one that the user prefers?

+1
source

according to the answer of MAAD. I tested in my application and found that the only keystroke is AppleLanguages

So

 [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"en"] forKey:@"AppleLanguages"]; 

.

Remember to restart the application so that the user defaults accept the effects.

+1
source

I tried installing "AppleLocale" and "AppleLanguages" with something like the following:

 [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"en"] forKey:@"AppleLanguages"]; [[NSUserDefaults standardUserDefaults] setObject:@"en_US" forKey:@"AppleLocale"]; 

He did nothing, although the language and locale are used in the system settings.

0
source

Source: https://habr.com/ru/post/1313871/


All Articles