I did some reading on localization in iOS and it seems like the two main things are localizing the nib file, and using the NSLocalizedString to grab the localized string from the string file. For our app, we have a sqlite database (using the FMDB wrapper) for the majority of our content we display. In this scenario, how would we localize our app? Do we need a Chinese version of our database? Or do we need a Chinese strings file that serves as a lookup table from the strings we pull out from our database. Like if in the database there is a description of a car, do we then look for that description in the strings file? I haven't really seen any examples on localization with a database.

Thanks!

有帮助吗?

解决方案

There's really 2 kinds of data here: 1) data that's operated on by your app, and string data that your app uses to display. You want to keep 1) separate so that if someone changes the language on their device, the data will still be correct. For 2) you can use the strings file lookup from the database as you suggest. You can also have language specific tables that hold these strings and just open that language's table when you run the app. For instance, your current database stores a temperature (number), and a city name. Using your string name, you'd get the city name from your database and use it as a lookup in strings.h, or you can have a database table of City names for each languages, and join to that table depending on the language setting, but only store the temperature in one place, so that all languages access it. You'll have to decide what data should be common to all languages, like temperature above, and probably write routines that will display that data depending on the language, as well.

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