gpt4 book ai didi

Symfony 4.4 翻译界面问题

转载 作者:行者123 更新时间:2023-12-01 22:00:31 25 4
gpt4 key购买 nike

最近将应用程序从 Symfony 4.3 升级到 4.4,并且在生产中我遇到了 Symfony Translator 界面问题

配置:

framework:
default_locale: pl
translator:
default_path: '%kernel.project_dir%/translations'

错误:

Fatal error: Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale) in ./vendor/symfony/translation/TranslatorInterface.php on line 24
Fatal error: Declaration of Symfony\Component\Translation\Translator::trans($id, array $parameters = Array, $domain = NULL, $locale = NULL) must be compatible with Symfony\Contracts\Translation\TranslatorInterface::trans(string $id, array $parameters = Array, ?string $domain = NULL, ?string $locale = NULL) in ./vendor/symfony/translation/Translator.php on line 32

最佳答案

我发现降级到 symfony:translation-contracts:1.1.6 对我有用。
Composer 自动安装了该软件包的 2.0.0 版本,该版本利用了类型提示。
1.1.6 版本不兼容,但使 Translator 类再次兼容。
它不使用打字提示。

在我的 composer.json 文件中,我将版本修复为 1.1.6:

"require": {
"php": ">=7.3",
"symfony/translation": "^4.4",
"symfony/translation-contracts": "1.1.6"
}

附注还有更多依赖项,但为了可读性我省略了它们

关于Symfony 4.4 翻译界面问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59007287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com