 |
 |
|
 |
03-17-2009, 01:04 AM
|
#1 (permalink)
|
|
New Member
Join Date: Jan 2009
Posts: 4
|
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.
|
|
|
03-17-2009, 04:20 AM
|
#2 (permalink)
|
|
Registered Member
Join Date: Feb 2009
Location: Poznań, Poland
Age: 23
Posts: 52
|
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.
|
|
|
03-17-2009, 08:48 AM
|
#3 (permalink)
|
|
Registered Member
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 13
|
You can user the Localizable.strings - I do the same
|
|
|
03-17-2009, 01:00 PM
|
#4 (permalink)
|
|
Registered Member
Join Date: Feb 2009
Location: Poznań, Poland
Age: 23
Posts: 52
|
Quote:
Originally Posted by pixel-shock
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!
|
|
|
03-18-2009, 02:49 AM
|
#5 (permalink)
|
|
New Member
Join Date: Jan 2009
Posts: 4
|
Quote:
Originally Posted by pixel-shock
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
|
|
|
03-18-2009, 03:20 AM
|
#6 (permalink)
|
|
monotreme
Join Date: Oct 2008
Location: UK
Posts: 146
|
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.
|
|
|
03-19-2009, 01:20 AM
|
#7 (permalink)
|
|
New Member
Join Date: Jan 2009
Posts: 4
|
Quote:
Originally Posted by manicaesar
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
|
|
|
 |
| 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: 327 |
| 29 members and 298 guests |
| angelFrog, ansonl, Batman, cavernicola, chorew, dbonates, Duncan C, Ed99, guyhundere, hatembr, Hololont, InteractiveLogic, iSdkDev, iTrackiGiveaway, j0egas, jaime1988, LemonMeringue, loobian, markdude, nDev1, obiwahn, racer_X, rjgrune, Rossco, s.newave, vitalys, wheels, yannickd60 |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 24,317
Threads: 39,113
Posts: 171,500
Top Poster: smasher (2,576)
|
| Welcome to our newest member, Lightsout565 |
|