Module::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace monsterhunter\yii2\log;
4
5
use yii;
6
use yii\base\Module as BaseModule;
7
8
/**
9
 * portal module definition class
10
 */
11
class Module extends BaseModule
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public $controllerNamespace = 'monsterhunter\yii2\log\controllers';
17
18
    /**
19
     *
20
     * @var string source language for translation
21
     */
22
    public $sourceLanguage = 'en-US';
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function init()
28
    {
29
        parent::init();
30
        $this->registerTranslations();
31
    }
32
33
    /**
34
     * Registers the translation files
35
     */
36
    protected function registerTranslations()
37
    {
38
        Yii::$app->i18n->translations['monsterhunter/yii2/log/*'] = [
39
            'class' => 'yii\i18n\PhpMessageSource',
40
            'sourceLanguage' => $this->sourceLanguage,
41
            'basePath' => __DIR__ . '/messages',
42
            'fileMap' => [
43
                'monsterhunter/yii2/log/log' => 'log.php',
44
            ],
45
        ];
46
    }
47
48
    /**
49
     * Translates a message. This is just a wrapper of Yii::t
50
     *
51
     * @see Yii::t
52
     *
53
     * @param $category
54
     * @param $message
55
     * @param array $params
56
     * @param null $language
57
     * @return string
58
     */
59
    public static function t($category, $message, $params = [], $language = null)
60
    {
61
        return Yii::t('monsterhunter/yii2/log/' . $category, $message, $params, $language);
62
    }
63
}
64