File-based translations

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 ...

Get Yii2 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.