Add language switcher see BT#13183

pull/2487/head
jmontoyaa 7 years ago
parent d535d28b27
commit 992b401658
  1. 3
      bower.json
  2. 25
      main/inc/lib/api.lib.php
  3. 8
      main/inc/lib/template.lib.php
  4. 7
      main/install/configuration.dist.php
  5. 55
      main/template/default/layout/login_form.tpl
  6. 12
      main/template/default/layout/menu.tpl

@ -31,7 +31,8 @@
"pwstrength-bootstrap": "*",
"readmore-js": "2.1.0",
"qtip2": "*",
"js-cookie" : "2.1.*"
"js-cookie" : "2.1.*",
"bootstrap-language" : "*"
},
"resolutions": {
"jquery": "2.1.4"

@ -4187,6 +4187,9 @@ function api_display_language_form($hide_if_no_choice = false)
$user_selected_language = api_get_setting('platformLanguage');
}
$currentLanguageId = api_get_language_id($user_selected_language);
$currentLanguageInfo = api_get_language_info($currentLanguageId);
$original_languages = $language_list['name'];
$folder = $language_list['folder']; // This line is probably no longer needed.
$html = '<script>
@ -4203,7 +4206,7 @@ function api_display_language_form($hide_if_no_choice = false)
</script>';
$html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
$html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>';
$html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
/*$html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
foreach ($original_languages as $key => $value) {
if ($folder[$key] == $user_selected_language) {
@ -4215,7 +4218,24 @@ function api_display_language_form($hide_if_no_choice = false)
//echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
$html .= $value.'</option>';
}
$html .= '</select>';
$html .= '</select>';*/
$html .= '<div class="btn-group dropup">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="lang-sm" lang="'.$currentLanguageInfo['isocode'].'"></span>
'.$currentLanguageInfo['original_name'].'
<span class="caret">
</span>
</button>';
$html .= '<ul class="dropdown-menu" role="menu">';
$url = api_get_self();
foreach ($language_list['all'] as $key => $data) {
$urlLink = $url.'?language='.$data['english_name'];
$html .= '<li><a href="'.$urlLink.'"><span class="lang-sm" lang="'.$data['isocode'].'"></span> '.$data['original_name'].'</a></li>';
}
$html .= '</ul>';
$html .= '</div>';
$html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
$html .= '</form>';
return $html;
@ -4237,6 +4257,7 @@ function api_get_languages()
while ($row = Database::fetch_array($result)) {
$language_list['name'][] = $row['original_name'];
$language_list['folder'][] = $row['dokeos_folder'];
$language_list['all'][] = $row;
}
return $language_list;
}

@ -202,6 +202,11 @@ class Template
$this->assign('locale', api_get_language_isocode());
$this->assign('login_class', null);
$allow = api_get_configuration_value('show_language_selector_in_menu');
if ($allow) {
$this->assign('language_form', api_display_language_form());
}
$this->setLoginForm();
// Chamilo plugins
@ -597,7 +602,8 @@ class Template
'jquery.scrollbar/jquery.scrollbar.css',
'bootstrap-daterangepicker/daterangepicker.css',
'bootstrap-select/dist/css/bootstrap-select.min.css',
'select2/dist/css/select2.min.css'
'select2/dist/css/select2.min.css',
'bootstrap-languages/languages.min.css'
];
foreach ($bowerCSSFiles as $file) {

@ -586,6 +586,9 @@ $_configuration['score_grade_model'] = [
// ALTER TABLE gradebook_category ADD COLUMN minimum_to_validate INT DEFAULT NULL;
// $_configuration['gradebook_dependency'] = false;
// Courses id list to check in the gradebook sidebar see BT#13099
$_configuration['gradebook_dependency_mandatory_courses'] = [
/*$_configuration['gradebook_dependency_mandatory_courses'] = [
'courses' => [1, 2]
];
];*/
// Show language selector in main menu
//$_configuration['show_language_selector_in_menu'] = false;

@ -1,36 +1,35 @@
{% if _u.logged == 0 %}
{% if login_form %}
<div id="login_block" class="panel panel-default">
<div class="panel-body">
{{ login_language_form }}
{% if login_form %}
<div id="login_block" class="panel panel-default">
<div class="panel-body">
{{ login_language_form }}
{% if plugin_login_top is not null %}
<div id="plugin_login_top">
{{ plugin_login_top }}
</div>
{% endif %}
{% if plugin_login_top is not null %}
<div id="plugin_login_top">
{{ plugin_login_top }}
</div>
{% endif %}
{{ login_failed }}
{{ login_form }}
{{ login_failed }}
{{ login_form }}
{% if "allow_lostpassword" | api_get_setting == 'true' or "allow_registration" | api_get_setting == 'true' %}
<ul class="nav nav-pills nav-stacked">
{% if "allow_registration" | api_get_setting != 'false' %}
<li><a href="{{ _p.web_main }}auth/inscription.php"> {{ 'SignUp' | get_lang }} </a></li>
{% endif %}
{% if "allow_lostpassword" | api_get_setting == 'true' or "allow_registration" | api_get_setting == 'true' %}
<ul class="nav nav-pills nav-stacked">
{% if "allow_registration" | api_get_setting != 'false' %}
<li><a href="{{ _p.web_main }}auth/inscription.php"> {{ 'SignUp' | get_lang }} </a></li>
{% endif %}
{% if "allow_lostpassword" | api_get_setting == 'true' %}
<li><a href="{{ _p.web_main }}auth/lostPassword.php"> {{ 'LostPassword' | get_lang }} </a></li>
{% endif %}
</ul>
{% endif %}
{% if "allow_lostpassword" | api_get_setting == 'true' %}
<li><a href="{{ _p.web_main }}auth/lostPassword.php"> {{ 'LostPassword' | get_lang }} </a></li>
{% endif %}
</ul>
{% endif %}
{% if plugin_login_bottom is not null %}
<div id="plugin_login_bottom">
{{ plugin_login_bottom }}
{% if plugin_login_bottom is not null %}
<div id="plugin_login_bottom">
{{ plugin_login_bottom }}
</div>
{% endif %}
</div>
{% endif %}
</div>
</div>
{% endif %}
{% endif %}
{% endif %}

@ -1,4 +1,3 @@
<nav id="menubar" class="navbar navbar-default">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
@ -36,18 +35,25 @@
});
});
</script>
<ul class="nav navbar-nav navbar-right">
<li id="count_message_li" class="hidden">
<a href="{{ message_url }}">
<span id="count_message" class="badge badge-warning"></span>
</a>
</li>
{% if language_form %}
<li class="dropdown language">
{{ language_form }}
</li>
{% endif %}
{% if _u.status != 6 %}
<li class="dropdown avatar-user">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
aria-expanded="false">
<img class="img-circle" src="{{ _u.avatar_small }}" alt="{{ _u.complete_name }}"/>
<span class="username-movil">{{ _u.complete_name }}</span>
<span class="caret"></span>

Loading…
Cancel
Save