tags:

views:

85

answers:

5

So, I have created a big website (a lot of text in different files and a lot of programming). I need to add one more language, how should I do? What is the fastest way I can add second language and let my visitors to choose between them? Any ideas?
Thanks.

A: 

use google translator

Klatys
It is bad idea, because language, which I want to add, isn't very good translated in google.
hey
+3  A: 

Translation is something you have to think about from the beginning, especially with dynamic sites.

  1. Make sure all of your messages are split into a separate file or files which a translator can work on. There is an art form to this - you want large text blocks with formatting specifiers, as different languages don't follow the same noun/verb/adjective order. For instance, making text strings such as "Please choose" followed by "items" where the middle is a number is a bad idea, make the string "Please choose %d items" - this allows the translator to place the number in the ideal location.
  2. You want a strong translation tool. The fill full of string constants is acceptable, but has poor usability. Try gettext which is a mature tool for doing translations.
Yann Ramin
@theatrus +1 for gettext. Also, the link http://php.net/manual/en/function.gettext.php
dabito
A: 

My suggestion is: write the content in separeted xml files, one for each language, and depending on the language of the user, you will load your website retrieving the content from the Xml that contains the selected language.

Rbacarin
A: 

Regardless of your approach, you are going to need to store all of your outputted strings in a separate resource. Flat files with arrays would be the fastest, though an SQLite database would be more flexible.

If you were to use arrays, you would basically just make a few language files, such as english.php:

$lang = array(
  'I am a language.' => 'I am a language.'
);

... and french.php:

$lang = array(
  'I am a language.' => 'Je suis une langue.'
);

Then you could make a static Language class that would import the appropriate language file, and return translated strings based on the array in that file. For example:

Language::init('french');
...
echo Language::get('I am a language.'); // outputs Je suis une langue.
Daniel
A: 

First you need to internationalize your entire web site, and then you need to localize it into your target language.

This is another case where the only numbers that matter are zero, one, and infinity. Either you support zero languages (there is no human interface at all), one language (which you just hardcode throughout), or any number of languages. Adding one more language is no easier than adding 10 more.

Daniel Pryden