xcode/iphone 中的字符串和语言

发布于 2024-12-27 09:51:53 字数 614 浏览 2 评论 0原文

您好,我的字符串有问题,我已经检查了这个链接< /a> 并执行了那里告诉的操作,但它不起作用

所以对于 xib 文件,我为每种语言都有不同的版本并且它可以工作。但我还有一个名为 Localization.strings 的文件,该文件目前只包含一个字符串:

“password”=“passwords are not the same”;

然后在我的代码中,我尝试访问本地化字符串:

NSString *tp=[[NSString alloc] initWithString:NSLocalizedString(@"password", nil)];

因此 tp 应该具有字符串“密码不相同”,但它不会返回“密码”。我一直想知道这是否是编写字符串的正确方法,也许您必须将值本身写在左侧???无论如何,我有两个版本的西班牙语和英语,并且在这两个版本中都发生了同样的事情。我已经从 iPhone 上删除了应用程序,清理干净,更改语言并重新安装,但没有任何效果。

谢谢

Hi I have a problem with my strings and I have already checked this link and did what was told there but it doesn't work

So for the xib files I have a diferent version for each language and it works. but I have also a file named Localization.strings which for now only contains one string:

"password" = "passwords are not the same";

Then in my code I try to access the localized string:

NSString *tp=[[NSString alloc] initWithString:NSLocalizedString(@"password", nil)];

so tp is supposed to have the string "passwords are not the same" but no it returns "password". I have been wondering if it is the right way to write strings maybe you have to write the value itself on the left side??? Anyway I have two versions spanish and english and in both the same thing happens. I have deleted app from the iphone cleaned, changed language and reinstalled and nothing works.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫离伤花 2025-01-03 09:51:53

您的问题是您的字符串文件的命名。 NSLocalizedString() 进行查找的默认文件是 Localized.strings

因此,将 Localization.strings 重命名为 Localizes.string。如果您愿意,也可以使用特定文件进行查找(例如,如果您将本地化字符串拆分为多个字符串文件)。使用:

NSString *tp = NSLocalizedStringFromTable(@"password", @"Localization", nil);

You problem is the naming of your strings-file. The default file that NSLocalizedString() do it's lookup in is Localizable.strings.

So rename Localization.strings to Localizable.string. You could also use a specific file for your lookup if you want too (if you for example split your localized strings into several strings-files). Using:

NSString *tp = NSLocalizedStringFromTable(@"password", @"Localization", nil);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文