I have an app with an \"Error\" message. I want to translate this error message.
OK, first I created a file named \"Localizable.strings\". In the file I wrote:
Follow the following tutorial to create language files, than after filling them do the followihg:
If localized string doesn’t show up, there might be another Localizable.strings in the pods so:
1 - Change “Localizable.strings" name to, say, Localized.strings
2 - Specify it as the tableName argument
let myStr = NSLocalizedString("key", tableName: "Localized", comment: "comment")
The below mentioned steps might help you :
Add required text into file in following format : "newStringItem" = "This is new String item";
Now the file contents can be used as NSLocalizedString(@"newStringItem", @"") which returns corresponding string.
Vola! Done with Localization!
What happens if you use it as follows.
self.label1.text = [NSString stringWithFormat:@"%@",NSLocalizedString(@"ERR", nil)];
I had the same problem. I stared at it for days, until I peeked into the app bundle and saw that none of my .strings files were copied...
The solution is to create a build phase to copy the string files: (adapted from here)
TADA!