Page 1 of 1

Multilanguage website

Posted: Tue Oct 24, 2006 4:23 am
by pedro84
Hello again!

I'm PHP neewbie, but I'm writing my first website, with huge help from good people. I have problem. I want to make multilingual site based on lang files

Code: Select all

define ('LOGIN', "Login");

But I don't know how to start, I found some articles over the internet, but I don;t understand them:)

I wanna ask how to make a cookies session too. You know, that recognize user's language all the time he is on the site in one session.

I hope You know what I mean.

Thank You in advance

Greetings,
Pedro Juan Alvaredo-Kowalski [Spanish-Polish Surname:)]

Posted: Tue Oct 24, 2006 9:18 am
by jmut
well if you use pure php ...no template engines like smarty and all.
you should be able to easily implement.


http://www.gnu.org/software/gettext/manual/gettext.html

It is pretty cool.
Currently I am fighting with it to somehow parse...html files..smarty tags and stuff. I guess I will have to manually generate .po files though :(


Other than that....just having an array with different translations should be ok.

Code: Select all

//en.php
$translate['hello'] = "Hello";

//de.php
$translate['hello'] = "Hallo";


...so in your application you dynamically include the corresponding file...base on the language.
and directly use.

Code: Select all

echo $translate['hello']." ".$user_name;