im developing application for ios5.im using core data as data storage.i have to display some information and those informations are saved in 4 languages in database, user can select language.when selects a language whole application should translated in to selected language by fetching strings from database.the database sync with remote database when application starts database sync with remote database(db is dynamic therefore can't use string file to translate my app).(except translation thing all other things are implemented im stuck with translation with db,i have small idea when user select language whole set of string loaded to user-default but i think it is not correct)any idea about translation ios app with strings in database?

有帮助吗?

解决方案

Localizable.strings uses a key/value pair approach. Do something similar inside your db. Assign a token (key) to your string (value) plus an flag for the language. The "flag" can be a integer, string, what-ever-you-like-most

Then your FetchRequest can query for the token and for the language flag and will return the string that is matching token and flag. When the user changes language the flag is changed, too, And for the same token as previously but now with the new flag a fetch request will return the string for the selected language.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top