As the title mentioned here is a quick start to internationalize your application. For more details you can read on the Yii API Documentation, what’s all about Yii::t() function:
Set your targeted application language:
In the main application configuration file which usually located at protected/config/main.php, set this:
<?php return array( 'language' => 'en', // the language that the user is using and the application should be targeted to );
Create a folder named messages in your protected folder:
Quote
Within the messages folder, create folders to store your language files by naming the folder with the language code (en, de, id):
Quote
protected/messages/id
protected/messages/de
Now, before continue, we must understand the minimum params for Yii::t() method that actually translates the language. here is the minimum format:
<?php Yii::t('param1', 'param2');
Explanation on what the params mean: param1 is the category, refers to the filename where the translations are stored. param2 is the string constant to be translated.
Within your view for example:
<?php echo Yii::t('contentForm', 'LABELSELECTTITLE');
In order for that to work, you need to create a new php file named contentForm.php under the protected/messages/[your language]/contentForm.php.
In your protected/messages/en/contentForm.php:
<?php return array ( 'LABELSELECTTITLE' => 'Select Title' );
And in your protected/messages/id/contentForm.php for example:
<?php return array ( 'LABELSELECTTITLE' => 'Pilih Judul' );
And that's all it has to be done. Congrats, your application is now just internationalized.