Follow-up to #2544544: Translate «The term '@term' will be added.»

«The term '@term' will be added.» — It is displayed regardless of the language. We need to do a line with the possibility of translation into other languages.

For the 8.x branch, many of the message strings are already translated, but there are still a few which aren't, both in .js and .php files.

Grepping for 'message' should locate all of them.

Refer to #8 for the D7 issue for how to translate message in .js files, if needed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LNakamura created an issue. See original summary.

thomjjames’s picture

Hi,

"not_found_message" was using $element array rather than $settings array in the field widget so the custom message wasn't showing, this patch fixes that and some related translation fixes. I'm not 100% sure the custom message should be translatable though?
Probably more translation fixes not covered by this patch but it does fix the "not_found_message" at least.

Cheers
Tom

oriol_e9g’s picture

The bug is out of scope and is fixed here: #3014259: Fix bug for custom Not Found Message

oriol_e9g’s picture

This text should not be translated here because @term param should be passed with t() function.

This string is used in an ajax call and passed through Drupal.t() in autocomplete deluxe.js with the correct @term param. If you translate before is double translated.

oriol_e9g’s picture

In teory is translated here:
autocomplete_deluxe.js:

if (term !== ' ') {
  result.push({
    label: Drupal.t(self.not_found_message, {'@term': term}),
    value: term,
    newTerm: true
  });
}
else {
  result.push({
    label: Drupal.t(self.no_empty_message),
    noTerms: true
  });
}
oriol_e9g’s picture

Rajab Natshah’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
sickness29’s picture

Status: Active » Reviewed & tested by the community

This is working on 2.0.x-dev without any patches.
The strings are configured on form display, so you can simply create config for specific language and specify translated values for not_found_message and no_empty_message.

For example, you have Ukrainian as second language on site and want to translate this values for field_tags on article default form display, then you need to put new file core.entity_form_display.node.article.default.yml into [your_config_sync_folder]/language/uk/
wtih something like that:

content:
  field_tags:
    settings:
      not_found_message: 'Новий термін ''@term'' буде додано'
      no_empty_message: 'Немає результатів. Будь ласка введіть початок.'

After config import your strings will be translated when page displayed in Ukrainian.

sickness29’s picture

Hi @rajab-natshah
this can be simply "Closed (works as designed)" as it is possible to translate all those texts through config translation