Count down message text is not translatable through the UI

Created on 22 March 2018, over 6 years ago
Updated 30 September 2023, about 1 year ago

Problem/Motivation

The default value for the Count down message is not translatable, including the variables @limit, @remaining and @count that are available in that field. This is because you should never use t() to translate variables.

The current default value is

Content limited to @limit characters, remaining: @remaining

Steps to reproduce

  1. Install and enable Language and translation modules
  2. Configure administration pages to use a language other than English.
  3. Visit the User Interface Translation admin page (/admin/config/regional/translate)
  4. Search for "Content limited"

Resolution

The reason the count down message is not translatable is because of Drupal core bug 🐛 Entity view/form mode formatter/widget settings have no translation UI Needs review .

Until that issue is resolved, do the following to translate the count down message through the UI.

  1. Apply the patch from 🐛 Entity view/form mode formatter/widget settings have no translation UI Needs review . This patch will add the UI needed to add the translations.
  2. Clear the cache.
  3. Log in as admin.
  4. Go to Configuration > Regional and Language > Configuration translation.
  5. In the list, find the row that contains the "form display" configuration for the entity type that has the field you want to translate. For example if you are using nodes, find "Content form display". Click "List" in this row.
  6. Click "Translate" next to the bundle name that has the field you want to translate.
  7. Now press "Add" or "Edit" for the language you want to translate to.
  8. Next up look in the "Field widgets" section and find the configuration for the field you want to translate. Note that this UI is still a work in progress and might not be very intuitive.
  9. Expand the "Third party settings" fieldset and edit the translation.
  10. Press "Save translation" at the bottom of the form.

🐛 Bug report
Status

Closed: works as designed

Version

2.1

Component

Code

Created by

🇺🇾Uruguay rpayanm

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States cedewey Denver, CO
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States cedewey Denver, CO

    Hi @mukesh88, thanks for contributing your patch. To get this work accepted we need to address the fact that we should never use t() to translate variables.

    If you can update your patch to account for that, that would be great. Thanks!

  • Assigned to mukesh88
  • First commit to issue fork.
  • @kunal_sahu opened merge request.
  • I have used TranslatableMarkup instead of t() function in #25

  • Status changed to Needs review over 1 year ago
  • Issue was unassigned.
  • Status changed to Needs work over 1 year ago
  • 🇮🇳India kunal_sahu Karnataka

    @mukesh88 Can you please look at this issue .

    $ git apply -v 2955352-25.patch
    Checking patch maxlength.module...
    error: while searching for:
          $maxlength_js = $thirdPartySettings['maxlength']['maxlength_js_summary'];
          $element['summary']['#attributes']['data-maxlength'] = $maxlength_js;
    
          $maxlength_js_label = !empty($thirdPartySettings['maxlength']['maxlength_js_label_summary']) ? $thirdPartySettings['maxlength']['maxlength_js_label_summary'] : t('Content limited to @limit characters, remaining: <strong>@remaining</strong>');
          $element['summary']['#attributes']['maxlength_js_label'][] = $maxlength_js_label;
    
          if (isset($thirdPartySettings['maxlength']['maxlength_js_enforce']) && $thirdPartySettings['maxlength']['maxlength_js_enforce']) {
    
    error: patch failed: maxlength.module:161
    error: maxlength.module: patch does not apply
    
    

    Thanks

  • Status changed to Needs review over 1 year ago
  • @kunal_sahu patch apply successfully for 2.1.x version.

  • 🇮🇳India kunal_sahu Karnataka

    @mukesh88 Apologies , i was applying it to the wrong branch.

    The patch looks good to me.

    I think this issue can be now moved to RTBC.

    /web/modules/contrib/maxlength-2955352 (2.1.x)
    $ git apply -v 2955352-25.patch
    Checking patch maxlength.module...
    Applied patch maxlength.module cleanly.
    

    Thanks

  • @kunal_sahu if you have review the issue then you can moved to RTBC

  • 🇧🇪Belgium joevagyok

    I think the root of the problem is in this issue.

  • Assigned to joevagyok
  • 🇺🇸United States cedewey Denver, CO

    I tested this on our 2.1.x branch and I believe this is now working as expected. The tokens, @limit and @remaining and @count need to stay named as such, but I think that's ok. Otherwise, the other countdown message text if translated shows up as expected on the respective language's edit form.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States cedewey Denver, CO

    I misspoke. What I had done was change the countdown message to Spanish and displayed as such even in English interfaces. I went to the User Interface Translation admin page (/admin/config/regional/translate) and searched for "content limited" and the MaxLength countdown string was not available.

    So, there is still work that needs to be done to make the countdown message translatable.

  • Status changed to Closed: works as designed over 1 year ago
  • 🇧🇬Bulgaria pfrenssen Sofia

    I can confirm that the fix from 🐛 Config schema type for maxlength_js_label and maxlength_js_label_summary should be text Fixed has also solved this issue. I can also confirm as many said before that the approach in the current patch is wrong.

    The confusion about how to translate this probably arises from the fact that there is no UI for translating field widget configuration yet. But there is a WIP patch in 🐛 Entity view/form mode formatter/widget settings have no translation UI Needs review that adds this UI.

    I will close this as "Works as designed" since this is already working from the perspective of the MaxLength module.

    Here are instructions to make it work:

    1. Apply the patch from 🐛 Entity view/form mode formatter/widget settings have no translation UI Needs review that works with your version of Drupal core. This patch will add the UI needed to add the translations.
    2. Clear the cache.
    3. Log in as admin.
    4. Go to Configuration > Regional and Language > Configuration translation.
    5. In the list, find the row that contains the "form display" configuration for the entity type that has the field you want to translate. For example if you are using nodes, find "Content form display". Click "List" in this row.
    6. Click "Translate" next to the bundle name that has the field you want to translate.
    7. Now press "Add" or "Edit" for the language you want to translate to.
    8. Next up look in the "Field widgets" section and find the configuration for the field you want to translate. Note that this UI is still a work in progress and might not be very intuitive.
    9. Expand the "Third party settings" fieldset and edit the translation.
    10. Press "Save translation" at the bottom of the form.

    Here is how the UI looks:

  • 🇺🇸United States cedewey Denver, CO

    Thanks Pieter, this is very helpful. I've updated the task description with this resolution and am crediting you as the author of this fix. Much appreciated!

  • 🇩🇪Germany markdc Hamburg

    I also wish to express my thanks @pfrenssen
    This solution is certainly the way forward.

Production build 0.71.5 2024