any suggestions for template translator???

5 years ago

alnux
Member | 106
+
0
-

How can i set templates views according to the language that is use on the client browser.

my folders structure is

templates
    es
      HomePage
      Paises
    en
      HomePage
      Paises
    cz
      HomePage
      Paises

I know that i can use NetteTranslator scrpipt with help of httpRequest service, but there are images or large paragraphs that is much better had on views that in a translator file.

Thanks for the help

5 years ago

Tomáš Votruba
Moderator | 1154
+
0
-

Just overload formatTemplateFiles in your BasePresenter.

Into sth like this:

public function formatTemplateFiles()
{
    $files = parent::formatTemplateFiles()
    $lang = $this->getLang();

    $name = $this->getName();
    $presenter = substr($name, strrpos(':' . $name, ':'));
    $dir = dirname($this->getReflection()->getFileName());
    $dir = is_dir("$dir/templates") ? $dir : dirname($dir);

    $files[] = "$dir/templates/$lang/$presenter/$this->view.latte";

    return $files;
}

5 years ago

alnux
Member | 106
+
0
-

Really thanks Tomas