| | 111 | if(!file_exists($file)) |
|---|
| | 112 | throw new Exception('Cannot load the resource '.$file,212); |
|---|
| | 113 | |
|---|
| | 114 | $new_line = true; |
|---|
| | 115 | foreach(explode("\n",file_get_contents($file)) as $linenumber=>$line){ |
|---|
| | 116 | if(strpos($line,'#')===0) |
|---|
| | 117 | continue; |
|---|
| | 118 | |
|---|
| | 119 | if($new_line){ |
|---|
| | 120 | if(!preg_match('#^([^=]+)=(.+)(\\\{1,2})?$#U',$line,$matches)) |
|---|
| | 121 | throw new Exception('Syntax error in localization file "'.$file.'" at line '.($linenumber+1),210); |
|---|
| | 122 | |
|---|
| | 123 | $key = trim($matches[1]); |
|---|
| | 124 | $this->_strings[$charset][$key] = ''; |
|---|
| | 125 | $string_index = 2; |
|---|
| | 126 | $eol_index = 3; |
|---|
| | 127 | } |
|---|
| | 128 | else{ |
|---|
| | 129 | if(!preg_match('#^(.+)(\\\{1,2})?$#U',$line,$matches)) |
|---|
| | 130 | throw new Exception('Syntax error in localization file "'.$file.'" at line '.($linenumber+1),210); |
|---|
| | 131 | |
|---|
| | 132 | $string_index = 1; |
|---|
| | 133 | $eol_index = 2; |
|---|
| | 134 | } |
|---|
| | 135 | |
|---|
| | 136 | |
|---|
| | 137 | $string = html_entity_decode(ltrim($matches[$string_index]),ENT_COMPAT,$charset); |
|---|
| | 138 | $new_line = true; |
|---|
| | 139 | if(isset($matches[$eol_index])){ |
|---|
| | 140 | $new_line = false; |
|---|
| | 141 | if(strlen($matches[$eol_index]) == 2) |
|---|
| | 142 | $string .= "\n"; |
|---|
| | 143 | else |
|---|
| | 144 | $string .= ' '; |
|---|
| | 145 | } |
|---|
| | 146 | $this->_strings[$charset][$key] .= $string; |
|---|
| | 147 | |
|---|
| | 148 | } |
|---|
| | 149 | /* |
|---|