Fix getting the site languages

This commit is contained in:
Flavio Copes
2015-08-18 19:44:07 +02:00
parent cb347ee30f
commit 4f3ef359c8
2 changed files with 22 additions and 1 deletions

View File

@@ -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.
*

View File

@@ -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>