Multilanguage website

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pedro84
Forum Newbie
Posts: 11
Joined: Sat Oct 21, 2006 11:28 am

Multilanguage website

Post 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:)]
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post 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;
Post Reply