Skip to content

Instantly share code, notes, and snippets.

@mauricius
Created November 3, 2019 12:22
Show Gist options
  • Save mauricius/96aeb6986e7eef00869a5ac8fec40677 to your computer and use it in GitHub Desktop.
Save mauricius/96aeb6986e7eef00869a5ac8fec40677 to your computer and use it in GitHub Desktop.
Helper function to retrieve Textdomain in ProcessWire using TemplateEngineBlade
function getViewTextDomain($path)
{
$config = wire('config');
$input = str_replace('.', '-',
str_replace($config->paths->root, '', $path)
);
$re = '/\/+/m';
return preg_replace($re, '--', $input);
}
$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