Created
November 3, 2019 12:22
-
-
Save mauricius/96aeb6986e7eef00869a5ac8fec40677 to your computer and use it in GitHub Desktop.
Helper function to retrieve Textdomain in ProcessWire using TemplateEngineBlade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getViewTextDomain($path) | |
{ | |
$config = wire('config'); | |
$input = str_replace('.', '-', | |
str_replace($config->paths->root, '', $path) | |
); | |
$re = '/\/+/m'; | |
return preg_replace($re, '--', $input); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$view->composer('*', function($view) | |
{ | |
$view->with('textdomain', getViewTextDomain($view->getPath())); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment