Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.