Configuring NSLocalizedString from remote api

Viewed 195

I would like to A/B test different variations of strings in my app by fetching translations from my server, and displaying them on the screen.

Let's say I have an api that takes locale and a list of string keys, and returns their values, for example:

// request   
{ 
    "locale": "es",
    "keys": ["greetings"]
} 

// response   
{ 
    "greetings": "Hola!"
} 

and then in the app I just use that value. It's easy and it works.

However, I'm not sure what to do with strings that require proper handling of plural nouns.

Usually I'd use .stringsdict:

enter image description here

then in the code I use it as follows:

enter image description here

This works just fine, everything looks correct at runtime: enter image description here

This only works with Localizable.stringsdict, and it has to be a file in the bundle.

Is there a way to make it work with dictionary fetched from remote api?

0 Answers
Related