Adding strings localization files from a server

廉价感情. 提交于 2019-12-18 11:49:39

问题


We are building an application with dynamic data that we wish to localize. We know how to localize strings in iOS and Android but in this case the data will be downloaded dynamically from the server so we will need to download the localization files dynamically.

Usually we store the strings files inside language folders. how can we do that when the file is coming from the server?


回答1:


how can we do that when the file is coming from the server?

You can't because the app bundle is not writable on iOS devices.

There is, however, NSLocalizedStringFromTableInBundle(), which lets you specify a different bundle from which you can load the .strings file. I haven't tried but I suppose this bundle can also reside in your app's Documents or Library folder.




回答2:


Yes, it's possible, but not using standard means. Check this github repository for simple and elegant solution.

It uses .json file which contains localization info and may be downloaded from server. All controllers need to subscribe to notifications sent by localization class and implement a method responsible for (re-)setting all texts in view.



来源:https://stackoverflow.com/questions/7946686/adding-strings-localization-files-from-a-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!