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

Drupal.t('May', {}, {context: "Long month name"}); works fine, but when using another context like Drupal.t('May', {}, {context: "Abbreviated month name"}); it does not work.

Why?

Comments

fxa created an issue. See original summary.

nod_’s picture

Category: Bug report » Support request

Can you define does not work?

Do you have the string with the appropriate context in the locales_source table? Is the string translated within this particular context? (just changing the context name without retranslating after will not be enough)

fxa’s picture

Does not work... means does not do the translation.

Yes and in php the translation works fine with the t function.

nod_’s picture

Status: Active » Postponed (maintainer needs more info)

Then I'm not sure, there is nothing obvious I can think of that would do this.

We'd need to have steps to reproduce to be able to look further into it, sample js code, library declaration, how the library is attached on the page (with twig, with #library, etc.), is it loaded after an ajax call or on initial page load, etc.

cilefen’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

It has been three weeks without a reply to this issue. I am closing it as outdated. If there is new information, please comment. You can reopen this issue.