Description
Symfony version(s) affected: 5.2-dev
Description
The translation using the trans
filter dont work on twig files.
It will returns the translation key.
How to reproduce
I setup a new project and followed the instructions of the documentation.
I changed the default and fallback loclae in the translation.yaml
config to de
.
I created a trabnslations file called messages.de.yaml
.
On my Twig template i have as example {{ 'menu.topnav.language.german'|trans }}
and on my translation file
menu:
topnav:
language:
english: 'Englisch'
german: 'Deutsch'
But the translation on the twig template dont work.
On controllers the translation works as excepted using the TranslatorInterface
e.g. die($translator->trans('menu.topnav.language.german'));
will output Deutsch
.
I also have installed the symfony/translation
package. The composer.lock contains this:
{
"name": "symfony/translation",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "a0485e88a72439c04c86e21e19e3f8540cc5898c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/a0485e88a72439c04c86e21e19e3f8540cc5898c",
"reference": "a0485e88a72439c04c86e21e19e3f8540cc5898c",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "^1.15",
"symfony/translation-contracts": "^2"
},
"conflict": {
"symfony/config": "<4.4",
"symfony/dependency-injection": "<5.0",
"symfony/http-kernel": "<5.0",
"symfony/twig-bundle": "<5.0",
"symfony/yaml": "<4.4"
},
"provide": {
"symfony/translation-implementation": "2.0"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "^4.4|^5.0",
"symfony/console": "^4.4|^5.0",
"symfony/dependency-injection": "^5.0",
"symfony/finder": "^4.4|^5.0",
"symfony/http-kernel": "^5.0",
"symfony/intl": "^4.4|^5.0",
"symfony/service-contracts": "^1.1.2|^2",
"symfony/yaml": "^4.4|^5.0"
},
"suggest": {
"psr/log-implementation": "To use logging capability in translator",
"symfony/config": "",
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.2-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Translation\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2020-06-30T17:42:41+00:00"
}
My translation.yaml:
framework:
default_locale: de
translator:
default_path: '%kernel.project_dir%/translations'
fallbacks:
- de