• 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
Re: Internationalization: How to bring the locale in line with the language?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Internationalization: How to bring the locale in line with the language?


  • Subject: Re: Internationalization: How to bring the locale in line with the language?
  • From: Uli Zappe <email@hidden>
  • Date: Thu, 4 Nov 2004 02:59:55 +0100

Am 03.11.2004 um 20:52 schrieb Jonathon Mah:

On 4 Nov 2004, at 02:15, Uli Zappe wrote:
No, but there I would have a hard time finding out what the used language will be. I don't want to hardcode the locale (then I could obviously simply not use localized methods in my app), but bring it in line with the language the app actually uses depending on the user's preferences and the available localized NIB files.

You could put each locale in the localized .strings file, and then set the setting to whatever NSLocalizedString() returns. That way, it'd be in English if it were using English strings, etc.


(I'm assuming that the application is set-up enough to use NSLocalizedString() before NSApplicationMain() is called — I haven't tried that yet.)

Yep, I ended up with a similar solution; however, if I use the Localizable.strings files, there is no need for early initialization anymore.


Here's the solution I came up with (only the decimal separator was important to me):

In the Localizable.strings files of my supported languages I added an entry

   "NSDecimalSeparator" = ".";

(or "," dependant on the language).

Then, in my initialization code I set an instance variable:

myLocale=[[NSDictionary
dictionaryWithObject:NSLocalizedString(@"NSDecimalSeparator", @"")
forKey:@"NSDecimalSeparator"] retain];


From then on, I can generate correctly formatted strings dealing with numeric values:

myString=[[[NSString alloc] initWithFormat:@"%.1f" locale:myLocale, floatValue] autorelease];

In the text field formatters of my localized NIB files I use the ",<–>." option instead of the "Localize" option.

This works. I just feel it could be more straightforward.


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


References: 
 >Internationalization: How to bring the locale in line with the language? (From: Uli Zappe <email@hidden>)
 >Re: Internationalization: How to bring the locale in line with the language? (From: Uli Zappe <email@hidden>)
 >Re: Internationalization: How to bring the locale in line with the language? (From: Jonathon Mah <email@hidden>)

  • Prev by Date: using JBuilder to code Cocoa-Java. It is possible ?
  • Next by Date: Creating keyboard equivalents for NSScrollView?
  • Previous by thread: Re: Internationalization: How to bring the locale in line with the language?
  • Next by thread: Re: Internationalization: How to bring the locale in line with the language?
  • Index(es):
    • Date
    • Thread