0

Hi all
I am working on a website and the requirement is to make it in two languages i.e. icelandic and english.
just like facebook and other google, if a user selects a language, then the site is translated in that language.
I am not allowed to use google translator.
Any other way to do this in Php

Thanks in advance :)

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by diafol
0

Hi,

Many ways to achieve this... some people in smarty community where I used to hangout a lot, they were using an xml for translation, while others uses a module of which I can't even remember its name.

Another common method is the direct translation for example,

create a language dir, and then inside the language dir create language name directory. e.g. language/en language/icelandic . Now for the php language page..

save this as en.php

$lang['home'] = "home";
$lang['comments'] = "comments";

create a test.php

require_once 'language/en/en.php';

## echo the translated item
echo $lang['home'];
echo "<br/>";
echo $lang['comments'];
echo "<br/>";

Direct your browser to test.php.. it should print home and comments.. now create another file and name it icelandic.php. translate the words in double quotes to the icelandic language. Change the require_once 'language/en/en.php'; to the icelandic directory. Direct your browser to the test.php. The page should be showing the translated language.

To change the language you can use $_GET to capture the viewers language selection, and then put it in session..

Edited by veedeoo: n/a

0

Thanks for the reply veedeoo
but my site is not static, what to do if i have some text dynamic?

0

Static text in arrayss or xml. Dynamic text in db fields. I assume all dynamic text will be from users.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.