1
votes

I'd like to be able to load translations in a JSON file (array of key value pairs) from a remote server at application boot or whenever deemed necessary, and keep the file locally on the device, as opposed to hardcoding into a .strings file.

I will be using this for labels, buttons and the like. All application data will already be translated on server side.

This will make it easy to add/remove languages/translations.

What's the best way to do this?

2

2 Answers

0
votes

There are many ways to do this.

I would advice to save them under in a dictionary, and save this dictionary under NSUserDefaults (NSUserdefaults will let this dictionary save and stay even when your app force closes. As long as you don't remove it in a function or uninstall the application).

Hope this helps!

0
votes

You can try to use LocalizationKit. This kit doing exactly what you described.

Another way is to dowload resource while app is loading and save all translation in UserDefaults.