mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-12-16 05:20:31 +01:00
Fixed login/logout message translations.
This commit is contained in:
@@ -107,7 +107,7 @@ class Admin
|
|||||||
$language = $this->grav['uri']->param('lang');
|
$language = $this->grav['uri']->param('lang');
|
||||||
if (!$language) {
|
if (!$language) {
|
||||||
if (!$this->session->admin_lang) {
|
if (!$this->session->admin_lang) {
|
||||||
$this->session->admin_lang = $this->grav['language']->getLanguage();
|
$this->session->admin_lang = $this->grav['language']->getLanguage();
|
||||||
}
|
}
|
||||||
$language = $this->session->admin_lang;
|
$language = $this->session->admin_lang;
|
||||||
}
|
}
|
||||||
@@ -187,6 +187,9 @@ class Admin
|
|||||||
/** @var Grav $grav */
|
/** @var Grav $grav */
|
||||||
$grav = $this->grav;
|
$grav = $this->grav;
|
||||||
|
|
||||||
|
unset($this->grav['user']);
|
||||||
|
$this->grav['user'] = $user;
|
||||||
|
|
||||||
$this->setMessage($this->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info');
|
$this->setMessage($this->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info');
|
||||||
$grav->redirect($post['redirect']);
|
$grav->redirect($post['redirect']);
|
||||||
}
|
}
|
||||||
@@ -950,18 +953,27 @@ class Admin
|
|||||||
*
|
*
|
||||||
* @param array|mixed $args
|
* @param array|mixed $args
|
||||||
*
|
*
|
||||||
|
* @param mixed $languages
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function translate($args)
|
public function translate($args, $languages = null)
|
||||||
{
|
{
|
||||||
if (is_array($args)) {
|
if (is_array($args)) {
|
||||||
$lookup = array_shift($args);
|
$lookup = array_shift($args);
|
||||||
|
if (!empty($args)) {
|
||||||
|
$languages = array_shift($args);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$lookup = $args;
|
$lookup = $args;
|
||||||
$args = [];
|
$args = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$languages = [$this->grav['user']->authenticated ? $this->grav['user']->language : ($this->grav['language']->getLanguage() ?: 'en')];
|
if (!$languages) {
|
||||||
|
$languages = [$this->grav['user']->authenticated ? $this->grav['user']->language : ($this->grav['language']->getLanguage() ?: 'en')];
|
||||||
|
} else {
|
||||||
|
$languages = (array) $languages;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($lookup) {
|
if ($lookup) {
|
||||||
if (empty($languages) || reset($languages) == null) {
|
if (empty($languages) || reset($languages) == null) {
|
||||||
|
|||||||
@@ -269,9 +269,10 @@ class AdminController
|
|||||||
*/
|
*/
|
||||||
protected function taskLogout()
|
protected function taskLogout()
|
||||||
{
|
{
|
||||||
|
$language = $this->grav['user']->authenticated ? $this->grav['user']->language : ($this->grav['language']->getLanguage() ?: 'en');
|
||||||
|
|
||||||
$this->admin->session()->invalidate()->start();
|
$this->admin->session()->invalidate()->start();
|
||||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.LOGGED_OUT'), 'info');
|
$this->setRedirect('/logout/lang:'.$language);
|
||||||
$this->setRedirect('/logout');
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
<h1>
|
<h1>
|
||||||
{{ title }}
|
{{ title }}
|
||||||
</h1>
|
</h1>
|
||||||
{{ admin.setMessage('PLUGIN_ADMIN.LOGGED_OUT'|tu) }}
|
{{ dump (uri.param('lang')) }}
|
||||||
|
{{ admin.setMessage('PLUGIN_ADMIN.LOGGED_OUT'|tu(uri.param('lang'))) }}
|
||||||
{% include 'partials/messages.html.twig' %}
|
{% include 'partials/messages.html.twig' %}
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user