we still have here the Drupal.t()
and Drupal.formatPlural()
functions to translate our interface text. To be able to use them you need to require the core/drupal
library as a dependency in your library entry.
Drupal.t()
Drupal.t("My String");
Clear the Drupal Cache.
This string appear in /admin/config/regional/
if not then check your libraries.yml file
And add the corresponding dependencies THEME.libraries.yml:
dependencies:
- core/jquery
- core/drupal
Examples:
Drupal.t('Something to translate');
Drupal.t('Comments to @type posts', {'@type': typeName});
Drupal.t('Something to translate', {}, {context: 'Javascript'});
var x = 'First text to translate'; Drupal.t(x);