Updated 14 December 2016
Translate languages at runtime like if u want to move english to chinese or french etc.Choose languages which you want in your application from Localization .Create .string file named (Localizable.string) localize that file into selected languages which you want ,after that add content to the Localizable.string file.
select Languages In localization
localize into selected languages
Add key Of string which you want to translate, add content to Localize.string file as shown below
1 |
[languageBundle localizedStringForKey:@"pleaseWait" value:@"" table:nil] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
warning = "Warning"; errorConnection = "ERROR with the Connection"; retry = "Retry"; dismiss = "Dismiss"; pleaseWait = "Please Wait...."; productAdded = "Product Added To Wishlist Successfully."; success = "success"; somethingWrong = "Sorry!! Something went wrong please try again later."; error = "error"; searchTerms = "Search Terms"; advanceSearch = "Advanced Search"; logIn = "LogIn"; dashboard = "Dashboard"; accountInformation = "Account Information"; addressBook = "Address Book"; myOrders = "My Orders"; productReviews = "My Product Reviews"; wishlist = "My Wishlist"; newsletter = "Newsletter Subscription"; downloadableProduct = "MyDownloadable Products"; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
-(void) language{ NSUserDefaults *languageCode = [NSUserDefaults standardUserDefaults]; if ([languageCode stringForKey:@"language" ] != nil) { NSString *language = [languageCode stringForKey:@"language"]; NSString *path= [[NSBundle mainBundle] pathForResource:language ofType:@"lproj"]; if (path == nil){ path = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"]; } _languageBundle = [NSBundle bundleWithPath:path]; } else{ [languageCode setObject:@"en" forKey:@"language"]; [languageCode synchronize]; NSString *language = [languageCode stringForKey:@"language"]; NSString *path= [[NSBundle mainBundle] pathForResource:language ofType:@"lproj"]; if (path == nil){ path = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"]; } _languageBundle = [NSBundle bundleWithPath:path]; } } |
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
1 comments