Problem/Motivation

Labels defined in a module's module.layouts.yml are not translatable.

Proposed resolution

N/A

Remaining tasks

Make labels (and possibly other strings defined in module.layouts.yml) translatable.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Comments

johnzzon created an issue. See original summary.

andypost’s picture

I think it should be broader issue to allow define translatable properties in annotations

andypost’s picture

\Drupal\Core\Layout\Annotation\Layout defines label & description as @ingroup plugin_translatable but actually it makes it translatable as https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/transla... supposed

andypost’s picture

Status: Active » Needs review
StatusFileSize
new2.25 KB

Let's see how many tests will fail

andypost’s picture

Also region names needs wrapper somehow

Status: Needs review » Needs work

The last submitted patch, 4: 3008772-4.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new1.56 KB
new2.15 KB

A bit cleaner patch

andypost’s picture

StatusFileSize
new3.22 KB
new5.37 KB

Fix test

andypost’s picture

Looking deeper it looks like \Drupal\Core\Plugin\Discovery\YamlDiscoveryDecorator should be able to detect properties that are translatable
Also reflection of properties annotations could bring overhead of yaml discovery

tim.plunkett’s picture

Issue tags: +Blocks-Layouts, +Needs tests
StatusFileSize
new1.03 KB

First of all, this needs tests.

Second, this should (ideally) work.

The last submitted patch, 7: 3008772-7.patch, failed testing. View results

andypost’s picture

There's no BC break according https://www.drupal.org/core/d8-bc-policy#public-properties because \Drupal\Core\Layout\LayoutDefinition has no interface

The last submitted patch, 8: 3008772-8-test-only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 10: 3008772-layout-10.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new8.17 KB
new6.36 KB
new8.27 KB

Fix #10 s/title/label and extended tests

The last submitted patch, 15: 3008772-15-test-only.patch, failed testing. View results

johnzzon’s picture

#15 worked for me!

tim.plunkett’s picture

Title: Layout label defined in yaml is not translatable » Layout definition defined in YAML is not translated

Thanks @andypost!

I believe breakpoint.module suffers from the same oversight, another issue should be opened for that module and any others using \Drupal\Core\Plugin\Discovery\YamlDiscovery

johnzzon’s picture

Status: Needs review » Reviewed & tested by the community
andypost’s picture

Status: Reviewed & tested by the community » Needs review
andypost’s picture

StatusFileSize
new771 bytes
new8.3 KB

At least region names should have own translation context

I did not add "context_key" argument to addTranslatableProperty() because it used in a strange way in \Drupal\Core\Plugin\Discovery\YamlDiscovery::getDefinitions()

            $options = [];
            // Move the t() context from the definition to the translation
            // wrapper.
            if ($context_key && isset($definition[$context_key])) {
              $options['context'] = $definition[$context_key];
              unset($definition[$context_key]);
            }
            $definition[$property] = new TranslatableMarkup($definition[$property], [], $options);

Status: Needs review » Needs work

The last submitted patch, 21: 3008772-21.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new2.17 KB
new8.77 KB

And fixed test

andrewmacpherson’s picture

Issue tags: +Accessibility

This is an accessibility must-have. We'll need to use layout/region label/description to describe various aspects of the layout builder UI to screen reader users.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Not sure what this has to do with accessibility, but I'll take your word for it :)

  • larowlan committed 1b186cf on 8.7.x
    Issue #3008772 by andypost, tim.plunkett: Layout definition defined in...
larowlan’s picture

Version: 8.7.x-dev » 8.6.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 1b186cf and pushed to 8.7.x. Thanks!

C/p as 090bbaea43 and pushed to 8.6.x

  • larowlan committed 090bbae on 8.6.x
    Issue #3008772 by andypost, tim.plunkett: Layout definition defined in...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.