discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnustep] Localization


From: Nicola Pero
Subject: Re: [Discuss-gnustep] Localization
Date: Thu, 21 Sep 2000 22:02:17 +0200 (CEST)

> 
> > How about this -
> > 
> > #define _(X)    \
> > [[NSBundle mainBundle] localizedStringForKey: @#X value: nil table: nil]
> > 
> 
> Nice.  What about 
> 
> #define @_(X)     \
> [[NSBundle mainBundle] localizedStringForKey: @#X  value: nil  table: nil]

Ahm - now I rememeber more clearly the trick - it's more difficult than
this.  We need to think also about static strings and similar.  We then
need something like

static NSString *string = @__(Message);

where @__(Message) expands simply to @"Message" in this case.
(Expanding it to [[NSBundle mainBundle] etc would not compile.)

The @__ (or some other similar symbol) is needed because it would be used
by the tool creating the list of strings to be localized in the
Localizable.strings file.

Then, when you access the string, you use @_() on the symbol, and that
will really expanded the string and give the translation.

Also, this allows more advanced people to use the OPENSTEP syntax and
features, like doing the translation manually or looking in other tables 
or using comments etc and still allow the tool to find out which 
strings need to be put in the Localizable.strings file.  
For example, 

NSString *myString = NSLocalizedString (@__("Hi"), @"Common greeting");

(or any more complicated function or method call).
@__("Hi") would expand to @"Hi" but mark @"Hi" as a string needing 
translation (while @"Common greeting" is not marked as such). 

Of course the tool would mark all @_() strings as needing translation 
automatically.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]