gpt4 book ai didi

objective-c - 占位符和 NSLocalizedString

转载 作者:太空狗 更新时间:2023-10-30 03:41:19 24 4
gpt4 key购买 nike

我正在尝试翻译我的应用程序,但我发现当有半个占位符时很难翻译。我需要找到以下代码:

[textView1 insertText:[NSString stringWithFormat:@"%@ è il %i/%i/%i. Il giorno delle settimana è %@. La Festa è compresa nel calcolo. \n", nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]];

我把文件localizable.string(英文):

"festaCompresa" = @"%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n";

然后我编辑了这段代码:

[textView1 insertText:[NSString stringWithFormat:NSLocalizedString(@"festaCompresaW, @""), nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]];

它不起作用。

最佳答案

您的字符串文件有一个小错误,您包含了一个 @ 就好像该字符串是一个 NSString 常量 - 文件格式使用引号中的字符串:

"festaCompresa" = "%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n";

顺便说一句:在为本地化创建格式字符串时,您可能需要使用位置 格式,其中每个格式规范都包含参数的编号。例如:

"festaCompresa" = "%1$@ is the %2$i/%3$i/%4$i. the day of the week is %@. The holidays is included in the calculation. \n";

这在上面的字符串中显然不是必需的,因为参数是按照它们提供的顺序包含的。然而,在某些语言中,它们可能需要以不同的顺序排列,这就是它的完成方式。

关于objective-c - 占位符和 NSLocalizedString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10387060/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com