- 🇩🇪Germany ktpm
Not sure if I should post this here or in #3188336: Updates to string causes over-write of fallback language → as both are related, but since this issue is still open, let's go with this.
Currently, if you try to import translations to a language, which has parent languages, the translations of the parent language may be overridden, when using
drush locale:import
with any--override
option. This happens, if there is no string item for the target language yet. This probably also occurs when using the import form in the backend, but I did not explicitly test it that way.Example:
EN as parent language
Set any language as child language, like DE.How it happens:
- The StringDatabaseStorageDecorator::dbStringSelect() wants to retrieve fallback candidates for the db select.
- The candidate selection is done in the language_fallback_candidates_alter hook. EN is returned as candidate.
- DE & EN are passed to the db select. String item for DE does not exist, hence the query returns the EN item.
- PoDatabaseWriter::importString() SHOULD go to the else part ("No such source string in the database yet.") but gets EN string.
- Because override option is set, string item gets overwritten/updated.As the candidate selection part is done in the alter hook, I believe the check should be done there, as I did in the attached patch file. Not too sure about it though. So I added some checks there if the current process is being run via cli (drush), if there is an actual batch being processed, and if the batch is a locale translate import, to be as specific as possible about this. There may be better ways to do this, but it helped me to avoid this issue.