Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-04-2011, 12:10 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 54
Nekbeth is on a distinguished road
Default 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
Nekbeth is offline   Reply With Quote
Old 05-04-2011, 12:31 PM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

just create more than 1 plist, and load the plist of the current language (the same tecnique to localize images)
__________________
dany_dev is offline   Reply With Quote
Old 05-04-2011, 12:47 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 54
Nekbeth is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
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
Nekbeth is offline   Reply With Quote
Old 05-04-2011, 03:49 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 54
Nekbeth is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
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
Nekbeth is offline   Reply With Quote
Old 05-04-2011, 05:12 PM   #5 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

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
__________________
dany_dev is offline   Reply With Quote
Old 05-04-2011, 05:49 PM   #6 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 54
Nekbeth is on a distinguished road
Default

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 ?
Nekbeth is offline   Reply With Quote
Old 05-04-2011, 06:17 PM   #7 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 54
Nekbeth is on a distinguished road
Default

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.
Nekbeth is offline   Reply With Quote
Old 05-05-2011, 02:54 AM   #8 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

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);
__________________
dany_dev is offline   Reply With Quote
Old 05-05-2011, 09:31 AM   #9 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 54
Nekbeth is on a distinguished road
Default

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?
Nekbeth is offline   Reply With Quote
Reply

Bookmarks

Tags
localization

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:56 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0