This is the most simple way to translate text messages from one language to another. Basically, there are one or more files for each language containing keywords with text representations; we will put these keywords in the source code where the framework will replace them with text.
The pairs of keyword-text translations are grouped by categories representing the filenames where they are stored. These pairs are array keys-values, where key indicates keywords, and value indicates text translations.
By default, the path folder containing translations for a specific language is in @app/messages/<language>/<category>.php
. Therefore, if we are writing translations for the app
category and the en-US
language, for example, the complete path for the translation file will be in @app/messages/en-US/app.php
.
Going to the source code, translations are activated using the Yii::t()
static method that accepts four parameters, but only the first two are required; the first...