Completed
Push — master ( da1f74...50e111 )
by mehdi
02:38
created

Lang::setConfig()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 27
rs 8.5806
cc 4
eloc 7
nc 4
nop 1
1
<?php namespace Datium\Tools;
2
3
/************************************************************
4
 * Lang class tranlate every expresion according to lang
5
 ************************************************************
6
 *
7
 * table in lang folder
8
 * @since Aug, 21 2015
9
 *
10
 *\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
11
 */
12
class Lang {
13
14
    /**
15
     * Store language table
16
     * @var array
17
     */
18
    protected static $langTable;
19
20
    /**
21
     * Language translated words
22
     * @var array
23
     */
24
    protected static $config;
25
26
    protected static $obj;
27
28
    /************************************************************
29
     * Return translated expression
30
     ************************************************************
31
     *
32
     * @since Aug, 21 2015
33
     * @param text string
34
     * @return mixed
35
     *
36
     *\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
37
     */
38
    public static function setConfig( $language ) {
39
40
      /**
41
       * Fetch translated file to config attribute
42
       */
43
       self::$config = include('src/CalendarSettings/Jalali.php');
44
45
       /**
46
        * Fetch translated expression to langTable attribute
47
        */
48
       self::$langTable = include('lang/' . $language . '/general.php');
49
50
       foreach( self::$langTable as $key => $translate ){
51
52
         if ( isset( self::$config[ $key ] ) ) {
53
54
           if ( self::$config[ $key ] ) {
55
56
             self::$config[ $key ] = $translate;
57
58
           }
59
60
         }
61
62
       }
63
64
    }
65
66
    public static function getConfig() {
67
68
      return self::$config;
69
70
    }
71
72
}
73