0

I finished my website and want to translate it in 3 other languages.
The question is not how to translate it, but how to handle the different languages, when you don't use a CMS.

I have all my script with English text in it.
I'm able to translate it in Dutch, French and German, so I'll have 3 folders: 1 folder for each language.
The problem is when I wan't to upgrade the website:
If I change code from the English folder, I'd like to juste copy-and-paste this code for the 3 other languages.
Problem is that I will always have to retranslate it to 3 other languages again.

How do big websites handle translation?
Having multiple folders, with every folder = 1 language, is the way to proceed?
Text coming from database is a better solution? With a table for each language?

unor
  • 92,415
  • 26
  • 211
  • 360
gr3g
  • 2,866
  • 5
  • 28
  • 52
  • 1
    Are you using Visual Studio’s "Web Site" projects (which the tag [tag:web-site-project] is about)? – unor Oct 18 '14 at 20:12
  • 1
    Didn't really find appropriate tags for this question... No, I'm not using Visual Studio's – gr3g Oct 18 '14 at 20:46

1 Answers1

1

Make a function with the parameters: string code, language So for example: translate('error_1','de_DE'); that "would" return an specified error in German. So you could create 3 .csv files with all the strings you would need.

And having multiple folders is rubbish. On the bis pages it just seems as they use different folders but the "folder" is handled via. .htaccess and is changed to i.e. index.php?page=main&language=de_DE

Cr41s3
  • 97
  • 2
  • 11
  • Is it possible to proceed this way, but don't use `$_GET['language']` but `$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);` on very page and set `translate('param1','param2')` with param2 as `$language`? – gr3g Oct 18 '14 at 21:05
  • I'm trying to use it know... Could you please add 1 detailed example? – gr3g Oct 21 '14 at 14:38
  • The function you need to write on your own. Just need to read the .csv file or .ini file and then search for the string and the return of the search you can return to your main script. – Cr41s3 Oct 21 '14 at 14:49