doulai8128 2017-03-01 12:15
浏览 97

我正在尝试将我的模板与“i18n Extension”整合到twig中。 坚持与xgettext集成

The integration works fine. But when I am trying to integrate it with xgettext for template string i get fatal error. There is an error

Fatal error: Uncaught Twig_Error_Loader: Unable to find template "C:/MAMP/htdocs/views/site/blocks/contactform.html" (looked into: C:\MAMP\htdocs/views/site). in C:\MAMP\htdocs\components\twig\Loader\Filesystem.php:232 Stack trace: 0 C:\MAMP\htdocs\components\twig\Loader\Filesystem.php(150): Twig_Loader_Filesystem->findTemplate('C:/MAMP/htdocs/...') #1 C:\MAMP\htdocs\components\twig\Environment.php(329): Twig_Loader_Filesystem->getCacheKey('C:\MAMP\htdocs/...') #2 C:\MAMP\htdocs\components\twig\Environment.php(419): Twig_Environment->getTemplateClass('C:\MAMP\htdocs/...') #3 C:\MAMP\htdocs\controllers\mainController.php(43): Twig_Environment->loadTemplate('C:\MAMP\htdocs/...') #4 C:\MAMP\htdocs\controllers\siteController.php(22): mainController->loadTwig() #5 C:\MAMP\htdocs\componentsouter.php(83): siteController->actionIndex() #6 C:\MAMP\htdocs\index.php(12): Router->Run() #7 {main} thrown in C:\MAMP\htdocs\components\twig\Loader\Filesystem.php on line 232

And here is my code:

class mainController {

  var $twig = null;
  public $configs;
  public $langlibrary;

  const DEFAULT_LANGUAGE = 'en';

  public function __construct() {
    $this->configs = Config::getConfigiration();
  }

  public function loadTwig() {

    require_once 'components/Twig/Autoloader.php';
    Twig_Autoloader::register();

    $tplDir = ROOT.'/views/site';
    $tmpDir = 'cache';
    $loader = new Twig_Loader_Filesystem($tplDir);

    $this->twig = new Twig_Environment($loader, array(
        'cache' => $tmpDir,
        'auto_reload' => true
    ));

    $this->twig->addExtension(new Twig_Extensions_Extension_I18n());

    // THE PROBLEM BEGINS WHEN ADD CODE BELOW FOR INETGRATION
    foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tplDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
    {
        // force compilation
        if ($file->isFile()) {
            $this->twig->loadTemplate(str_replace($tplDir.'/', '', $file));
        }
    }
  • 写回答

1条回答 默认 最新

  • douya6229 2017-04-07 08:56
    关注

    The fault was Windows web development environment in my computer. By the way i tried all of them Wamp, Mamp, Denwer in all of them was this problem. so better use Linux )

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器