2

I've a problem about string translations.

I've built a multi-language site and in a custom module, in a JS file, I've used the function t() to make translatable some strings. These strings appear in /admin/config/regional/translate and I'm able to edit their value, but then, after cleared cache when I visit the site I see the strings not translated.

The strangest things is that for other elements the system works. I'm not able to debug this, my apache error and access logs are clear, nothing also in the message log of Drupal.

Anyone can help me? Thank u in advance

  • Hey hey, please show us some of your JS code. And your *.libraries.yml. And please verify as suggested below, if using Drupal.t() fixed it for you. – leymannx May 31 '18 at 10:07
3

Which string you want to translate before that you can use Drupal.t

like

var optionsList = '<option value="" selected>' + Drupal.t('Navigate...') + '</option>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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