Skip to content

Commit

Permalink
MDL-63244 core: make mustache retrieve language
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Mar 19, 2019
1 parent ec81914 commit 545e2ab
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/amd/build/templates.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/amd/src/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ define([
args: {
component: component,
template: name,
themename: theme
themename: theme,
lang: $('html').attr('lang').replace(/-/g, '_')
}
});
// Remember the index in the requests list for this template so that
Expand Down
15 changes: 11 additions & 4 deletions lib/classes/output/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public static function load_template_with_dependencies_parameters() {
'component' => new external_value(PARAM_COMPONENT, 'component containing the template'),
'template' => new external_value(PARAM_ALPHANUMEXT, 'name of the template'),
'themename' => new external_value(PARAM_ALPHANUMEXT, 'The current theme.'),
'includecomments' => new external_value(PARAM_BOOL, 'Include comments or not', VALUE_DEFAULT, false)
'includecomments' => new external_value(PARAM_BOOL, 'Include comments or not', VALUE_DEFAULT, false),
'lang' => new external_value(PARAM_LANG, 'lang', VALUE_DEFAULT, null),
]);
}

Expand All @@ -115,13 +116,15 @@ public static function load_template_with_dependencies_parameters() {
* @param string $template The name of the template.
* @param string $themename The name of the current theme.
* @param bool $includecomments Whether to strip comments from the template source.
* @param string $lang moodle translation language, null means use current.
* @return string the template
*/
public static function load_template_with_dependencies(
string $component,
string $template,
string $themename,
bool $includecomments = false
bool $includecomments = false,
string $lang = null
) {
global $DB, $CFG, $PAGE;

Expand All @@ -131,7 +134,8 @@ public static function load_template_with_dependencies(
'component' => $component,
'template' => $template,
'themename' => $themename,
'includecomments' => $includecomments
'includecomments' => $includecomments,
'lang' => $lang
]
);

Expand All @@ -141,7 +145,10 @@ public static function load_template_with_dependencies(
$params['component'],
$params['template'],
$params['themename'],
$params['includecomments']
$params['includecomments'],
[],
[],
$params['lang']
);
$formatdependencies = function($dependency) {
$results = [];
Expand Down
Loading

0 comments on commit 545e2ab

Please sign in to comment.