Increase site slogan maxlength for translations

Created on 14 October 2020, over 3 years ago
Updated 7 February 2024, 4 months ago

Problem/Motivation

Follow-up to #2928960: Increase site slogan maxlength to 255 to allow longer slogans โ†’ .

Seems like the patch does not account for the translation of the slogan, when I want to translate the slogan in a different language it's still limited to 128 chars for the other language.

Steps to reproduce

Enable languages modules.
Add an additional language.
Go to '/admin/config/system/site-information/translate' and try to set a longer slogan.

Proposed resolution

Increase length of slogan to 255 for the translations.

Remaining tasks

Create patch, tests & commit.

User interface changes

Same settings for translations and original language.

API changes

no

Data model changes

no

๐Ÿ“Œ Task
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Config translationย  โ†’

Last updated about 1 month ago

Created by

๐Ÿ‡ต๐Ÿ‡ฑPoland Krzysztof Domaล„ski Poland

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium joevagyok

    None of the above proposed patches offer the right solution here, by hardcoding a maxlength number on the translation form element.

    Since config_translation is not aware of the form used for the given config, it relies on a basic mapping between config types and field elements.
    Therefore, config_translation has no idea about the fact that in the parent issue โ†’ , maxlength was set to 255. The label config type is mapped to Drupal\config_translation\FormElement\Textfield which uses the default 128 char maxlength setting.

    So either we change the slogan config type from label to text which will allow more characters on translation too, or come up with way to set core from Element properties within config_translation per field.

    As a workaround, developers can make their own class and change the mapping to override the Drupal\config_translation\FormElement\Textfield class to their own class where they set all desired properties to the Textfield element.

  • First commit to issue fork.
  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia shalini_jha

    HI, I think the one of solution to this problem is updating the config schema. Currently, these 2 field name,slogan use type: label, where long texts should be marked as type: text , so i have added text type for slogan field. please clear your cache after these changes.
    I have added a MR for your reference, please review.

  • Assigned to DishaKatariya
  • Pipeline finished with Failed
    5 months ago
    Total: 920s
    #86755
  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Schema changes will require an update hook. If the solution is changing issue summary should reflex.

    Even as a task seems like something that will need test coverage.

  • Issue was unassigned.
  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia shalini_jha

    After the system.site schema changes(type:labe to type:text)for slogan field, I tested the Translations for System information add/edit form, and it seems that the slogan field is accepting more characters than intended. Subsequently, I also tested the existing value, and it remains unchanged. Additionally, when I added a translation for the slogan field, those changes did not take effect. Therefore, it appears that the data is not being affected by these modifications.
    Can you please do we need hook update for this ?

    It appears that the test case named testSourceValueDuplicateSave is encountering a failure, at the line:
    $this->assertSession()->pageTextNotContains('FR ' . $site_slogan);

    The purpose of this line is to confirm that the original value remains unchanged when a translation is added. Despite the presence of these translated text for both the name and slogan fields in the translation edit page, the test is passing (refer to the attached screenshot). My assumption is that if the slogan field type were a label, the pageTextNotContains function might not have checked the slogan field value. However, due to recent changes made to the slogan field type, the pageTextNotContains function is now taking the slogan field value also, resulting in the test failure.

    To resolve this issue, I adjusted the line related to the slogan field. Instead of using pageTextNotContains, I opted for elementTextNotContains. The revised line is as follows:

    $this->assertSession()->elementTextNotContains('css', '#edit-source-config-names-systemsite-slogan', 'FR ' . $site_slogan);
    

    With these modifications, the test case is now working as intended, ensuring that the original value of the slogan field remains unaffected by the addition of a translation.
    so can i update these changes for test fail.

    Please review and suggest . thanks

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    @shalini_jha it looks like you didn't push to the MR?

  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave
  • Pipeline finished with Failed
    4 months ago
    Total: 545s
    #89288
  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia shalini_jha

    I have pushed the changes in https://git.drupalcode.org/project/drupal/-/merge_requests/6432. please review

  • Assigned to DishaKatariya
  • Issue was unassigned.
  • Status changed to RTBC 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia DishaKatariya

    Hi, Verified and tested the Merge request !6432 on 11.x-dev version. Its working as expected now.
    Testing Steps:
    1. Install the 11.x-dev version
    2. Go to the Extend and enable the Languages module
    3. Enable the translation module.
    3. Now go to the /admin/config/regional/language/add and add any language.
    3. then, Go to '/admin/config/system/site-information/translate' and try to set a longer slogan.
    4. Now you will be able to see the error for the slogan added 255 characters long. and not able to add the translation.
    5. Now, Apply the patch.
    6. and Check if the maxlength is added and can be able to save translation slogan.
    Testing Results-
    Increased site slogan maxlength for the translations.
    Attaching screenshots for the reference.
    Can be move to RTBC.
    Thanks!

  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium joevagyok

    Other test cases are still failing.

  • Pipeline finished with Failed
    4 months ago
    Total: 231s
    #89652
  • Pipeline finished with Success
    4 months ago
    Total: 477s
    #89663
  • Status changed to Needs review 4 months ago
  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Needs an upgrade path

  • Pipeline finished with Success
    4 months ago
    Total: 573s
    #89700
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium joevagyok

    Left another review on the code, please make sure to load up the config to check the string is correctly saved, beside asserting the success message.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance andypost
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance andypost
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium Wim Leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • Pipeline finished with Failed
    4 months ago
    Total: 515s
    #101380
Production build 0.69.0 2024