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 :)

Recommended Answers

All 3 Replies


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..

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

Member Avatar

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.