Language::translate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
3
/**
4
 * Language
5
 *
6
 * Localization tools.
7
 *
8
 * @package core
9
 * @author [email protected]
10
 * @version 0.1 * @copyright Caffeina srl - 2015 - http://caffeina.it
11
 */
12
13
 class Language extends Dictionary {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
14
    use Module;
15
    protected static $current_lang = 'en';
16
17
    public static function translate($text,$params=null){
18
      $result = static::get(static::$current_lang.'.'.strtolower($text),$text);
19
      return $params ? Text::render($result) : $result;
20
    }
21
22
    public static function using($lang){
23
      static::$current_lang = strtolower(trim($lang));
24
    }
25
26
    public static function load($lang, $dictfile){
27
      ob_start(); $lang = include($dictfile); ob_end_clean();
28
      static::merge([$lang => $dictfile]);
29
    }
30
}
31