3
votes

According to the symfony docs, in order for the translation service to work, you need to create a resource with one of the known valid extension for this thing, resulting in a format like: domain.locale.extension . Symfony code looks for a 'messages' domain as default and if you want to organize those translation better, you can specify the new domain in the third argument of the function trans(). And here is where i'm a bit confused.I read somewhere(can't remember where) that is a better practice to divide your translation catalog in multiple files like

  • labels.en.xlf
  • labels.ro.xlf
  • options.en.xlf
  • options.ro.xlf
  • messages.en.xlf
  • messages.ro.xlf

I'm creating a file for each purpose so it can be organized, but here's the problem... for now i have only 2 languages, further i'm planning on adding all of them.Also,for now i got only 3 domains, but further i will surely add more. This will result in tons on files, but isn't that a bit nasty for performance? I mean, it may be a better practice to organize it in multiple files but symfony will have to load all of those files which will affect the performance for sure, but if i'll keep just the 'messages' domain and add every translation inside it wouldn't be better? Another thing is the syntax of the trans() function.Is much better to call it like this:

$translator->trans('translation.id');

than this:

$translator->trans('translation.id', array(), 'theNewDomain');

What are your thoughts on this?

1

1 Answers

1
votes

the files are only loaded once via cache:warmup see var/cache/{env}/translations/

then you only have one catalog per locale.