Questions tagged [symfony-translator]

13 questions
5
votes
2 answers

Symfony Translatable Enum

My supplier entity has enum property notifyType. Any idea how translate the enum this way? {{ supplier.notifyType|trans }} Unfortunately, use __toString method in Enum is not possible. // error - Enum may not include __toString public function…
Hricer
  • 173
  • 1
  • 8
3
votes
1 answer

Specify source language, if the default_locale is not english

I am working on a website for a French customer. My translations.yml looks like this: framework: default_locale: en translator: default_path: '%kernel.project_dir%/translations' fallbacks: - fr I write everything…
Iter Ator
  • 8,226
  • 20
  • 73
  • 164
2
votes
1 answer

Update Symfony translation files with nested keywords

Symfony has support for nested keyword in translation files, for example: symfony: is: great: Symfony is great amazing: Symfony is amazing has: bundles: Symfony has bundles So now I can use this: {% trans from…
Tomas S.
  • 329
  • 2
  • 9
1
vote
2 answers

Symfony 6 (php8) XLIFF plurals now working

I'm working with Symfony 6.1.1 + php8.1.7 and have a problem with translations (XLIFF) If the translation file is without translation all fine but pluralization won't work correctly with the translation key in the file Translation call in Twig {{…
Dmitriy.Net
  • 1,476
  • 13
  • 24
1
vote
2 answers

How to set the locale on a Symfony CLI command?

I run a multi-language Symfony 4.4 website where the locale is part of the URL. So I have /it/, /fr/ and so on. My routes look like this: /** * @Route({ * "it": "/it/azienda/", * "es": "/es/empresa/" * },…
1
vote
2 answers

Priority on Translation Loader

I use 2 different loader for symfony translations : Yaml basic loader (already implemented). A custom loader who save translations into a db table. The first loader is for developer purpose (having a translation when the code is displayed in…
1
vote
1 answer

Symfony UseLocaleSubscriber and InMemoryUser

I have UserLocaleSubscriber from Symfony documentation for switch locale by user. But my admin user is stored "In memory", and the InMemoryUser class does not have the getLocale() method. How may I run this subscriber only for user User entity. I…
mardon
  • 1,065
  • 1
  • 11
  • 29
1
vote
0 answers

Is there a way to get the absolute number of %count% in a translation?

I'm trying to get a nice formatted string for a datetime interval. Basically I have %count% as -2 for "two days ago", 4 for "in 4 days", 0 for "today", 1 for "tomorrow" and so on. My translation string looks like this: dateinterval: '{0} today|{1}…
Matthias
  • 11
  • 1
1
vote
0 answers

Symfony 4 default_locale is not working on Security library messages

I am building single language Symfony (v4.4.7) application. As I understood from the documentation I need to set framework: default_locale: tr translator: default_path: '%kernel.project_dir%/translations' fallbacks: …
1
vote
2 answers

Symfony 5: Translate form errors

the website I work on was developped in french(FR) and I recently developped the multilingual aspect to translate the website in english(EN), for this, I used the translator bundle. Here are my configs files : translation.yaml services.yaml I also…
Tarumi
  • 31
  • 1
  • 4
0
votes
0 answers

Set Symfony translation domain for whole bundle

Is it possible to set the Symfony default translation domain for the whole bundle? By default a bundle uses the messages domain, which apparently breaks overriding the translations in Symfony > 4 (https://github.com/symfony/symfony/issues/40014).…
tobias47n9e
  • 2,233
  • 3
  • 28
  • 54
0
votes
0 answers

Symfony 4 - Twig filter "trans" not detected

I have some twig files and inside I use the trans filter, unfortunately I get error like Unknown "trans" filter. when I run bin/console debug:twig --filter trans I can see the filter there, I see even my custom "trans2" filter, which gives me…
Erik Kubica
  • 1,180
  • 3
  • 15
  • 39
-1
votes
2 answers

How to change the user locale with Symfony 4?

I'm trying to change the user locale with Symfony from a field "locale" in the database. I read the Symfony manual (how to sticky a session for example), but nothing works in my application. Translator still gets the default locale... I created…
Alexander
  • 31
  • 1
  • 7