In a multilanguage application with lookup tables, what's the best way to handle translations?
For example for a country lookup table, a US user should see English country names, as a German should see German names. But still their IDs should be the same.
I can think of the following:
Lookup tables provide the essential function of helping you maintain data integrity in your database environment. For example, if you have users entering their gender into a data item, the table that contains the Gender item can reference a lookup table to verify that only the value M or F is used.
A lookup table is an array of data that maps input values to output values, thereby approximating a mathematical function. Given a set of input values, a lookup operation retrieves the corresponding output values from the table.
THERE ARE FOUR METHODS THAT ARE USED TO LOCALIZE DATABASES: Row localization – copies the original row for each language. Field localization – updates the values of the localized fields. Table localization – adds new language tables for each table. Database cloning – creates a copy of the database for each language.
The Ruby I18n (shorthand for internationalization) gem which is shipped with Ruby on Rails (starting from Rails 2.2) provides an easy-to-use and extensible framework for translating your application to a single custom language other than English or for providing multi-language support in your application.
The big question here is - can translations can be altered by end users?
If the answer is "NO", resource bundles are easier and faster to use than tables. Instead of actual text your tables will contain resource key (or you could use primary key for that purpose if it's textual rather than numeric) and appropriate resource bundle will contain the translation.
If the answer is "YES", you have to store translations in the database. I have found, however, that the easiest approach in this scenario is to mimic the above resource bundle functionality in the database - e.g. have a single table with "locale", "resource key", "resource value" columns that all other tables will use to look up actual localized text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With