【问题标题】:localize UIAlertView & offline notifications in project with no storyboard在没有情节提要的项目中本地化 UIAlertView 和离线通知
【发布时间】:2016-02-18 07:18:32
【问题描述】:

我正在处理一个没有任何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"];

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

【问题讨论】:

  • 在 Localizable.strings 文件中显示标题、消息和确定。
  • in localizable,strings (English) "title" = "congratulations!"; "msg" = "你已完成所有关卡"; "好的" = "知道了";在 localizable.strings (法语) "title"="Félicitations !"; "msg"="Vous avez terminé tous les niveaux"; "ok"="COMPRIS"
  • 删除应用程序,然后清理,然后再运行。
  • 字符串文件的确切名称是什么?是 localizable.strings 还是 Localizable.strings。应该是后者,因为文件名在设备中区分大小写。您还将设备更改为哪种语言设置?
  • 这是后来的一个 - 我当然是法语:(

标签: ios cocos2d-x xcode7.2


【解决方案1】:

解决方案 1:

执行以下步骤。

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

我认为它只是缓存问题。

解决方案 2:

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

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

【讨论】:

  • 太棒了.. 解决方案 2 对我有用!我使用的是 NSLocalizedString 但 NSLocalizedStringFromTable(@"Message", @"File", comment);成功了。
  • 我的荣幸 :) 编码快乐。
猜你喜欢
  • 1970-01-01
  • 2013-12-09
  • 1970-01-01
  • 2015-10-26
  • 2015-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多