我如何使用NSLocalizedString构建具有多个参数的字符串,同时让翻译器控件根据需要更改顺序?
我的Localizable.string中的一个示例是:
"score_out_of"="Your score is %i out of %i";
Run Code Online (Sandbox Code Playgroud)
并且会像
[NSString stringWithFormat:NSLocalizedString(@"score_out_of", nil), correct, total];
Run Code Online (Sandbox Code Playgroud)
但是在某些语言环境中,语法规则可能会规定总数必须正确。在目标C中,插值顺序似乎是硬编码的。
在其他语言中,这是通过命名参数来实现的,例如在ruby中将其定义为:
out_of: "Your score is %{correct} out of %{total}"
Run Code Online (Sandbox Code Playgroud)
并像这样调用:
I18n('out_of', {total: total, correct: correct})
Run Code Online (Sandbox Code Playgroud)
在iOS / Objective C上完成相同任务的推荐方法是什么?
localization objective-c internationalization nslocalizedstring ios