Skip to main content
Category:

In Drupal 8, you can put text in certain defined places in various YML files, and it will be picked up as translatable strings and translated automatically:

Module names and descriptions in *.info.yml files are still found as translatable in /admin/config/regional/translate.

_title (coupled with optional _title_context) key values under the defaults section of *.routing.yml files are found in translatable in /admin/config/regional/translate.

title (coupled with optional title_context) key values in *.links.action.yml*.links.task.yml and *.links.contextual.yml files are found as translatable in /admin/config/regional/translate.

That these strings are found as translatable (and later on t()-ed in the process of handling them) also means that any code generating them dynamically should take care of not translating them too soon.

For example, if you need dynamic titles in your local tasks or actions, extend the base class and override the getTitle() method to run the translation the right way.

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook