availability of labels to plugins

This commit is contained in:
severoiuliano@gmail.com 2020-06-15 09:43:10 +02:00
parent c26cf7711d
commit 8b33c09f62

View file

@ -28,7 +28,7 @@ class TwigLanguageExtension extends \Twig_Extension
}
public function translate( $label )
public function translate( $label, $labels_from_plugin = NULL )
{
// replaces spaces, dots, comma and dash with underscores
$string = str_replace(" ", "_", $label);
@ -40,7 +40,11 @@ class TwigLanguageExtension extends \Twig_Extension
$string = strtoupper( $string );
//translates the string
$translated_label = isset($this->labels[$string]) ? $this->labels[$string] : null;
if(isset($labels_from_plugin)){
$translated_label = isset($labels_from_plugin[$string]) ? $labels_from_plugin[$string] : null;
} else {
$translated_label = isset($this->labels[$string]) ? $this->labels[$string] : null;
}
// if the string is not present, set the original string
if( empty($translated_label) ){