Refactor Localizer into a separate class.

This commit is contained in:
marco
2015-08-09 21:44:37 +02:00
parent 62c0f18c03
commit 787ee9f043
2 changed files with 59 additions and 35 deletions

View File

@@ -15,17 +15,12 @@ class Initializer {
$activator = new Activator();
$activator->init();
// localization
$this->setup_textdomain();
add_action(
'init',
array($this, 'localize'),
0
);
$renderer = new Renderer();
$this->renderer = $renderer->init();
$localizer = new Localizer($this->renderer);
$localizer->init();
$menu = new Menu(
$this->renderer,
Env::$assets_url
@@ -85,31 +80,4 @@ class Initializer {
);
wp_enqueue_script($name);
}
public function localize() {
load_plugin_textdomain(
Env::$plugin_name,
false,
dirname(plugin_basename(Env::$file)) . '/lang/'
);
// set rtl flag
$this->renderer->addGlobal('is_rtl', is_rtl());
}
public function setup_textdomain() {
$locale = apply_filters(
'plugin_locale',
get_locale(),
Env::$plugin_name
);
$language_path = Env::$languages_path.'/'.Env::$plugin_name.'-'.$locale.'.mo';
load_textdomain(Env::$plugin_name, $language_path);
load_plugin_textdomain(
Env::$plugin_name,
false,
dirname(plugin_basename(Env::$file)) . '/lang/'
);
}
}