/** * Inspect the supplied source, capture gettext references as a PoFile object. * * @param string $source php source code * @param string $refname source identification used for PO reference comments * * @return PoFile */ public function msginitString($source, $refname) { if (!$this->poFile instanceof PoFile) { $this->poFile = new PoFile(); } $tpl = $this->smarty->createTemplate('eval:' . $source); $tags = $this->smarty->getTags($tpl); $translateTags = array_merge($this->gettextTags, $this->pgettextTags, $this->ngettextTags); foreach ($tags as $tag) { if (in_array($tag[0], $translateTags)) { $entry = new PoEntry(); $haveEntry = false; $entry->add(PoTokens::REFERENCE, $refname); foreach ($tag[1] as $temp) { foreach ($temp as $key => $value) { if ($value[0] == "'" || $value[0] == '"') { if (in_array($key, $this->msgidArgNames)) { $entry->set(PoTokens::MESSAGE, $this->escapeForPo($value)); $haveEntry = true; } elseif (in_array($key, $this->msgidPluralArgNames)) { $entry->set(PoTokens::PLURAL, $this->escapeForPo($value)); } elseif (in_array($key, $this->msgctxtArgNames)) { $entry->set(PoTokens::CONTEXT, $this->escapeForPo($value)); } } } } if ($haveEntry) { $this->checkPhpFormatFlag($entry); $this->poFile->mergeEntry($entry); } } } return $this->poFile; }