/** * Returns the token parser instances to add to the existing list. * * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances */ public function getTokenParsers() { // best place to set locale I could find, because of how the module loader works // translator is optional to facilitate extraction, use Factory to create in production if ($this->translator) { $locale = $this->translator->getLocale(); putenv('LANG=' . $locale); setlocale(LC_MESSAGES, $locale . ".utf-8"); } return [new TransParser($this->translator)]; }
/** * * * @param string $templateName * @param string $to * @param array $params * @return */ public function __invoke($templateName, $to, array $params = array()) { // set mail language if not given if (!isset($params['language']) && $this->translator) { $params['language'] = \Locale::getPrimaryLanguage($this->translator->getLocale()); } // set root url if not given if (!isset($params['root_url']) && $this->router) { $params['root_url'] = rtrim($this->router->assemble(array('language' => $params['language']), array('name' => 'frontend/index')), '/'); } // $params['to'] = $to; return $this->mailer->sendMail($templateName, $to, $params); }
public function getLocationCode() { return substr($this->translator->getLocale(), 0, 5); }
/** * Prepara as traduções do formulário * @return \Cityware\Form\Adapter\ZendAdapter */ private function prepareTranslator() { //Create the translator $translator = new MvcTranslator(new Translator()); //Add the translation file. Here we are using the Portuguese-Brazilian translation $translator->addTranslationFile('PhpArray', self::$aSession['moduleTranslate'] . $translator->getLocale() . DS . $this->controllerName . DS . $this->getNameIniForm() . '.php', 'default', $translator->getLocale()); $translator->addTranslationFile('PhpArray', self::$aSession['moduleTranslate'] . $translator->getLocale() . DS . "Zend_Validate.php", 'default', $translator->getLocale()); $translator->addTranslationFile('PhpArray', self::$aSession['moduleTranslate'] . $translator->getLocale() . DS . "Zend_Captcha.php", 'default', $translator->getLocale()); //Set the default translator for validators AbstractValidator::setDefaultTranslator($translator); $this->translator = $translator; return $this; }