Skip to content

Instantly share code, notes, and snippets.

@somatonic
Last active December 11, 2015 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somatonic/4520324 to your computer and use it in GitHub Desktop.
Save somatonic/4520324 to your computer and use it in GitHub Desktop.
textdomain infos
<?php
class TextDomainHelper extends Wire implements Module {
public static function getModuleInfo() {
return array(
'title' => 'TextDomainHelper',
'version' => 1,
'summary' => '',
'href' => '',
'singular' => true,
'autoload' => true
);
}
public function init() {
$this->addHookAfter('LanguageTranslator::getTranslation', $this, 'textDomain');
}
public function textDomain($event) {
if($this->process == "ProcessLanguage") return;
$textdomain = $event->arguments[0];
$text = $event->arguments[1];
//$context = $event->arguments[2];
$translation = $event->return;
$lang = $this->user->language->name;
$root = $this->config->paths->root;
if(!(strpos($textdomain, "/") !== FALSE)){
$textdomain = $this->config->paths->$textdomain . $textdomain . ".module";
}
ChromePhp::log( "Text : " . $text ."\n"
. "Translation : " . $translation . "\n"
. "Textdomain : ".str_replace($root, "/", $textdomain) . "\n"
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment