div
div

Reputation: 21

Website Language translation in php

Hi i am devloping site in php i need to translate whole website in other language like german,spanish etc... how can it possible in php i have tried using some csv but it all goes static i mean i can not convert the whole website ..

if you have any csv or api information ..

please help..

-Div

Upvotes: 2

Views: 4012

Answers (4)

Elzo Valugi
Elzo Valugi

Reputation: 27876

Zend Translate is a library exactly build for this.

Gettext is not thread-safe. PHP supports only gettext and native array. Zend_Translate supports several source formats, including those supported by PHP, and other formats including TMX and CSV files.

Upvotes: 0

fabrik
fabrik

Reputation: 14365

While Christian's answer will do the trick there's a more cleaner and efficient way to achieve your needs: gettext is PHP's built-in function for internationalization.

Upvotes: 1

Lekensteyn
Lekensteyn

Reputation: 66485

If you want to translate 'a whole page' to any language, you could use Google Translate.

Upvotes: -1

Christian
Christian

Reputation: 28165

<?php
    $GLOBAL['langs']=array(
       'en'=>array(
          'Welcome to my site!'=>'Welcome to my site!'
       ),
       'it'=>array(
          'Welcome to my site!'=>'Benvenuto sul mio sito web!'
       )
    );

    function _($text){
       $lang=$_COOKIE['lang'];
       return $GLOBAL['langs'][$text];
    }
?><html><head><?php

    echo '<title>'._('Welcome to my site!').'</title>';

?></head><body>

    ....

</body></html>

Upvotes: 2

Related Questions