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
Comments
Comment #2
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 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 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 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 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.ymlYAML structure, how would I make thelabelanddescriptionitems translatable?I tried this, but despite the fact that POTX scanned the YAML files, the strings did not end up in the
potfile: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.