1

I'm an Angular front-end developer. I work with a team that uses Drupal for content.

The scenario is that we use Drupal.t() to translate the strings.

When I translate the word from the back-office, it works, but I can't see the change on my page. So I tested it with another laptop from a colleague, and it works.

My colleague has drupalTranslations(), which gives him the translated strings.

When I run this function in my browser, it doesn't work. drupalTranslations() is not defined while Drupal and drupalSettings work.

Error Message

Do I have to install something?

FYI: We run the project with Docker (Drupal 9.x).

1
  • do you share a database ? or config ? do you have this module installed "Interface Translation" aka locale ?
    – taggartJ
    Commented Oct 24, 2022 at 0:24

1 Answer 1

0

I'm able to replicate the issue on Drupal 9 with a simple javscript file

console.log(Drupal.t('Comments'))
console.log(Drupal.drupalTranslations('Comments'))

コメント
TypeError: Drupal.drupalTranslations is not a function

There appears to be an open issue (Text in Drupal.t() on some pages is not translated after installing a module [library cache problem]) related to this marked active but without progress since 2018. The issue relates to a caching bug.

I also found drupal-8-react-i18n-and-typescript which might help you along, but if you're using the same code as your colleague, I'm inclined to thing it is the cache bug.

2
  • 2
    Despite the original question being closed for not being detailed enough, you could improve your answer by providing e.g., a link to the open issue(s) you mentioned. This might help the original author of the question more than you just confirming that you can replicate the behavior and found related issues in the Drupal issue queues. Both of you are relatively new in this Drupal Answers group. It lives from to the point questions and answers that provide enough details to gain a solution for both, the original author, as well as future visitors. Commented Oct 24, 2022 at 1:58
  • Thank you Mario. I copied my response to the same question on StackOverflow and it seems the links did not copy over. I updated my original answer with the missing URLs.
    – tyler36
    Commented Oct 25, 2022 at 1:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.