Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Multi-Lingual Site

Guest
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

Hi

The website I am designing will have two or three different languages.

Is it OK just to use the same database I am currently using but just add extra fields for different languages i.e.

id | contentEN | contentCN | contentFR

like that? and then send the selected language in the URL with $_GET - or would a cookie be better?

I would change the URLs in the htaccess file to make them nicer/more user friendly.

Or is there a better way to do it?

Thank you,

Chris

TOPICS
Server side applications

Views

595
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 23, 2012 May 23, 2012

Copy link to clipboard

Copied

LATEST

Or is there a better way to do it?

Yes, there is a better way to do it.

Let's say you have a table called 'pages' which contains data specific to pages. Store any language-specific data in a separate table linked by a foreign key.

So the pages table might have the following columns: page_id, main_image, page_type, and the page_content table would have the following columns: page_id, language_id, content.

A third table, called languages, contains five columns: language_id, language_name, language_selected, Language_active, and language_default. See the illustration for administration below.

languages.gif

Then, regarding your urls, they would look something like this:

page.php/page_id=26&language_id=2

You could use htaccess to create 'friendlier' urls, but I wouldn't (Google advises against it)

The problem with using cookies or sessions for the language choice is that it won't be included if someone links to a page.

There are various ways to handle which language will show by default. You can use an IP lookup table to determine which part of the world the visitor is in, but I simply pick the language most visitors are likely to know, so if 90% of the traffic is from Vietnam, we use Vietnamese as the default.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines