According to the documentation, we can use contexts with Drupal.t() since Drupal 8.

Drupal.t('May', {}, {context: "Long month name"}); works fine, but Drupal.t('May', {}, {context: "Abbreviated month name"}); doesn't translate May.


  • 2
    How are you determining it doesn't work?
    – Jaypan
    Commented Jan 20, 2022 at 16:20
  • In French it must return "Mai" ... but it returns "May".
    – fxa
    Commented Jan 20, 2022 at 16:24
  • Have you translated the string in the new context already?
    – leymannx
    Commented Jan 20, 2022 at 16:55
  • Of course... in php the t('May', {}, {context: "Abbreviated month name"}) works fine
    – fxa
    Commented Jan 20, 2022 at 17:07
  • 1
    Please provide more feedback, for example the code, expected output and actual output of what is currently working, the same for what is not working, and maybe a bit more info around it, that helps people here to help you.
    – berliner
    Commented Jan 20, 2022 at 17:11


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.