Wednesday, March 14, 2012

How to add multi-language site in yii framework

To make multi language in your yii framework you have to implements some rules. You can use the session variables to make the translation between your page. With the the documentation you can look at here.

I have to implements this to make the translation page. You can follow the instruction in that articles that not almost I discuss in this page.

But when I finish implement that step, I can make my own translation page on the protected/messages/<your language id>/<your category>.php files..

For the example :

../protected/messages/id/translation.php

The example of the translation page that I use like this
<?php
/**
 * Bahasa Indonesia Yang digunakan untuk menerjemahkan
 */
return array(
  //------NAVIGASI MENU------------//
  'Home'=>'Beranda',
  'About'=>'Tentang',
  'Contact'=>'Kontak',
  'Login'=>'Masuk',
  'Logout'=>'Keluar',
  
  
  
  //-----------ISI KONTEN DEPAN------------------//
  'What are You Looking For?'=>'Apa Yang Anda Cari?',
  'Sell Your Products'=>'Mau Menjual Barang',
  'Products'=>'Barang',
  'Services'=>'Jasa'
  
  );
?>

Oke when you finish that I use my native languages (Indonesian=ID) and than I can use that for my translation in my code using this example in your view files.



echo Yii::t('translation','Home');

1 comment:

  1. Creating your first web site can be an intimidating task if you don't know where to start.

    Multilingual websites

    ReplyDelete