Re: Changing the Locale for a single App?
Re: Changing the Locale for a single App?
- Subject: Re: Changing the Locale for a single App?
- From: Douglas Davidson <email@hidden>
- Date: Tue, 16 Dec 2003 11:40:52 -0800
On Dec 16, 2003, at 10:13 AM, Huyler, Christopher M wrote:
Is it possible to change the locale of my application without changing
the language preference of the current user? I have been asked to put
a
language selector in our preference panel that will allow the user to
change the language of our entire product (including the preference
panel).
Currently the preference panel is the only thing using standard bundle
localization (NSLocalizedStringFromTable). The rest of the product has
separate dylibs for each language which are copied into the right
locations by a set_language script.
However, with my preference panel, I need a way to load the correct
localized strings from my localizable.strings file depending upon what
the user selects.
Yes. The user's localization preferences are set using the
AppleLanguages default. This is a standard user default, and can be
set globally or on a per-app basis, or as a command-line argument, like
other defaults. The relevant preference pane sets the global
preferences. If you want to run an application using some other
preferences, you can for example launch it from the command line e.g.
/Applications/TextEdit.app/Contents/MacOS/TextEdit -AppleLanguages
"(fr, en)".
However, it sounds like what you want to do is to select a specific
localization from within the running app. For that what you probably
want is NSBundle's localization-specific APIs (the ones with
forLocalization: in the name). These allow you to locate a resource
for a specific localization rather than use NSBundle's default
localization selection. What this will not do for you is parse a
.strings file, but that is not a large amount of additional work; the
standard plist parsing methods will parse .strings files into
dictionaries.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.