8000 Fatal error: translations in templates without installed translator · Issue #31754 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fatal error: translations in templates without installed translator #31754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MMagicM opened this issue May 30, 2019 · 1 comment
Closed

Fatal error: translations in templates without installed translator #31754

MMagicM opened this issue May 30, 2019 · 1 comment

Comments

@MMagicM
Copy link
MMagicM commented May 30, 2019

Symfony version(s) affected: 4.3.0

Description
Using trans filters in twig templates without the translator installed results in a fatal error instead of just displaying the string to translate (as was the case in every other version I used before).

How to reproduce
Do the following:

  1. composer create-project symfony/skeleton
  2. composer require symfony/twig-bundle
  3. composer require annotations
  4. Make a controller that renders the base.html.twig
  5. In the base.html.twig insert {{ 'test'|trans }}

Additional context
Stack Trace:
[Thu May 30 23:11:55.906614 2019] [php7:error] [pid 24356:tid 2000] [client ::1:53977] PHP Fatal error: Trait 'Symfony\Contracts\Translation\TranslatorTrait' not found in C:\xampp\htdocs\project2\vendor\symfony\twig-bridge\Extension\TranslationExtension.php on line 113
2019-05-30T23:11:55+02:00 [critical] Fatal Error: Trait 'Symfony\Contracts\Translation\TranslatorTrait' not found
2019-05-30T23:11:56+02:00 [critical] Uncaught PHP Exception Symfony\Component\Debug\Exception\ClassNotFoundException: "Attempted to load trait "TranslatorTrait" from namespace "Symfony\Contracts\Translation".
Did you forget a "use" statement for another namespace?" at C:\xampp\htdocs\project2\vendor\symfony\twig-bridge\Extension\TranslationExtension.php line 113

@nicolas-grekas
Copy link
Member

Try running composer require symfony/translation-contracts
This is what I'm suggesting in #31761

@javiereguiluz javiereguiluz added this to the 4.3 milestone May 31, 2019
@fabpot fabpot closed this as completed Jun 1, 2019
fabpot added a commit that referenced this issue Jun 1, 2019
…nExtension is used (nicolas-grekas)

This PR was merged into the 4.3 branch.

Discussion
----------

[TwigBridge] suggest Translation Component when TranslationExtension is used

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31754
| License       | MIT
| Doc PR        | -

Commits
-------

d4a9e7e [TwigBridge] suggest Translation Component when TranslationExtension is used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0