Wednesday, June 12, 2024
HomeiOS Developmentios - Methods to correctly construct localization string key with a variables...

ios – Methods to correctly construct localization string key with a variables inside it


I’ve the next code:

Textual content("key.(merchandise.rely) (merchandise.actionName)")

And based mostly on merchandise.actionName, I would like to offer totally different translations to implement pluralization appropriately. merchandise.rely is of kind Double (it have step of 0.5) and merchandise.actionName is of kind String.

I believed that utilizing totally different keys within the catalog, like this:

"key.%f actionName1", "key.%f actionName2"

would work. Moreover, the interpretation could be simply “%f actionName” with out the .key half, which I used for sort of “namespacing” amongst different keys.

Nonetheless, this strategy would not appear to work as anticipated. Xcode appears to interpret(I assume?) the string from the Textual content view as:

"key.%f %@"

quite than "key.%f actionName1". How can I implement this correctly?

Additionally, I am conscious of the ^[(item.count) actionName"(inflect: true) approach. However, it seems to work mostly with English, so that’s not an option for me.

I tried to use String(localized:) but probably wrongly, so…

Any suggestions would be greatly appreciated!



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments