0

我正在做一个没有任何storyboards. 所以我不能使用“基础国际化”

我创建了 localizable.string 然后为每种所需语言打开了本地化。

然后尝试做

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

对于通知,我使用 nsdictionary 并将通知存储为:

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

但是在更改设备的语言时它不会做任何更改。有没有我遗漏的步骤或者是否有更好的方法?任何工作参考将不胜感激!

4

1 回答 1

1

解决方案 1:

执行以下步骤。

  1. 清洁项目
  2. 从设备/模拟器中删除应用程序
  3. 如果模拟器 - 重置它。
  4. 删除派生文件(XCode > Window > Projects > Derived Data Delete)
  5. 安装应用程序,它将工作。

我认为它只是缓存问题。

解决方案 2:

NSLocalizedString 默认使用 Localizable.strings 文件。更改您的 File.strings 名称,然后重试。

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

于 2016-02-18T08:18:32.320 回答