views:

91

answers:

3

Hi

I have a client that wants to store data in a MySQL database with multiple languages (English, French etc) and be able to retrieve the data (in the same specified language). ie: we have an English description of a product (varchar), which we intend to rewrite in French, and then on the server side find the description in the locale that we require.

I thought of wrapping the data in XML with language tags and then parsing the data?

What is the best way to cater for multiple languages from a user data perspective? Is there a framework out there?

J

A: 

I don't know exactly, does such mechanism exist, but if it isn't, I'd store data in format encoding$encoded_text like UTF-8$#####.

Frozen Spider
UTF is not an answer for all the problems, but you're right that in this case some Unicode Transformation Format (be it UTF-8 or UTF-16) need to be used both to store and interchange the data.
Paweł Dyda
Umm, in fact I mean to specify encoding in the beginning of the field, and decode all the remaining text using it.
Frozen Spider
A: 

This is what ResourceBundle is meant for; most people use the Properties-based implementation, but you could easily write an implementation backed by a database.

Michael Borgwardt
+3  A: 

I think that you could fix the problem with a Master - Detail table model:

TABLE Product 
--------------------
ID
ID_MANUFACTURER   
EAN13    
WHATEVER

TABLE Product_I18n
---------------------
ID_PRODUCT
ID_LOCALE
DESC

When you have to access data in a certain Locale, you have to pass the Locale String to the query, but you don't need to fight against a localized XML structure...

Tomas Narros
+1. This is the best idea for dynamic data, for static it would be better to use resources. The only problem with that solution is the fact that JOIN would be required (although it could be hidden from user perspective via some View).
Paweł Dyda