Problem/Motivation
onlyoffice.info.yml sets
'interface translation project': onlyoffice 'interface translation server pattern': modules/contrib/onlyoffice-drupal/translations/onlyoffice.%language.po
This path fits an installation of the Packagist package onlyoffice/onlyoffice-drupal, which composer/installers puts into modules/contrib/onlyoffice-drupal. A site that installs drupal/onlyoffice from packages.drupal.org gets the module in modules/contrib/onlyoffice, so the file is never found.
The pattern is a local path, so Locale only looks for that local file and never asks localize.drupal.org (see \Drupal\locale\LocaleSource::sourceBuild()). As a result, such sites get no translation for the module at all: neither the .po files shipped in translations/ nor translations from localize.drupal.org. For example, a German site shows "Edit in ONLYOFFICE" and "View in ONLYOFFICE" untranslated, although translations/onlyoffice.de.po contains both strings. Its locale_file row for the project has an empty file name and timestamp 0.
Steps to reproduce
composer require drupal/onlyoffice(installs intomodules/contrib/onlyoffice), enable German and the module.- Check for translation updates at Reports › Available translation updates, or run
drush locale:checkanddrush locale:update. - Nothing is imported for ONLYOFFICE Connector, and its strings stay in English.
Proposed resolution
Point the pattern at the directory the module is actually installed in, wherever that is. Implement hook_locale_translation_projects_alter() and set interface translation server pattern from \Drupal::service('extension.list.module')->getPath('onlyoffice'), and remove the hard-coded pattern from onlyoffice.info.yml. The shipped .po files are then imported for both installation methods.
Alternative: remove both keys, so Locale uses localize.drupal.org like other contributed projects, and import the shipped translations into localize.drupal.org.
Remaining tasks
- Decide between the two approaches.
- Review the merge request (first approach).
User interface changes
Translated module strings on sites that installed drupal/onlyoffice.
API changes
None.
Data model changes
None.
Text generated with AI
Issue fork onlyoffice-3630201
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
daniel.pernold commentedMerge request !6 is ready for review.