I suggest changing the text of the translation string from:

$element['time']['#attributes']['title'] = t('Enter a valid time - e.g. @format', [
    '@format' => (new \DateTime())->format('h:i'),
]);

to:

$element['time']['#attributes']['title'] = t('Time (e.g. @format)', [
    '@format' => (new \DateTime())->format('h:i'),
]);
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hop created an issue. See original summary.

geek-merlin’s picture

mably’s picture

@geek-merlin do you want me to implement the suggested fix?

geek-merlin’s picture

@mably: Please look what the string is in the original widget, and use the same one (apart from the format). That way, no re-translation is necessary.

mably’s picture

Original widget string is defined here, excerpt below:

      // Adds the HTML5 attributes.
      $extra_attributes = [
        'type' => $element['#date_time_element'],
        'step' => $element['#date_increment'],
      ];
      $element['time'] = [
        '#type' => 'date',
        '#title' => t('Time'),
        '#title_display' => 'invisible',
        '#value' => $time_value,
        '#attributes' => $element['#attributes'] + $extra_attributes,
        '#required' => $element['#required'],
        '#size' => 12,
        '#error_no_message' => TRUE,
      ];

So OP's suggestion is ok, but it will still require a translation because of the format.

Or do you prefer that we totally remove the format part?

mably’s picture

Status: Active » Needs review
geek-merlin’s picture

Status: Needs review » Closed (won't fix)

Thanks for the research! Since #2, where i was open to this, i learnt a lot about translations.
Setting to wontfix for reasons:
- A t() string should be hard to mis-contextualize, because translators on localize.drupal.org do not see the UI.
- String changes should only be made if absolutely necessary, as they invalidate existing community translations.
- Anyone can translate the string as they like, even to english.