[thelist] DBs and multi languages
Warden, Matt
mwarden at odyssey-design.com
Mon May 8 15:15:39 2000
> I was thinking of this one:
> <select name="RE">
> <option value=1>France
> <option value=2>Germany
> </select>
> and
> <select name="RE">
> <option value=1>Frankreich
> <option value=2>Deutschland
> </select>
>
> For internal usage I'd use the values 1 or 2 and when I have to output
> the country I'd have to do something like this:
> <pseudo-code>
> if user_language equal english then print "France"
> else if user_language equal deutsch then print "Frankreich"
> </pseudo-code>
Again, yell at me if I don't understand the problem...
Here's what I'd do:
1. Save a cookie (or similar multi-page state) like this:
if "en" within_string $HTTP_ACCEPT_LANGUAGE then
$cookie("languageID") = 1
elseif "fr" within_string $HTTP_ACCEPT_LANGUAGE then
$cookie("languageID") = 2
...
2. Create a table named LANGUAGE with supported languages. I would put a bit
field named fullySupported so that you don't run into issues where there is
a language in the language table, but not all content is translated (that's
supposed to be translated).
3. Then (I'm assuming you have the countries in a database table), add a
column to COUNTRY named LANGUAGE_ID, which is a forign key to the primary
key within LANGUAGE.
4. Grab the select box values like (excuse my own way of formatting SQL):
SELECT c.ID,c.Name
FROM COUNTRY c,
WHERE c.LANGUAGE_ID='$cookie("languageID")
Technically, you don't really need the LANGUAGE table, but I would strongly
advise that you include it.
This what you wanted? I don't think I'm leaving anything out.
--
mattwarden
mattwarden.com