使用“%@%@”?

发布于 2025-02-01 11:13:32 字数 714 浏览 2 评论 0原文

我的本地化值只有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 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文