mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-01-03 06:10:52 +01:00
Fix getting the site languages
This commit is contained in:
@@ -594,6 +594,11 @@ class Admin
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the languages available in the admin
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function adminLanguages()
|
||||
{
|
||||
$languages = [];
|
||||
@@ -604,6 +609,22 @@ class Admin
|
||||
return $languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the languages available in the site
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function siteLanguages()
|
||||
{
|
||||
$languages = [];
|
||||
$lang_data = Grav::instance()['config']->get('system.languages.supported', []);
|
||||
|
||||
foreach ($lang_data as $index => $lang) {
|
||||
$languages[$lang] = LanguageCodes::getNativeName($lang);
|
||||
}
|
||||
return $languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static helper method to return current route.
|
||||
*
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
</button>
|
||||
<ul class="dropdown-menu language-switcher">
|
||||
{% for language in admin.languages_enabled %}
|
||||
<li><a class="button {% if admin_lang == language %}active{% endif %}" href="{{ base_url_relative }}{{ theme.slug }}/pages/task{{ config.system.param_sep }}switchlanguage/lang{{ config.system.param_sep }}{{language}}">{{ admin.adminLanguages[language] }}</a></li>
|
||||
<li><a class="button {% if admin_lang == language %}active{% endif %}" href="{{ base_url_relative }}{{ theme.slug }}/pages/task{{ config.system.param_sep }}switchlanguage/lang{{ config.system.param_sep }}{{language}}">{{ admin.siteLanguages[language] }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user