Jump to content

some query on multilingual website


avvllvva

Recommended Posts

Build your website in one language it's IMO the best solution some use a setup like an PHP array and a table for translations of their pages and their blog posts, .. To many sources to maintain keep it all in your database. If the user selects a language then translate everything that has a translation in the translation table.

 

create table language (
  id integer not null auto_increment,
  name varchar(32), -- Dutch (for back-end)
  name_translated varchar(32), -- Nederlands (for front-end)
  code char(2), -- nl
  unique language_code_un (code),
  primary key (id));

create table translation (
  id integer not null auto_increment,
  language_id integer,
  message text, -- message as typed on the website
  message_translated text, -- translated version
  key translation_language_id_fk (language_id),
  primary key (id));

 

Now on your website:

 

<a href=".." title="<?php print translate('Return to the frontpage');?>"><?php print translate('Frontpage');?></a>

 

Your function translate remembers the language of the user (cookie otherwise HTTP_ACCEPT_LANGUAGE or system settings eg English).

 

SELECT t2.* FROM language t1 JOIN translation t2 ON t1.id = t2.language_id WHERE t1.code = $code

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.