O'Reilly logo

Mastering Yii by Charles R. Portwood II

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Message translations

Yii2's message translation service translates a given text message from the source language to another by looking up the message to be translated in a message source file. If a message is found in a source for the target language, that string is returned instead of the original message. If the translated text is not found, Yii2 will return the original message.

The use of Yii2's message translation service is extremely straightforward. The first step toward translating messages in Yii2 is to wrap any and all messages you want translated in the Yii::t() static method, which can be called as follows:

Yii::t('app', 'My message to be translated');

The first parameter indicates the category we want to store our messages in, and the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required