Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone ($4.99)

dotnetIQ ($4.99)

Your First iPhone App ($1.99)

iPocket Tools 9 in 1 ($0.99)

Catch-Me (Free)

Alien Strike ($0.99)

Historic Olympic Medal-Table ($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 03-17-2009, 02:04 AM   #1 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 4
Default Localization problem

As I know, localization is mainly depends on the language,region setting of the iphone.
My application would like to provide two language support: English and Chinese.
So, I have localized the string and the nib file.

If the preferred language of the phone is English. Is it possible that I can programmatically change the preferred language to chinese, such that the user can swap between chinese and english in my application without change the setting inside the phone.
purej is offline   Reply With Quote
Old 03-17-2009, 05:20 AM   #2 (permalink)
Registered Member
 
manicaesar's Avatar
 
Join Date: Feb 2009
Location: Poznań, Poland
Age: 23
Posts: 33
Question Same problem

I was just searching the forum for solution of similiar problem, but I wasn't able to find the answer

I want my application to support, let's say, two languages: English and German. When user presses the appropriate "Change language" button in "Options" view, all elements of user interface based on language i.e. titles on buttons, text in labels, etc. should change immediately.

Could this problem be solved with the use of Localizalible.strings or do I have to solve it by myself?

Thanks in advance.
manicaesar is offline   Reply With Quote
Old 03-17-2009, 09:48 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 13
Default

You can user the Localizable.strings - I do the same
pixel-shock is offline   Reply With Quote
Old 03-17-2009, 02:00 PM   #4 (permalink)
Registered Member
 
manicaesar's Avatar
 
Join Date: Feb 2009
Location: Poznań, Poland
Age: 23
Posts: 33
Question

Quote:
Originally Posted by pixel-shock View Post
You can user the Localizable.strings - I do the same
Thanks, it is good to know, but I was wondering if you could attach some code - I'm especially interested in method invoked, when the button is pressed - how to make the language change - how to make used Localizable.strings "swap"? What should I do?

Thanks for your reply!
manicaesar is offline   Reply With Quote
Old 03-18-2009, 03:49 AM   #5 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 4
Default

Quote:
Originally Posted by pixel-shock View Post
You can user the Localizable.strings - I do the same
Can you please give some hints to us how we can change the language in progame

Which object we should focus?
the preferredLanguages of NSLocale?
NSBundle?
Thanks for your help
purej is offline   Reply With Quote
Old 03-18-2009, 04:20 AM   #6 (permalink)
monotreme
 
Join Date: Oct 2008
Location: UK
Posts: 146
Default

It would be great to change the language programatically within the app but if you are using localizable strings etc to determine language then it isn't going to be possible. That system works on NSLocale which is set in the device settings and you cannot change it.

The only way to achieve this would be to write your own classes for the localization.
spinyanteater is offline   Reply With Quote
Old 03-19-2009, 02:20 AM   #7 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 4
Default

Quote:
Originally Posted by manicaesar View Post
Thanks, it is good to know, but I was wondering if you could attach some code - I'm especially interested in method invoked, when the button is pressed - how to make the language change - how to make used Localizable.strings "swap"? What should I do?

Thanks for your reply!
Here is some testing I have done now. I can programatically force to load the view while ignoring the phone's setting

Here is some my sample Code
I use English and chinese as my application language

When loading English nib
Code:
NSBundle *myLocalizedBundle=[NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle]bundlePath],"@English.lproj"]];
SomeViewController *viewController=[[SomeViewController alloc] initWithNibName:@"NibName" bundle:myLocalizedBundle];
When loading Chinese nib
Code:
NSBundle *myLocalizedBundle=[NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle]bundlePath],"@zh.lproj"]];
SomeViewController *viewController=[[SomeViewController alloc] initWithNibName:@"NibName" bundle:myLocalizedBundle];
Here is my finding, it works for me now.
Let's discuss if there is any new findings
purej 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
» Stats
Members: 21,510
Threads: 35,793
Posts: 156,804
Top Poster: smasher (2,449)
Welcome to our newest member, dmf1978
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:48 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0