【问题标题】:How to get missing translations/messages in Symfony 4, in a controller?如何在控制器中获取 Symfony 4 中丢失的翻译/消息?
【发布时间】:2018-09-21 09:10:23
【问题描述】:

我的愿望:在控制器中提取 Symfony 4 中缺失的翻译/消息。

我知道这是可能的,使用命令行。

Extract missing translations with command lines

我所有的翻译都来自我的模板。

我试图加载对象 TranslatorInterface

示例:

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Translation\TranslatorInterface;

public function index(TranslatorInterface $translator)
{
    dump($translator);
}

如果你有一个想法,一个捆绑的目的?

谢谢

【问题讨论】:

  • 恕我直言,在 Symfony 中本机是不可能的。您可以检查命令的代码来自己完成这项工作。这是命令vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php的路径

标签: symfony controller export translation


【解决方案1】:

您正在寻找https://github.com/php-translation/symfony-bundle 我猜?

这带来了许多额外的翻译功能,例如专用编辑器, 许多命令和所需的提取器。

罪魁祸首:它只支持 xliff 格式,但现有的 yaml 可以轻松转换。

【讨论】:

    猜你喜欢
    • 2016-04-23
    • 1970-01-01
    • 2019-08-18
    • 2017-05-20
    • 2015-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    相关资源
    最近更新 更多