1 | <?php |
||
23 | class Translator |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * Hook class instance |
||
28 | * @var \gplcart\core\Hook $hook |
||
29 | */ |
||
30 | protected $hook; |
||
31 | |||
32 | /** |
||
33 | * Module class instance |
||
34 | * @var \gplcart\core\Module $module |
||
35 | */ |
||
36 | protected $module; |
||
37 | |||
38 | /** |
||
39 | * Translation UI model class instance |
||
40 | * @var \gplcart\core\models\Translation $translation |
||
41 | */ |
||
42 | protected $translation; |
||
43 | |||
44 | /** |
||
45 | * @param Hook $hook |
||
46 | * @param Module $module |
||
47 | * @param TranslationModel $translation |
||
48 | */ |
||
49 | public function __construct(Hook $hook, Module $module, TranslationModel $translation) |
||
55 | |||
56 | /** |
||
57 | * Returns an array of information about the translation file |
||
58 | * @param string $file |
||
59 | * @return array |
||
60 | */ |
||
61 | public function getFileInfo($file) |
||
83 | |||
84 | /** |
||
85 | * Copy a translation file |
||
86 | * @param string $source |
||
87 | * @param string $destination |
||
88 | * @return boolean |
||
89 | */ |
||
90 | public function copy($source, $destination) |
||
109 | |||
110 | /** |
||
111 | * Deletes a translation file |
||
112 | * @param string $file |
||
113 | * @param string $langcode |
||
114 | * @return boolean |
||
115 | */ |
||
116 | public function delete($file, $langcode) |
||
133 | |||
134 | /** |
||
135 | * Whether the translation file can be deleted |
||
136 | * @param string $file |
||
137 | * @param string $langcode |
||
138 | * @return bool |
||
139 | */ |
||
140 | public function canDelete($file, $langcode) |
||
144 | |||
145 | /** |
||
146 | * Whether the file is a translation file |
||
147 | * @param string $file |
||
148 | * @param string $langcode |
||
149 | * @return bool |
||
150 | */ |
||
151 | public function isTranslationFile($file, $langcode) |
||
157 | |||
158 | /** |
||
159 | * Returns a module ID from the translation file path |
||
160 | * @param string $file |
||
161 | * @return string |
||
162 | */ |
||
163 | public function getModuleIdFromPath($file) |
||
174 | |||
175 | /** |
||
176 | * Ensure that directory exists and contains no the same file |
||
177 | * @param string $file |
||
178 | * @throws RuntimeException |
||
179 | */ |
||
180 | protected function prepareDirectory($file) |
||
192 | |||
193 | /** |
||
194 | * Returns a total number of translated strings |
||
195 | * @param array $lines |
||
196 | * @return integer |
||
197 | */ |
||
198 | protected function countTranslated(array $lines) |
||
210 | |||
211 | /** |
||
212 | * Fix html strings in the translation file |
||
213 | * @param string $file |
||
214 | * @param array $fixed_strings |
||
215 | * @return array |
||
216 | */ |
||
217 | public function getFixedStrings($file, array &$fixed_strings = array()) |
||
234 | |||
235 | /** |
||
236 | * Tries to fix invalid HTML |
||
237 | * @param string $string |
||
238 | * @return boolean|string |
||
239 | */ |
||
240 | public function fixHtmlString($string) |
||
260 | |||
261 | } |
||
262 |