Localization - Using plutil and genstrings tools

Hello all,

I am trying to localize my app in French and English.

I've set up the Localizable.strings files and am in the process of writing them

Of course, I test the results regularly, and last night, the french localization stopped working... Only the Keys were beeing displayed...
(My app is written in english)

In the "Internationalization Programming Topics" document provided by Apple, I found a mention of that type of problem :

"If you run into problems during testing and find that the functions and macros for retrieving strings are always returning the same key (as opposed to the translated value), run the /usr/bin/plutil tool on your strings file. "

How the H... do I do that ? in terminal ? I have no knowledge of terminal...

This doc also mentions genstrings :

"The simplest way to generate a strings file is to use the genstrings tool from the command line."

and :

"For more information about using the genstrings tool, see the genstrings man page."

But I can't find this page, is it a lookup in Terminal as well ?

if anyone can help, PLEASE do so..

Thanks

MacBook, Mac OS X (10.5.4), MacBook

Posted on Aug 3, 2008 1:44 AM

Reply
5 replies

Aug 3, 2008 7:19 AM in response to Ostrowsky S

Ostrowsky S wrote:
"For more information about using the genstrings tool, see the genstrings man page."


"plutil" and "genstrings" are both command line utilities that you'll have to run in Terminal.

In addition, "man" is the command line tool you use to read the online manual. So if you Launch Terminal and type "man genstrings" (without the quotes) you'll see the manual page for genstrings.

Once you're viewing the man page use the arrow keys to move up and down thru the info. Also, the space bar will move down an entire screen. Press the "q" key to exit the man page and get back to the Terminal prompt.

It appears that "genstrings" is a utility that can generate .strings files from C, Obj-C and Java source code. I've never used it though.

"plutil" is a utility for converting property list files from one format to another. I use this one fairly frequently for converting .plist files from binary to xml and back, but I'm not quite sure how it would be useful in your situation.

Steve

Aug 4, 2008 12:20 AM in response to Steve Herman1

OK, so:

I created a test project called "testGenstrings". in its Directory, I created an en.lproj folder into which I am trying to get that Localizable.strings file written.

In my test project, i Have 4 line containing NSLocalizedString commands...

for info :

- (IBAction)decodePressed
{
textView1.text = NSLocalizedString(@"pressage", @"");
textView2.text = NSLocalizedString(@"felicitations", @"");
textView3.text = NSLocalizedString(@"age", @"");
textView4.text = NSLocalizedString(@"name", @"");
}


Here is the command line from my terminal shell :

genstrings -s NSLocalizedString -o en.lproj/

executed from my tesGenstrings directory (with root privileges)

Nothing happens !

What am I forgetting ?


Thanks

Serge

Aug 4, 2008 1:05 PM in response to Ostrowsky S

Ostrowsky S wrote:
Here is the command line from my terminal shell :

genstrings -s NSLocalizedString -o en.lproj/

executed from my tesGenstrings directory (with root privileges)

Nothing happens !

What am I forgetting ?


I believe the problem is that you're not providing genstrings with the source file name that you want it to scan. That's what the file parameter at the very tail end of the SYNOPSIS portion of the man page indicates. It kinda seems like genstrings ought to give you an error message or something though... 😟

Also, I don't believe the "-s NSLocalizedString" is necessary in your case. According to the man page you would use the "-s" option if you needed to specify a routine name *other than* NSLocalizedString. However, I don't think including this option is causing you a problem.

I created a test file similar to yours named MyController.m:

#import "MyController.h"
@implementation MyController
- (IBAction)btnPressed:(id)sender {
NSString * temp;

temp = NSLocalizedString(@"pressage", @"");
temp = NSLocalizedString(@"felicitations", @"");
temp = NSLocalizedString(@"age", @"");
temp = NSLocalizedString(@"name", @"");

}
@end


Then, running this command in Terminal seemed to work for me:

genstrings -o English.lproj/ MyController.m


The output was a "Localizable.strings" file located in my English.lproj directory that looked like this:

/* No comment provided by engineer. */
"age" = "age";
/* No comment provided by engineer. */
"felicitations" = "felicitations";
/* No comment provided by engineer. */
"name" = "name";
/* No comment provided by engineer. */
"pressage" = "pressage";


Note that I've never localized an app so I don't know if this is the sort of output you're looking for or not.

Steve

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Localization - Using plutil and genstrings tools

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.