Yii 2.0: json-messages

JSON message source: store translations in JSON files.

JSON Messages for Yii

ReleaseLicenseDownloadsCode qualityBuild

JSON message source for Yii, high-performance PHP framework.

This package provides a single class, yii\i18n\JsonMessageSource which is a message source that stores translated messages in JSON files. It extends from PhpMessageSource class, so its usage is basically the same.

Within a JSON file, an object literal of (source, translation) pairs is defined. For example:

  "original message 1": "translated message 1",
  "original message 2": "translated message 2"


The latest PHP and Composer versions. If you plan to play with the sources, you will also need the Phing latest version.

Installing via Composer

From a command prompt, run:

$ composer require cedx/yii2-json-messages

Now in your application configuration file, you can use the following message source:

return [
  'components' => [
    'i18n' => [
      'translations' => [
        '*' => 'yii\i18n\JsonMessageSource'

See Also


JSON Messages for Yii is distributed under the Apache License, version 2.0.

Be the first person to leave a comment

Please to leave your comment.

Create extension