Difference between #2 and #4 of
Simple example for language translation

Changes

Title unchanged

Simple example for language translation

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

yii, i18n

Content changed

[...]
Message translation is done as Yii::t(category,message) in simplest form. Create PHP translation files as protected/messages/LocaleID/CategoryName.php. The file simply contains message translations returned in array format. The built in validation messages for form fields are automatically converted by the framework in most cases.

For File translation, the file with same name under the LocaleId sudbirecotry is created. If not found, the default file is selected.

One of the issues encountered was that the language state was not maintained in subsequent request. To overcome that, we use an application behavior. Refer
[http://www.yiiframework.com/wiki/208/how-to-use-an-application-behavior-to-maintain-runtime-configuration/](http://www.yiiframework.com/wiki/208/how-to-use-an-application-behavior-to-maintain-runtime-configuration/ "behaviour class")
for more details.
Below , shows a simple example to convert the yii default login page to french storing the language in cookie.

Step 1:
Create the login.php (login is the category name used) file under /protected/messages/fr which returns the array.
[...]
1 0
5 followers
Viewed: 38 163 times
Version: 1.1
Category: How-tos
Tags: i18n, Yii
Written by: RKA
Last updated by: CeBe
Created on: Mar 14, 2014
Last updated: 10 years ago
Update Article

Revisions

View all history