Re: Getting an NSLocalizedString for another localization
Re: Getting an NSLocalizedString for another localization
- Subject: Re: Getting an NSLocalizedString for another localization
- From: Damien Trog <email@hidden>
- Date: Tue, 4 Oct 2005 22:00:47 +0200
Thank you very much! That's exactly what I was looking for.
I have made a category for NSBundle to provide this functionality in
a macro NSLocalizedStringForLocalization, which works just like
NSLocalizedString. I have put it online on http://
damientrog.blogspot.com/2005/10/localized-strings-with-specified.html
for those who might need this as well.
Greetings,
Damien
On 4-okt-05, at 18:40, Douglas Davidson wrote:
On Oct 4, 2005, at 2:52 AM, Damien Trog wrote:
I have an application which, amongst other things, lets the user
print exams. It is localized in multiple languages. Also it is
possible that the user wants an exam printed in another language
than the one which is set in his internationalization settings in
the preferences.
For example, the user can be using the application in Dutch, but
wanting to print an exam in English, or vice versa. (The static
text would be different then.)
Is it possible to use localized strings for this? I would need
something like NSLocalizedString(@"Question",@"Dutch",@"");
So is it possible to specify which localization you want for a
localized string?
You can do this, but you will have to do a little more work.
Get the bundle you are interested in--probably the main bundle, if
it's your application we're talking about. You can call
[someBundle localizations] if you need to get a list of the
localizations available. For the localization of interest, call
[someBundle pathForResource:<table name> ofType:@"strings"
inDirectory:nil forLocalization:localization]
to get the path to the strings file (the table name for the default
table is @"Localizable"). Parse the contents of that file as a
property list. The result should be a dictionary with keys that
are the localized string keys and values that are the localized
strings. Get the value for the key you are interested in; that's
the localization for that key in the given localization.
Douglas Davidson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden