• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to make localizedStringForKey: work in a Foundation Tool?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to make localizedStringForKey: work in a Foundation Tool?


  • Subject: How to make localizedStringForKey: work in a Foundation Tool?
  • From: Uli Zappe <email@hidden>
  • Date: Thu, 11 Aug 2005 09:55:14 +0200

Hi everybody,

I want to write a Foundation Tool that allows me to get the localized versions of expressions used in Cocoa apps.

For instance, I might want to know what word the Finder uses for "Archive" in the user's current language.

The respective key in the Finder's string tables is "AR40", so basically, the code for this task is:

id bundle = [NSBundle bundleWithPath:@"/System/Library/CoreServices/ Finder.app"];
id string = [bundle localizedStringForKey:@"AR40"] value:nil table:nil];


However, in a Foundation Tool, this code *always* displays the English variant ("Archive"), no matter what the user's preferred language. (Of course, the Finder itself has string files in all languages.)

If you use this code in a Cocoa app, the result is the same *unless* you add resources for languages other than English. Then, all these languages are considered, too, so if the user's preferred language is among them, it will be displayed instead of "Archive".

In other words, [bundle localizedStringForKey:<string>] first and foremost does *not* consider the languages available in bundle, but rather those of its own process. God knows if this is a bug or a feature. :-/


So how can I make a Foundation Tool think it has more languages available than English? Any ideas anyone?




            Bye
                    Uli
________________________________________________________

  Uli Zappe, Solmsstraße 5, D-65189 Wiesbaden, Germany
  http://www.ritual.org
  Fon: +49-700-ULIZAPPE
  Fax: +49-700-ZAPPEFAX
________________________________________________________

_______________________________________________
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


  • Follow-Ups:
    • Re: How to make localizedStringForKey: work in a Foundation Tool?
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: [Moderator] Re: Option-click on my app hides the other app
  • Next by Date: Re: Types for the method have to conform?
  • Previous by thread: Re: const Object cannot receive messages in 10.4
  • Next by thread: Re: How to make localizedStringForKey: work in a Foundation Tool?
  • Index(es):
    • Date
    • Thread