Skip to content

Commit bfbf316

Browse files
author
Francis Gonzales
committed
add plugin lang to templates
1 parent daa94d7 commit bfbf316

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

main/inc/lib/internationalization.lib.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,6 +3315,7 @@ function api_is_valid_date($date, $format = 'Y-m-d H:i:s') {
33153315
$d = DateTime::createFromFormat($format, $date);
33163316
return $d && $d->format($format) == $date;
33173317
}
3318+
33183319
/**
33193320
* Return the encoding country code for jquery datepicker
33203321
* used for exemple in main/exercice/exercise_report.php
@@ -3331,6 +3332,16 @@ function get_datepicker_langage_code() {
33313332
return $languaje;
33323333
}
33333334

3335+
/**
3336+
* Returns the variable translated
3337+
* @param $variable the string to translate
3338+
* @param $pluginName the Plugin name
3339+
* @return string the variable translated
3340+
*/
3341+
function get_plugin_lang($variable, $pluginName) {
3342+
eval("\$plugin = {$pluginName}::create();");
3343+
return $plugin->get_lang($variable);
3344+
}
33343345
/**
33353346
* Functions for internal use behind this API
33363347
*/

main/inc/lib/template.lib.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public function __construct(
9191

9292
$this->twig = new Twig_Environment($loader, $options);
9393

94+
$this->twig->addFilter('get_plugin_lang', new Twig_Filter_Function('get_plugin_lang'));
9495
$this->twig->addFilter('get_lang', new Twig_Filter_Function('get_lang'));
9596
$this->twig->addFilter('get_path', new Twig_Filter_Function('api_get_path'));
9697
$this->twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting'));

0 commit comments

Comments
 (0)