Page 1 of 1

Selecting a Language in a Site

Posted: Thu Jul 26, 2007 7:10 pm
by Maluendaster
Does anyone knows where i can get a tutorial to learn how to create a multilingual site?

Thank you.

Posted: Thu Jul 26, 2007 7:50 pm
by Ollie Saunders
Have a look at gettext php extension there are tutorials about that and at least one on, the excellent, sitepoint. There are many other issues concerning multi language sites. I believe PEAR and the Zend Framework have a bunch of tools for managing other issues such as those to do with dates and times. UTF-8 support for all unicode characters is quite useful but a bit of a hassle in PHP.
If you are only serving static pages Apache's content negotiation may be of interest, you can probably recreate it's behaviour in pretty easily PHP.

Final note: we tend to be more helpful on specific issues.

language files

Posted: Thu Jul 26, 2007 10:00 pm
by yacahuma
i just read a little on gettext and I jave no idea of what it does. I know I have done site with spanish and english in a very simple manner.

I created a directory called languages. There I have en.php and spa.php

inside you will see something like

Code: Select all

en.php
$dog_la = 'dog';
$cat_la = 'cat';

spa.php
$cat_la = 'gato';
$dog_la = 'perro';

you get the idea.
In every page you will use the variable defined on the language files instead of the word
Use a session to keep track of which language the user wants.

Code: Select all

include 'languages/' . $_SESSION['language'] . '.php';
Simple but effective.

Re: Selecting a Language in a Site

Posted: Sun Feb 03, 2008 4:25 pm
by matteoraggi
what about if someone want to translate not only simple text but categories and subcategories, for example here:
http://www.hotel-supplies.biz
I desire to translate it also in italian language: http://www.forniture-alberghiere.net and german: http://hotelbedarf.biz
which is the best way to do this work for me?
I just not have any multi-language script in this moment installed..