Closed pvbergen closed 4 years ago
We have discussed the issue internally and we decided to use the global po file (per theme/module).
We collect all necessary patterns within a theme during preprocessing and then add the necessary translations to the theme's po file. This includes some amount of extra preprocessing but doesn't necessitate any changes to the translation system of Drupal.
I close the issue for now, but if there are any comments, feel free to add them.
Background / Motivation
We've been using the ui_patterns module as a base for patterns for our pagedesigner module (drupal.org/project/pagedesigner). We're currently dealing with displaying pattern information in a localized form, e.g. passing label and description through the interface translation of Drupal. We are a bit stuck on finding the right approach. As far as I can tell, the ui_pattern module does not implement any translation of yaml values or specifies a way to add translations for a pattern.
Solutions
I believe there are multiple, possible approaches we could take:
Global po file
A global po file would represent the usual approach for Drupal translations and require the least amount of work on the module side. The downside is that adding a new pattern require changes to the central file(s), which might impose an issue when dealing with a central repository of patterns as in our case.
PO file per pattern
We could include a po file with the pattern and make sure that these are loaded by Drupal. This would keep definition and translation local to the pattern. It could hover result in a lot of duplication within the po files (translating the same string over and over).
Translation within yaml
We could combine translations directly in to the yaml file, making the coupling even tighter. Effect is similar to a po file per pattern.
Thoughts
I would like to implement the PO file per pattern approach. For us, this is the approach matching our needs for a central repository of patterns. This would require to add detection and import for non standard location po files.
What are your thoughts on this? Did I miss something?