Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Implementing a solution for #2088371: YAML discovery incompatible with translations, #2296219: Create schema for non-config YAML files? in potx.
The proposed solution now is to specify only the translatable keys (ignoring the yaml structure) in a specific file (yaml_translation_patterns.yml
?), and allow contrib modules to extend this by defining a similar file in their root folder.
This is the current proposed format, including all supported yaml types in core:
*.info.yml:
- name
- description
- package
- regions
*.routing.yml:
- _title:
context: _title_context
*.links.task.yml:
- title:
context: title_context
*.links.action.yml:
- title:
context: title_context
*.links.contextual.yml:
- title:
context: title_context
*.links.menu.yml:
- title:
context: title_context
- description
*.breakpoints.yml:
- label
- group
*.permissions.yml:
- title
- description
- %top-level-key
config/schema/*.yml:
- label
Comment | File | Size | Author |
---|---|---|---|
#9 | potx-yaml-translation-followup-2322839-9.patch | 4.64 KB | herom |
#9 | interdiff-2322839-6-9.txt | 1.45 KB | herom |
#2 | potx-yaml-translation.patch | 7.87 KB | herom |
Comments
Comment #2
herom CreditAttribution: herom commentedoops. missed that new file.
Comment #3
Gábor HojtsyThis looks good as a first step, it does not yet support integration with contrib solutions though. What do you think how would we do the reading of those files? It sounds like it would be similar to how you read all the schema files first and then the parsing of the config files. Here the "schema" files are the YAML pattern files (not happy for the name but have no better idea :D).
Comment #5
Gábor HojtsyThe patch itself looks amazing, so committed this patch for now. What we need though is a translatables yaml file in the D8 module and some of our own defined YAML file eg. potx_test_8.potx_test_strings.yml or something from where to test the extraction, so we test the discovery of the translatables definition and that it works.
Comment #6
herom CreditAttribution: herom commentedHere comes contrib support, tests, and a bit of docs.
Comment #8
Gábor HojtsyStart with uppercase.
Add newline between endcode and param.
Test file was not in the patch :)
Comment #9
herom CreditAttribution: herom commentedsilly me :)
Comment #10
Gábor HojtsyYay, thanks, that looks great. Fixed the whitespace errors in potx_test_8.test.yml on commit.
Comment #12
Gábor HojtsyComment #13
herom CreditAttribution: herom commentedClosed a couple of issues on the 7.x-2.x branch in favor of porting this: #1936028: Support for Drupal 8 info.yml translatables, #1935192: Support for Drupal 8 shipped configuration schema translatables, #2254561: Support string extraction for Drupal 8 menu_links.yml, #2123127: Extract titles of local tasks, local actions and contextual links, #2069923: Support for Drupal 8 routing.yml title, #2305555: All the links files got renamed in Drupal 8, #2325321: Support for Drupal 8 Breakpoint.
Comment #16
SebCorbin CreditAttribution: SebCorbin commentedPorted to 7.x-3.x as it has been branched directly from 6.x-3.x
Comment #17
XanoThe documentation is a little unclear to me. Say I have the following
*.payment.status.yml
YAML structure, how would I make thelabel
anddescription
items translatable?I tried this, but despite the fact that POTX scanned the YAML files, the strings did not end up in the
pot
file:Comment #18
Gábor HojtsyAre you sure potx considers your declaration of translatable things? I suspect that may be the problem.
Comment #19
Xano#2357365: Followup: Keep YAML translation patterns throughout the request turned out to be the root cause.