Changes plugin language based on user's locale

This commit is contained in:
Vlad
2017-11-22 20:13:56 -05:00
parent d603d99a04
commit 94c7e2a5c0
2 changed files with 9 additions and 1 deletions

View File

@@ -232,6 +232,7 @@ class Initializer {
$this->setupHooks();
$this->setupJSONAPI();
$this->setupRouter();
$this->setupUserLocale();
} catch(\Exception $e) {
$this->handleFailedInitialization($e);
}
@@ -247,6 +248,13 @@ class Initializer {
$router->init();
}
function setupUserLocale() {
if(get_user_locale() === get_locale()) return;
unload_textdomain(Env::$plugin_name);
$localizer = new Localizer();
$localizer->init();
}
function setupPages() {
$pages = new \MailPoet\Settings\Pages();
$pages->init();

View File

@@ -30,7 +30,7 @@ class Localizer {
function locale() {
$locale = apply_filters(
'plugin_locale',
get_locale(),
get_user_locale(),
Env::$plugin_name
);
return $locale;