使用“%@%@”?
我的本地化值只有2个值。这将是类似的:
English: "Example 5:04pm"
Arabic: "5:04pm Example"
如果本地化为%@%@
,我该如何完成?这就是我在做的事情:
en/Localizable.strings:
"some_key %@ %@" = "%@ %@";
ar/Localizable.strings:
"some_key %@ %@" = "%@ %@";
Swift:
let title = "Example"
let time = "5:04pm"
String(localized: "some_key \(title) \(time)"
但是,这总是在两种语言中都导致示例5:04 pm
,但我需要以不同的顺序对某些语言。我几乎需要类似的东西,而只是为了说明:
en/Localizable.strings:
"some_key %@1 %@2" = "%@1 %@2";
ar/Localizable.strings:
"some_key %@1 %@2" = "%@2 %@1";
注意它们是如何编号的,以便我可以控制输出。是否有一种方法可以将标识符附加到占位符,因此我可以根据左右和其他场景以不同的语言和动词在语义和顺序上不同的语言或任何更好的方法来实现这一目标的方式,以不同的方式订购标识符?
I have a localization value where it's only 2 values. It would be something like:
English: "Example 5:04pm"
Arabic: "5:04pm Example"
How would I accomplish this if the localization is %@ %@
? This is what I'm doing:
en/Localizable.strings:
"some_key %@ %@" = "%@ %@";
ar/Localizable.strings:
"some_key %@ %@" = "%@ %@";
Swift:
let title = "Example"
let time = "5:04pm"
String(localized: "some_key \(title) \(time)"
However, this would always result in Example 5:04pm
in both languages but I need them in a different order for some languages. I almost need something like this which isn't possible but just to illustrate:
en/Localizable.strings:
"some_key %@1 %@2" = "%@1 %@2";
ar/Localizable.strings:
"some_key %@1 %@2" = "%@2 %@1";
Notice how they are numbered so I can control the output. Is there a way to attach identifiers to the placeholder so I can order them differently depending on the right-to-left and other scenarios where nouns and verbs are semantically and sequentially different for different languages or any better way to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论