0

I'm creating CakePHP 3 localized app and want to generate all backend part with bake for multiple languages. I'm already familiar with i18n shell and .po files, I have used cakephp/localized and it's ok. It have translations of cake core for many languages. But one i can't get a glue is how to translate templates generated by bake? It's bunch of similar strings like

The group has been deleted
The user has been deleted
The item has been deleted

and so on. I want to translate all pattern "The {0} has been deleted" once but not for every single entity.

Am i missing something important?

Yaroslav
  • 2,338
  • 26
  • 37
  • 1
    That's not necessarily a good idea, as there are languages that for example require using different structures or gendered articles depending on the noun. – ndm Jul 12 '19 at 14:50
  • @ndm it's all can be handled with gettext – Yaroslav Jul 12 '19 at 15:38
  • How? If all you have is the message `The {0} has been deleted`, how would you create different translations depending on what `{0}` is? – ndm Jul 12 '19 at 15:54
  • @ndm `The {0} has been deleted` it's just example, it can be anything. But now i have to translate same string again and again for each new controller. Also i need to translate same entity title thousand times in each string. – Yaroslav Jul 12 '19 at 16:05
  • Well, my point is that it's not the same message. If it were the same (and it wouldn't be used in multiple different context's), then you'd only have to translate it once, because it would only appear once in the extracted `.pot` file. The messages are similar, but similar doesn't mean that you can just dumb it down to identical messages. Some things just cannot be simplified, you're going to create huge problems for translators if you make values like that dynamic. – ndm Jul 12 '19 at 17:11
  • @ndm it's wery beginning and i have only 4 controllers and there are almost 500 lines in .pot file and i have to translate strings like User Id, Company Id, Group Id, Related Users, Related Companies etc. etc. Is it looks OK? – Yaroslav Jul 12 '19 at 20:19
  • 500 lines or 500 messages? 500 message for 4 controllers/templates would surely be possible if you have enough associations and columns. If it's 500 lines, then lots of these lines are probably comments. Generally having stuff like "Company Id", "Group Id", etc in there is OK/expected, whether that's useful for your application is another question. – ndm Jul 12 '19 at 20:51
  • 1
    Ideally you should edit your baked code accordingly before you extract the messages, the default bake output is really just a starting point. For applications with lots or (re)baking (especially large ones), you might want to create custom bake templates that produce a more final output, see **https://book.cakephp.org/bake/1.x/en/development.html**. – ndm Jul 12 '19 at 20:51

0 Answers0