diff --git a/lib/classes/navigation/output/primary.php b/lib/classes/navigation/output/primary.php index a30fff77dbb..b5ef3245a97 100644 --- a/lib/classes/navigation/output/primary.php +++ b/lib/classes/navigation/output/primary.php @@ -124,6 +124,7 @@ class primary implements renderable, templatable { $currentlang = current_language(); $langs = get_string_manager()->get_list_of_translations(); $nodes = []; + $activelanguage = ''; // Add the lang picker if needed. foreach ($langs as $langtype => $langname) { @@ -137,9 +138,16 @@ class primary implements renderable, templatable { ]; $nodes[] = $node; + + if ($isactive) { + $activelanguage = $langname; + } } - return $nodes; + return [ + 'title' => $activelanguage, + 'items' => $nodes, + ]; } /** diff --git a/theme/boost/layout/columns2.php b/theme/boost/layout/columns2.php index 56e1c5cdd46..a4180cfaef7 100644 --- a/theme/boost/layout/columns2.php +++ b/theme/boost/layout/columns2.php @@ -66,6 +66,7 @@ $templatecontext = [ 'primarymoremenu' => $OUTPUT->more_menu(array_merge($primarymenu['primary'], $primarymenu['custom']), 'navbar-nav'), 'secondarymoremenu' => $secondarynavigation, 'usermenu' => $primarymenu['user'], + 'langmenu' => $primarymenu['lang'], ]; $nav = $PAGE->flatnav; $templatecontext['flatnavigation'] = $nav; diff --git a/theme/boost/scss/moodle/navbar.scss b/theme/boost/scss/moodle/navbar.scss index 3dff5794695..712e2fa4043 100644 --- a/theme/boost/scss/moodle/navbar.scss +++ b/theme/boost/scss/moodle/navbar.scss @@ -74,6 +74,17 @@ } } } + .langmenu { + .dropdown-menu { + .dropdown-item { + &[aria-current="true"]::before { + content: "\f00c"; + font-size: 0.75rem; + padding-left: .25rem; + } + } + } + } .moodle-actionmenu .menubar, .action-menu-trigger .dropdown { height: 100%; diff --git a/theme/boost/style/moodle.css b/theme/boost/style/moodle.css index f3ffa78815a..3af54fd80df 100644 --- a/theme/boost/style/moodle.css +++ b/theme/boost/style/moodle.css @@ -20023,6 +20023,10 @@ div.editor_atto_toolbar button .icon { content: ""; font-size: 0.75rem; padding-left: .25rem; } + .navbar.fixed-top .langmenu .dropdown-menu .dropdown-item[aria-current="true"]::before { + content: "\f00c"; + font-size: 0.75rem; + padding-left: .25rem; } .navbar.fixed-top .moodle-actionmenu .menubar, .navbar.fixed-top .action-menu-trigger .dropdown { height: 100%; diff --git a/theme/boost/templates/language_menu.mustache b/theme/boost/templates/language_menu.mustache new file mode 100644 index 00000000000..1a077980466 --- /dev/null +++ b/theme/boost/templates/language_menu.mustache @@ -0,0 +1,63 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template theme_boost/language_menu + + Language menu template. + + Context variables required for this template: + * title - The title of the menu (displays the text of the currently active language). + * items - Array of data representing the available languages to be displayed in the language menu. + * link - If a link is provided render it. + * title - The title of the language item. + * text - The text displayed for the language item. + * url - The url link to activate the given language. + * isactive - Whether the language is currently active. + + Example context (json): + { + "title": "English (en)", + "items": { + "link": { + "title": "English (en)", + "text": "English (en)", + "url": "http://example.com", + "isactive": 0 + } + } + } +}} +
+ +
diff --git a/theme/boost/templates/navbar.mustache b/theme/boost/templates/navbar.mustache index d3c43f101d7..cbe53db03c0 100644 --- a/theme/boost/templates/navbar.mustache +++ b/theme/boost/templates/navbar.mustache @@ -61,6 +61,9 @@