是否可以让 TWIG 使用 YAML 文件翻译模板

Is it possible to have TWIG translate the templates using YAML files

我有一个带有普通 PHP 站点的 TWIG 模板,我想加载翻译后的 YAML 文件,就像我处理类似的 Silex 项目一样。但是,除了 gettext 之外,我在 Twig 文档中没有看到任何关于翻译的内容,而且我不明白如何将 Symfony YamlFileLoader 添加到纯 Twig 中。

这可能吗,还是 gettext 是唯一的方法?

翻译不是 Twig 的一部分。

Silex 使用 Symfony2 Translation Component which provides support for translations in YAML files. You must install and configure that component and then register twig extension so you can use it in Twig. Twig integration for translation component is part of TwigBridge.