views:

52

answers:

2

Hi guys

I have a question, how would I do the following?

  • I want to display a dropdown (html) with a list of language (english, french, etc.), ISO 639-1 codes. I want to display the language based on the native language (e.g., on the combo box, the "french" must say "francais" for the french speaking people to understand).

How I would do it? i,e. This is how I did it in MySQL

CREATE TABLE IF NOT EXISTS LANGUAGE
(
     LANGUAGE_CODE              VARCHAR(3) NOT NULL    --ISO 3 digit digit code
     ,LANGUAGE_NAME_ENGLISH     TEXT NOT NULL
     ,LANGUAGE_NAME_NATIVE      TEXT NOT NULL
) DEFAULT CHARACTER SET utf8;

The only problem, I cannot populate "LANGUAGE_NAME_NATIVE" since 1) I cannot get all native languages, and 2) I don't have languages in UTF8 format.

Is there any better way to do this?

Basically, what I'm accenuating is this: Should I have a language table for all the language list of all respective language; should I have i18n configuration files (properties file) for all languages list in their respective language or should I use a language translator?

PS I'm using MVC like Spring MVC and Struts.

+1  A: 

many frameworks allow you to do i18n configuration via properties files. You would have a properties file for each supported language. All properties files would have the same keys but different values, and you would use the keys in your presentation layer. You will have to look at the documentation for whatever technologies you are using...

edit -- here is a link i found for struts... http://www.allapplabs.com/struts/struts_internationalization.htm

hvgotcodes
That's cool, but I have to make it MVC independent (if you know what I mean).
The Elite Gentleman
Im not sure what you mean by 'MVC Independent' -- your problem is that users are going to select their language, and then you are going to display your content in whatever language they select, right? If that is your problem, then using the i18n solution of Spring/Struts/Whatever you are using seems to be the way to go.
hvgotcodes
I agree, my thing is this, I have a language list (from ISO 639-1) that's fully in English so a Taiwanese person won't understand that "Taiwanese" is his language. I want to display all the languages in their respective language. How would I do this "translation" thing? keep it in db or use a translation tool or keep a list in a i18n configuration file?
The Elite Gentleman
aaaaahhh i see now. Hmm I don't know. Storing in the DB seems like a good idea then, but I don't know how to solve the specific issue you mentioned...sorry
hvgotcodes
+1  A: 

Storing in DB level is fine. The only alternative is to store it in same place as the translations. If those are filebased, it would be too expensive to open/load every file to gather the available languages.

Left behind your question how to get the translations: no tool comes to mind. How are you actually doing the "normal" translations? Using a human translator? Let him/her do the job translating the language name and insert it in the DB yourself. Alternatively, parse this or this.

BalusC
My initial idea is to use Google translator on the fly....but what if Google server crash? I'm looking at efficient ways of doing this.
The Elite Gentleman
That's an extremely bad idea. It's not only expensive, but it also makes no sense. Languages doesn't change daily. I.e. it's static information. Isn't this question more an evidence of laziness? :) You would already almost be finished by routinely gathering and inserting the data in DB in the time you spent waiting for answers on this question...
BalusC
@BalusC, now how would I store these native languges in database seeing I can't copy paste these languages to a SQL statement?
The Elite Gentleman
Insert it yourself. There's no magic. That's why they hired you. Hint: you can create a multi-insert statement by writing SQL like so `INSERT INTO tbl (col1, col2) VALUES (val1a, val2a), (val1b, val2b), (val1c, val2c)`.
BalusC
LOL @BalusC, it's not that....it's that many editors cannot support locales, e.g. language "dinka" (Thuɔŋjäŋ). How would I store value in bracket then?
The Elite Gentleman
I would say that you've to look for a better editor which supports UTF-8. Even PhpMyAdmin accepts it perfectly fine.
BalusC
Sweet, thanks....I'll accept your answer then.
The Elite Gentleman