localize UIAlertView & offline notifications in project with no storyboard

87 views Asked by At

I'm working on a project that doesn't have any storyboards. So I can't use "base internationalization"

I've created localizable.string then turned on localization for each required languages.

Then tried doing

- UIAlertView * messageBox = [[UIAlertView alloc] initWithTitle:
                                                   NSLocalizedString(@"title", nil)
                                                   message: NSLocalizedString(@"msg", nil)
                                                   delegate: self
                                                   cancelButtonTitle: NSLocalizedString(@"ok", nil)
                                                   otherButtonTitles: nil];

And for notification i'm using nsdictionary and store notifications as:

 - [alertMessages setObject:NSLocalizedString(@"test_notification", nil)
   forKey:@"6"];

but it doesn't do any changes when changing language of the device. Is there any step i'm missing or if any better method is there? any working references would be greatly appreciated!

1

There are 1 answers

2
Chatar Veer Suthar On BEST ANSWER

SOLUTION 1:

Do the following steps.

  1. Clean Project
  2. Delete App From Device/Simulator
  3. If Simulator - Reset it.
  4. Delete Derived Files (XCode > Window > Projects > Derived Data Delete)
  5. Install App, and it will work.

I think its simply Cache Issue.

SOLUTION 2:

NSLocalizedString uses Localizable.strings file by default. Change your File.strings name and try again.

NSLocalizedStringFromTable(@"Message", @"File");