Last active
December 11, 2015 00:59
-
-
Save somatonic/4520324 to your computer and use it in GitHub Desktop.
textdomain infos
This file contains 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
<?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