-
-
Notifications
You must be signed in to change notification settings - Fork 827
/
JsCompiler.php
46 lines (37 loc) · 993 Bytes
/
JsCompiler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Locale;
use Flarum\Asset\JsCompiler as BaseJsCompiler;
class JsCompiler extends BaseJsCompiler
{
protected $translations = [];
public function setTranslations(array $translations)
{
$this->translations = $translations;
}
public function compile()
{
$output = "
System.register('locale', [], function(_export) {
return {
execute: function() {
_export('default', function(app) {
app.translator.translations = ".json_encode($this->translations).";\n";
foreach ($this->files as $filename) {
$output .= file_get_contents($filename);
}
$output .= '
});
}
};
});';
return $this->format($output);
}
}