Hi everyone,

I am using the Drupal 9 sites which were built using pattern lab structure. When trying to translate the content using translate function t() in .theme file, the translated word from .theme file is not showing up in interface translate search to change it manually.

Can anyone help me with this?

Comments

john_b’s picture

I doubt you can use t() in the .theme file. It is too late in Drupal pipeline.

From the early days of Drupal it has been see as very bad practice to get or modify content in the theme rather than a module, and this is still true of Drupal 9. It was always a standing joke that finding a database query in a theme template was the mark of an incompetent Drupal developer, but that has been made impossible since D8. Theme is for styling, everything else goes in modules.

Whilst the documentation on t() is a bit thin here, it is still useful.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

sai_raj_1’s picture

I have already used translate function t() in the .theme file and everything is working fine but when trying to translate manually on interface translate search, it was not showing up in the search bar.

Can you suggest how to make it visible in the search bar of the interface translate search?

NOTE: It is visible when we use the normal theming Drupal site, the problem occurs only when we use "pattern lab" to build a site

john_b’s picture

I don't know. It does not seem likely to be related to pattern lab. Just have to debug, starting with checking that the function containing the t() is being called at all.

Debugging Drupal > 7 sometimes really needs PHPStorm, which is very helpful for this kind of thing, though unfortunately not free.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors