【发布时间】:2011-02-20 17:20:35
【问题描述】:
我有一个严重的问题,我在网上没有找到任何问题。当我推送本地化消息时,它仅适用于瑞典语而不适用于英语。我有另一个说它只显示他们的瑞典 Iphone 4 的常数。我也在 Iphone 3g 上进行了测试,它和我的 iphone 4 有同样的问题,用瑞典语而不是英语工作。
当用英语显示 Iphone 4 的弹出窗口时,我只能从服务器获得我在通知中提供的本地化密钥。
这是我从 Windows 服务器推送的 C# 通知字符串。我的 iphone 应用程序的额外参数在任何语言下都可以正常工作,因此它似乎与推送的服务器端部分无关。
int total = notification.AmountScheduledEvent + notification.AmountCourseResult + notification.AmountExam;
string locKey = (total > 1 ? "PushMessageMultiple" : "PushMessageSingle");
string msg = "{\"aps\":{"+
"\"alert\": {"+
"\"loc-key\":\"" + locKey + "\","+
"\"loc-args\":[\"" + total + "\"]},"+
"\"badge\":" + total + ","+
"\"sound\":\"default\"},"+
"\"amountSchedule\":" + notification.AmountScheduledEvent + ","+
"\"amountCourseResult\":" + notification.AmountCourseResult + ","+
"\"amountExam\":" + notification.AmountExam + "}";
在我的 sv.lproj 中的 Localizable.strings 中:
/* push stuff */
"PushMessageMultiple" = "%@ nya händelser";
"PushMessageSingle" = "1 ny händelse";
在我的 en.lproj 中的 Localizable.strings 中:
/* push stuff */
"PushMessageMultiple" = "%@ new events";
"PushMessageSingle" = "1 new event";
这是带有有效通知的屏幕图片(瑞典语) http://img267.imageshack.us/i/img0014b.png/
这是一张显示通知无效的屏幕图片(英文) http://img696.imageshack.us/i/img0015i.png/
知道为什么我得到的是常量而不是消息吗?
【问题讨论】:
-
尝试使用 NSLocalizedString(@"PushMessageMultiple",@"");
-
它有效,我得到瑞典语“%@ nya händelser”和英语“%@ new events”。
-
那我把它作为答案发布。
-
不,你误解了我的意思。 NSLocalizedString 确实有效,但是在接收到 IOS 处理的远程推送通知时,它就不起作用了。
-
这是个好问题。有没有想过?英语是您的本地化基础吗?
标签: iphone localization push-notification apple-push-notifications localizable.strings