discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Localization with NSString


From: Richard Frith-Macdonald
Subject: Re: Localization with NSString
Date: Tue, 22 Jun 2010 15:21:00 +0100

On 22 Jun 2010, at 14:59, Paul Chany wrote:

> Hi,
> 
> I'm trying to localize the Window.app Renaissance application so that
> every string that an user can see be localized.
> 
> (I'm new to Obj-C.)
> 
> The Window.app is that from Nicola Pero's Renaissance tutorial.
> I'm reading in 'Renaissance Manual' chapter '3.1.2 GNUstep localization 
> macros' and trying to get localized the 'Hello!' string to Hungarian and
> Croatian. 
> 
> When I compile the Window.app I get warnings:
> 
> make
> This is gnustep-make 2.4.0. Type 'make print-gnustep-make-help' for help.
> Making all for app Window...
> Creating Window.app/....
> Compiling file main.m ...
> main.m: In function ‘-[MyDelegate printHello:]’:
> main.m:39: warning: passing argument 1 of ‘printf’ from incompatible
> pointer type 
> /usr/include/stdio.h:339: note: expected ‘const char * __restrict__’ but
> argument is of type ‘struct NSString *’ 
> Linking app Window ...
> Creating Window.app/Resources...
> Creating stamp fileCreating Window.app/Resources/Info-gnustep.plist...
> Creating Window.app/Resources/Window.desktop...
> Copying resources into the app wrapper...
> Copying localized resources into the app wrapper...
> 
> So when I run Window.app I can't get it to print the localized string
> 'Hello'. What is the problem and how can I solve it?
> Any advices will be appreciated!

I took a look at the tutorial ... the localisation instructions there are for 
localising the user infterace using renaissance, but it appears that you are 
wanting to localize the message logged by the code in the application ratyher 
than the user interface ... so the renaissance instructions don't apply.
In this case you have a line of code saying 'printf("Hello!\n");' and you want 
to use a localized version of the string.

Firstly you need to change to use a function which works with NSString objects 
rather than C-strings.
eg.
GSPrintf(stdout, @"Hello!\n");

Then you need to deal with localization.  The standard way to do that in 
GNUstep is using the '_(X)' macro (which is a shorthand for a more longwinded 
localization call: 'NSLocalizedString (X, @"")' ).  Renaissance effectively 
does this for you in the gui code it controls, but in your own program code you 
have to localize the strings you want localised.

eg.
GSPrintf(stdout, _(@"Hello!\n"));

That loads localised strings from the default localisation file of the 
application.







reply via email to

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