Loading
Resolve #3639005 "MT setup deletes the TM pretranslation rule of new Smartcat projects"
Generated with the help of an LLM.
Keep the existing pretranslation rules when the module adds the MT rule. Before, the module replaced them with one MT rule, so the TM rule of every new project was deleted.
Smartcat::getPreTranslationRules()reads the project's current rules.SmartcatProjectManager::appendMtRule()adds the MT rule after the current rules. It returns NULL when an MT rule already exists, and then the module sends nothing.- If reading the rules fails with an HTTP error, the module logs the error and does not post. The TM rule stays.
- New unit test
tests/src/Unit/AppendMtRuleTest.php(4 cases, including lower-case"mt"from the API).
Tested on a Smartcat test environment through the Drupal UI (Drupal 11.4, PHP 8.5):
| Workflow | Before | After |
|---|---|---|
| AI translation + human review | MT rule only | TM rule + MT rule |
| AI translation | MT rule only | TM rule + MT rule |
| Manual translation | TM rule only (no change) | TM rule only (no change) |
Not tested: a project template with its own MT and TM rules.
Closes https://www.drupal.org/project/tmgmt_smartcat/issues/3639005