Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
If you translate the literal "inline blocks" to another language in the layout builder, it stops working.
This is because in the controller, there is a validation with the literal "Inline blocks".
/web/core/modules/layout_builder/src/Controller/ChooseBlockController.php line 157 "if (isset($blocks['Inline blocks'])) {"
Proposed resolution
Translate the string before using it.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#12 | 3019333-translation-12-PASS.patch | 4.95 KB | tim.plunkett |
#12 | 3019333-translation-12-FAIL.patch | 3.85 KB | tim.plunkett |
#9 | Screen Shot 2019-02-04 at 7.23.28 PM.png | 294.25 KB | Kristen Pol |
#4 | 3019333-translate-4.patch | 1.1 KB | tim.plunkett |
Captura de pantalla de 2018-12-10 12-39-35.png | 198.06 KB | julenmelgar |
Comments
Comment #2
julenmelgar CreditAttribution: julenmelgar commentedComment #3
julenmelgar CreditAttribution: julenmelgar commentedComment #4
tim.plunkettThis is because of how
\Drupal\Component\Plugin\CategorizingPluginManagerInterface::getGroupedDefinitions()
works: it uses translated strings as array keys. Not great :(This needs a test, but here's the fix.
Comment #5
julenmelgar CreditAttribution: julenmelgar commentedHello @tim.plunkett, first thanks for your quick reply and your contributions. I'm doing some tests to see if the patch works completely well.
Comment #6
Kristen PolI agree with @julenmelgar that the patch in #4 looks good. I'll try to test now.
Comment #7
amit.drupal CreditAttribution: amit.drupal as a volunteer and at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commented@tim.plunkett, Test patch #4 it's working fine.
Comment #8
Kristen PolI've been unable to test this with simplytest.me. Tried on various occasions. @amit.drupal how did you test on your local?
Comment #9
Kristen PolHmm... I am not seeing "Inline blocks" in the list of strings. I must be looking in the wrong place. Please add steps to reproduce this to the issue summary. Thanks.
Comment #10
Ismail Cherri CreditAttribution: Ismail Cherri as a volunteer and commented@Kristen Pol
Steps to reproduce:
1. Install Drupal
2. Enable content, config and interface translation
3. Add additional language e.g. German & Import translations
4. Add a new custom block type (/admin/structure/block/block-content/types/add) e.g. Test Block
5. Enable Layout Builder module
6. Enable it for Basic Page content type
7. Create a new basic page in English
8. Add an inline block -> works as you see a list of inline blocks
9. Switch to German interface
10. Add an inline block -> Does not work as you don't see the list of inline blocks
Notes
- The issue doesn't happen if there only one type of inline blocks especially the default one
- I couldn't apply the patch in #4 with simplytest.me also.
- I applied it on a fresh Drupal 8.6.9 and 8.7.x-dev installations and it fixes the issue
Comment #11
xjmLooks like we need an automated test here. Thanks!
Comment #12
tim.plunkettLocale module + content translation + 2 content blocks all to test an artifact of the plugin system. Idk if I've ever written a more lopsided test :)
FAIL patch is also the interdiff
Comment #14
phenaproximaPerfect.
Comment #15
xjmSo, definitely not a fan of this -- stringcasting a translatable string that varies per language for an array key instead of keying on a machine name is brittle and bug-prone -- but per @tim.plunkett this is unavoidable because of the way the API works. See #4. I filed #3032836: CategorizingPluginManagerTrait::getGroupedDefinitions() keys groups by a stringcast of a translatable string, which is brittle.
I also asked if we needed a cache clear. @tim.plunkett pointed out that this line's method call would be cached:
...but fortunately, we're not changing that line, just the build array. I also asked whether the render cache would need to be invalidated for that, but (again, per @tim.plunkett) the Layout Builder UI is already marked as uncacheable.
Saving issue credit.
Comment #17
xjmCommitted and pushed to 8.7.x. Thanks for reporting this! Promoting to major since this basically breaks the inline blocks feature for non-English sites.
This is probably eligible for backport since the impact outweighs the disruption, but I'm going to queue an 8.6.x test run before pushing that cherry-pick.
Comment #19
xjmAnd pushed the 8.6.x cherry-pick! Thanks all.