Problem/Motivation
Themes define region names in their .info.yml files in Drupal 8.
These should be translated, but as far as I can tell, they are not being extracted by POTX.
For example, the Drupal core Bartik theme has this in bartik.info.yml:
regions:
header: Header
primary_menu: 'Primary menu'
secondary_menu: 'Secondary menu'
page_top: 'Page top'
page_bottom: 'Page bottom'
highlighted: Highlighted
featured_top: 'Featured top'
breadcrumb: Breadcrumb
content: Content
sidebar_first: 'Sidebar first'
sidebar_second: 'Sidebar second'
featured_bottom_first: 'Featured bottom first'
featured_bottom_second: 'Featured bottom second'
featured_bottom_third: 'Featured bottom third'
footer_first: 'Footer first'
footer_second: 'Footer second'
footer_third: 'Footer third'
footer_fourth: 'Footer fourth'
footer_fifth: 'Footer fifth'
But if you look at various theme-related pages, such as the block region preview, you will see that only a few of these region names get translated (presumably the ones that are translated are done because they are in the POTX database from other sources). So for instance, "Primary menu", "Secondary menu", and "Sidebar first" are not in the POTX database on localize.drupal.org for the Drupal Core project (after Drupal 8.0.0-rc2 anyway -- they seem to be in there for early beta versions of Drupal). They should be.
Screenshot of what this page looks like in Catalan (from the User Guide):
Proposed resolution
Parse region name human-readable strings in POTX.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#31 | 3043258-d8-31.patch | 4.17 KB | jhodgdon |
#17 | 3043258-test-plus-code-17.patch | 4.34 KB | jhodgdon |
#17 | interdiff.txt | 1.98 KB | jhodgdon |
#2 | 3043258-test.patch | 780 bytes | Gábor Hojtsy |
block-regions-bartik.png | 22.04 KB | jhodgdon |
Comments
Comment #2
Gábor HojtsyGood find! Theoretically the rules in yaml_translation_patterns.yml would make potx find them, but there is no test coverage. Let's see what would expanded tests say.
Comment #4
jhodgdonRealized I created this issue long ago in the wrong project, so I'll be closing #2806065: Theme region names are not making it into PO database as a duplicate of this one. Doh!
Comment #5
jhodgdonThat looks like a good test!
Comment #6
jhodgdonHm. Regions is not like the other keys in that translation patterns file, in that it is an array.
So, looking at what happens in _potx_find_yaml_translatables() in potx.inc, for arrays in YAML... let's see. In either the test info.yml file or in the Bartik yml file, we have something like this:
So in the code, it does this, basically [my comments added and a bunch of code removed for simplicity]:
And then there is a recursive call to the same function if $value is an array, but at that level, the keys are things like 'sidebar_first' and those will not match the keys in the translatable list.
In other words... What we want here is "Extract values for all the keys underneath regions". But that is not what the code does.
Comment #7
jhodgdonHere's a proposed fix... It is already possible in a yaml_translation_patterns.yml file to specify
at the file level, and also it is possible to specify a context for each translatable key.
So what I've done is to add the possibility of specifying something similar to top_level_translatables for each key.
Let's see what happens...
Comment #9
jhodgdonInvalid YAML, whoops. How about this? Should also probably fix the coding standards warning.
Comment #10
jhodgdonwhoops, that's not quite right either. Need to think about the logic a bit more.
Comment #11
jhodgdonOK, I think this even simplifies the logic a bit. I canceled the other test.
Comment #13
jhodgdonOne more fix. Should hopefully take care of the coding standards warnings in the lines touched by this patch, plus fix the test fail maybe/hopefully.
Comment #15
jhodgdonSorry for all the sloppiness. This patch might fix the last test fails hopefully...
Comment #17
jhodgdonOK, here's a new patch that reorganizes the logic and is hopefully clearer, plus might work this time. :)
Probably I should have installed the module and run the tests on my own machine... oh well.
Comment #18
jhodgdonOK, it's green, with no coding standards violations! Time for an actual review.
Comment #19
Joachim NamysloIt seems this is valid for the them region names on the block layout page, too. Maybe Gabor misunderstood my issue and therefore he marked it as a duplicate of this one.
As long as the region names are English we aren't able to make user guide screenshots. It is at least a blocking Issue for de
Comment #20
Joachim NamysloComment #21
jhodgdonYes, the problem is that the region names for the theme, which are used on the Block Layout page as well as the Regions Preview page that you can see in the screenshot on this issue... Those region names are not being extracted by the POTX string extractor, so they are not on localize.drupal.org to be translated. Some of them are on there because they have been used in PHP code elsewhere in Drupal Core, but not all. This patch should fix the problem, so that the translation teams can translate those terms.
Comment #22
jhodgdonBump... I added a patch about 6 weeks ago. What can we do to move this forward?
Comment #23
Joachim NamysloYep Great question just before Amsterdam. Putting it on the list for Drupal Con would be a great Idea.
Comment #24
Joachim NamysloAny Updates on this. I'd like to translate the User Manual from scratch on Global contribution Weekend 2020 in Berlin Maybe this one could be reviewd so we can work on as long the Help topics Module is in experimental state, still.
Comment #25
jhodgdonI don't see why this issue would prevent you from translating the User Guide into German. It's only affecting one screenshot.
Comment #26
Joachim NamysloI thought there is a problem to extract template region names correctly. But If we can motivate people to translate the guide again in it's current version the screenshots will be the last step. So youre absolutely right. Hope we can do this untill the Help topics module is stabele.
Thank you Jennifer
Comment #27
jhodgdonTrue, this is a problem for translating the user interface, but I think it only affects a few pages of the User Guide where blocks are being placed in regions.
Comment #28
Gábor HojtsyComment #30
Gábor HojtsyThanks all. Committed to 7.x-3.x. Sorry for making this linger. Should be ported to 8.x too. Now on 7.x though @drumm can roll this out to l.d.o.
Comment #31
jhodgdonHere's an attempt at porting the patch. The code for D7 and D8 looks pretty similar, so I basically just copy/pasted stuff from the D7 patch and put it in the equivalent spot in D8... let's see what the bot says (I'm not on my D8 dev machine so I didn't run the test) -- I included the test changes in the patch.
Comment #32
Gábor HojtsyWe do try to keep potx.inc identical between major Drupal versions, so backporting and forward porting is easier. At one point we'll need to stop doing that, but so far it served us well.
Comment #33
jhodgdonIt was close, but not identical. The patch didn't apply, even with "fuzz". But it was easy to figure out where to copy/paste things and how to change one variable name.
Comment #34
jhodgdonThe tests pass on the d8 port.
Comment #36
Gábor HojtsyGreat, pushed that too, thanks!