mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-06 07:17:16 +02:00
Reworked Admin JS with ES6
This commit is contained in:
@@ -571,7 +571,7 @@ class AdminPlugin extends Plugin
|
||||
$this->theme = $this->config->get('plugins.admin.theme', 'grav');
|
||||
|
||||
$assets = $this->grav['assets'];
|
||||
$translations = 'if (!window.translations) window.translations = {}; ' . PHP_EOL . 'window.translations.PLUGIN_ADMIN = {};' . PHP_EOL;
|
||||
$translations = 'this.GravAdmin = this.GravAdmin || {}; if (!this.GravAdmin.translations) this.GravAdmin.translations = {}; ' . PHP_EOL . 'this.GravAdmin.translations.PLUGIN_ADMIN = {';
|
||||
|
||||
// Enable language translations
|
||||
$translations_actual_state = $this->config->get('system.languages.translations');
|
||||
@@ -597,13 +597,16 @@ class AdminPlugin extends Plugin
|
||||
'DAYS',
|
||||
'PAGE_MODES',
|
||||
'PAGE_TYPES',
|
||||
'ACCESS_LEVELS'
|
||||
'ACCESS_LEVELS',
|
||||
'NOTHING_TO_SAVE'
|
||||
];
|
||||
|
||||
foreach($strings as $string) {
|
||||
$translations .= 'translations.PLUGIN_ADMIN.' . $string .' = "' . $this->admin->translate('PLUGIN_ADMIN.' . $string) . '"; ' . PHP_EOL;;
|
||||
$separator = (end($strings) === $string) ? '' : ',';
|
||||
$translations .= '"' . $string .'": "' . $this->admin->translate('PLUGIN_ADMIN.' . $string) . '"' . $separator;
|
||||
}
|
||||
|
||||
$translations .= '};';
|
||||
// set the actual translations state back
|
||||
$this->config->set('system.languages.translations', $translations_actual_state);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user