05-04-2011, 12:10 PM
#1 (permalink )
Registered Member
Join Date: Feb 2011
Posts: 54
How to localize a plist file ?
Hi, I'm working on localizing my App. I have successfully localize my nibs but I'm having some trouble with plist. How can you recommend me to localize them? *
*I have try to localize them the same way as nibs but it's not working.
Please let me know if you need more specific info.
Thank you
05-04-2011, 12:31 PM
#2 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
just create more than 1 plist, and load the plist of the current language (the same tecnique to localize images)
__________________
05-04-2011, 12:47 PM
#3 (permalink )
Registered Member
Join Date: Feb 2011
Posts: 54
Quote:
Originally Posted by
dany_dev
just create more than 1 plist, and load the plist of the current language (the same tecnique to localize images)
Thanks for your reply Dany,
I have done that, and the result is that when I build & run I get no text on my app. (it's a tableview). It seems that it's not finding any plist file after I localize them. I have checked their location in finder and found that it created two folder (en and es).
When I did the same with nib files, it also created the same folders (en and es) to store the language nibs in another location.
Could this be the problem?
Thank you
05-04-2011, 03:49 PM
#4 (permalink )
Registered Member
Join Date: Feb 2011
Posts: 54
Quote:
Originally Posted by
dany_dev
just create more than 1 plist, and load the plist of the current language (the same tecnique to localize images)
Danny, by creating a 1 plist, you mean file>new > plist or localize the existing plist?
How do you load the plist of the current language ?? (any link tutorials would be great!! )
Thanks
05-04-2011, 05:12 PM
#5 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
what I would do is to create 2 plist, ok?
like ita.plist and eng.plist
now i would use
Code:
NSString *plistToUse = NSLocalizedString(@"eng.plist",@"");
//now load the info from plistToUse
"Localizable.strings" (English)
Code:
"eng.plist" = "eng.plist";
"Localizable.strings" (Italian)
Code:
"eng.plist" = "ita.plist"
"Localizable.strings" (Franch)
Code:
"eng.plist" = "fra.plist"
So that will be taken the localized plist....
ps: dany
__________________
05-04-2011, 05:49 PM
#6 (permalink )
Registered Member
Join Date: Feb 2011
Posts: 54
Thanks for your help dany, so here is what I got so far.
I created the two more plist (en & it) from my original plist. Then I assume that the code
Code:
NSString *plistToUse = NSLocalizedString(@"eng.plist",@"");
//now load the info from plistToUse
is going in my main file inside viewDidLoad. But it now gives me a warning that I'm not using the plistToUse variable.
I grab my plist this way in my code:
Code:
//Data Recipes
NSString *Path2 = [[NSBundle mainBundle] bundlePath];
NSString *DataPath2 = [Path2 stringByAppendingPathComponent:@"RecipeData.plist"];
Should I change that piece of code for the NSLocalizeString instead ?
05-04-2011, 06:17 PM
#7 (permalink )
Registered Member
Join Date: Feb 2011
Posts: 54
Great!!! I made the following changes and it now works :
I created the 2 plist (en and it)
in my delegate (where I save my plist into a dictionary) I did this
Code:
//Data Recipes
NSString *Path2 = [[NSBundle mainBundle] bundlePath];
NSString *DataPath2 = [Path2 stringByAppendingPathComponent:NSLocalizedString(@"en.plist",@"")];
NSDictionary *tempDict2 = [[NSDictionary alloc] initWithContentsOfFile:DataPath2];
self.dataRecipes = tempDict2;
[tempDict2 release];
I then created 2 localizable.strings files and typed :
// For English
Code:
"en.plist" = "en.plist";
//For Italian
Code:
"en.plist" = "it.plist";
After that It worked flawlessly, thanks a lot Dany, I owe you a big one.
Last edited by Nekbeth; 05-05-2011 at 09:25 AM .
05-05-2011, 02:54 AM
#8 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
the code looks good, but the file should be
// For English
Code:
"en.plist" = "en.plist";
//For Italian
Code:
"en.plist" = "it.plist";
Really strange that work, check it again.
if doesn't work with these file maybe is related to nil
Code:
NSLocalizedString(@"en.plist", nil);
__________________
05-05-2011, 09:31 AM
#9 (permalink )
Registered Member
Join Date: Feb 2011
Posts: 54
Yes, I missed that one (I typed it wrong here). There is something a bit strange going on with the simulator and device do. I have localized 1 nib to two languages, after that, I clean, rebuild and it works great in the simulator but if I test it on the iPhone device..only the Localized Strings work not the nib.
Do you know why?
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 352
11 members and 341 guests
dansparrow , iOS.Lover , lorrettaui53 , MikaelBartlett , Nobbsy , oztemel , pbart , PlutoPrime , sledzeppelin , thephotographer , Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44