views:

109

answers:

0

Hello

Im doing my first localized project and I've been fighting with it for several hours with no luck.

I have to create an app that, based on the user selection, shows texts and images in different languages.

I've read most of Apple's documents on the matter but I cant make a simple example work.

This are my steps so far:

1) Create a new project.

2) Manually create a "en.lproj" directory in the projects folder.

3) Using TexEdit create file called "Localizable.strings" and store it in Unicode UTF-16. The file looks like this:

/* 
   Localizable.strings
   Multilanguage02

   Created by Gonzalo Floria on 5/6/10.
   Copyright 2010 __MyCompanyName__. All rights reserved.
 */
"Hello" = "Hi";
"Goodbye" = "Bye";

4) I drag this file to the Resources Folder on XCode and it appear with the "subdir" "en" underneath it (with the dropdown triangle to the left). If I try to see it on XCode it looks all wrong, whit lots of ? symbols, but Im guessing thats because its a UTF-16 file. Right?

5) Now on my view did load I can access this strings like this:

NSString *translated;
translated = NSLocalizedString(@"Hello", @"User greetings");
NSLog(@"Translated text is %@",translated);

My problem is allowing the user to switch language. I have create an es.lproj with the Localizable.strings file (in Spanish), but I CANT access it.

I've tried this line:

[[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:@"es", nil] forKey:@"AppleLanguages"];

But that only works the NEXT time you load the application. Is there no way to allow the user to switch languages while running the application??

Do I have to implement my own Dictionary files and forget all about NSLocalizableString family?

Thanks for ANY advice or pointers.

Gonso