Remove default colon behind inline labels

Created on 22 December 2016, almost 8 years ago
Updated 17 January 2023, almost 2 years ago

Problem/Motivation

The formatter adds a default colon behind the inline label, as example in in date fields.
This is bad practice. In some languages, like Greek, colon is not even used.
If people want colon on their labels, they can easily add it themselves.

Check this comment;
#67211-41: Show colon after form title only when there is no other punctuation

And what happens when you have a label with other punctuations, like questions marks?
#67211: Show colon after form title only when there is no other punctuation

Steps to reproduce

Proposed resolution

Do something like add it in PHP/twig as a translatable string + context then let people translate it to empty string. See #22.

Remaining tasks

Create a follow up, see #22.
Patch
Test
Review

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

9.5

Component
CSS 

Last updated 5 days ago

Created by

🇳🇴Norway matsbla

Live updates comments and jobs are added and updated live.
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.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,388 pass
  • 🇮🇳India gauravvvv Delhi, India

    I have updated it for all the themes expect starterkit theme. I have attached a patch for same. please review

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    Saw the removal which addressed the first part but didn't see "As for a solution the agreement was to do something like add it in PHP/twig as a translatable string + context then let people translate it to empty string"

  • First commit to issue fork.
  • Pipeline finished with Failed
    2 months ago
    Total: 2122s
    #312474
  • Pipeline finished with Success
    2 months ago
    Total: 823s
    #313258
  • 🇮🇳India nayana_mvr

    I have added the colon ':' as a translatable string in twig template core/themes/claro/templates/classy/field/field.html.twig and created an MR against 11.x branch. Attaching before and after screenshots of a Greek page after translating ':' to an empty string for Greek language in UI translation for reference.

    Before:

    After:

    Please review.

  • 🇺🇸United States smustgrave

    Per the proposed solution I actually think this should be done in php somehow to the title attributes

  • Pipeline finished with Failed
    about 2 months ago
    Total: 220s
    #315688
  • Pipeline finished with Success
    about 2 months ago
    Total: 1088s
    #315690
  • 🇮🇳India nayana_mvr

    As per feedback comment, I have done the changes using php. Please check if this is fine. Changes in the UI are same as shown in previous screenshots. So not attaching them again.

  • 🇺🇸United States smustgrave

    Opened 📌 Remove the colon in starterkit Active to address follow up. Though I do wonder if that could be rolled up into this now that it's not a twig change. Will let committer decide that but current scope of this issue looks addressed.

  • 🇳🇿New Zealand quietone

    I read the IS, comments and the MR. I see that the follow up has been made, there are no unanswered questions and the core gates are addressed.

    I updated credit, hid files, and unassigned.

    Leaving at RTBC

  • 🇫🇷France nod_ Lille

    We need more context in the translated string, whitespace rules around colons are different in english and french at least so we need to know a bit more than just ":".

  • Pipeline finished with Success
    about 2 months ago
    Total: 489s
    #319220
  • 🇺🇸United States smustgrave

    Believe feedback from @nod_ has been addressed.

  • I think it is great to remove colons after label by default as it causes issues.

    However using translations to manage it implies that we'll need to translate all labels if we want to remove colon (e.g. for Greek), add a space before (e.g. French)...etc. This seem to be less convenient than the current implementation in CSS - as of now, if it is easy to customize this with a one line CSS such as:
    :lang(el) .field--label-inline .field__label::after { content: ""; }
    :lang(fr) .field--label-inline .field__label::after { content: " :"; }

    Marking as need review because I suggest we better provide custom CSS rules for the most languages possible in core + add example and documentation for developers to customize this colon for their sites' languages.

  • Hi,
    Issue is reproduceable before applying patch.

    But after patch is showing an error. Hence unable to retest.
    Steps to reproduce-
    - Create a new field eg., Date in any of the content type.
    - In the Manage Display, change label to inline.
    - Create a node with that content type.
    - Add Greek language in /admin/config/regional/language
    - Open the newly created node in Greek /el/, there will be a colon ':' after the label.

    Please refer the attachments.

  • 🇫🇷France ericdsd France

    @Matthieuscarset, je me dis que ça mériterait même de générer ça avec une variable css

  • Pipeline finished with Canceled
    25 days ago
    Total: 93s
    #347898
  • Pipeline finished with Canceled
    25 days ago
    Total: 97s
    #347899
  • Just opened a MR to fix formatting of inline field label suffix per language with CSS only.

    I just made two commits. I dont know why the MR show 450+ commits 🤷... something's wrong.

    Need review.

    @Eric good idea! I used a CSS variable:

    :root {
      --drupal-field-label-inline-suffix: ":";
    }
    
  • Pipeline finished with Failed
    25 days ago
    Total: 699s
    #347897
  • Test status-Pass
    Verified on Drupal 11.X version

    Test steps -
    - Create a new field eg., Date in any of the content type.
    - In the Manage Display, change label to inline.
    - Create a node with that content type.
    - Add Greek language in /admin/config/regional/language
    - Open the newly created node in Greek /el/, there will be a colon ':' after the label.

    Patch applied successfully. Issue looks fixed. Moving the ticket to RTBC state.
    Please refer the attached screenshots.

  • 🇫🇷France nod_ Lille

    The translation approach has been validated in #22, so we won't go with the CSS method. The string translation workflow is well oiled and adding a different way to do this doesn't provide significant benefits.

    Here we need to add a context to the string, I suggest: "Field label"

  • If I understood correctly, using translation means users will need to translate each field labels for every language of a site?

    This is a serious amount of work. It makes the current situation worst IMO.

  • 🇫🇷France nod_ Lille

    it's one string that needs translating, it'll handle all inline fields. No visible changes to users after this patch

  • 🇺🇸United States smustgrave

    Closed 📌 Remove the colon in starterkit Active as a duplicate, moving over credit

Production build 0.71.5 2024