Allow to lock a translation
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3554530. --> Reported by: [claudiu.cristea](https://www.drupal.org/user/56348) Related to !72 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Scenario</p> <ul> <li>As a translator, when I edit or add a non-empty translation via UI, the translation is automatically locked, so that is neither exported in files, nor is picked by the TMGMT source plugin.</li> <li>As a translator, when I visit the translation UI, I can see an Unlock button for each row, which is enabled only for the locked translations and disabled for the rest.</li> <li>As a translator, when I visit the translation UI, I can press an enabled button at row level, and the translation becomes unlocked.</li> </ul> <p>Note that TMGMT source plugin is added in <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/babel/-/work_items/3554005" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/babel/-/work_items/3554005</a></span></p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <ul> <li>Add a new property in<code> \Drupal\babel\Model\Source</code>: <code>protected bool $locked = FALSE</code> plus getter/setter.</li> <li>Create a new table <code>{babel_source_lock}</code> to store the values per-language with 2 fields: <code>hash</code>, <code>langcode</code>. Together they are the primary key.</li> <li>When a string is locked for a certain language, an entry is added in the table. On unlocking, the record is deleted.</li> <li>When a user adds or edits a translation via UI, the string is being locked for that language. By editing, we understand that the translated final string is different from the initial one.</li> <li>Locked strings are removed from file export</li> <li>Locked strings are not picked up by TMGMT source plugin</li> <li>On translation form, on each row, we show an 'Unlock' button. <ul> <li>Button is disabled for unlocked translations</li> <li> As soon as a translation is locked the button becomes available</li> <li> If the user presses the button it unlocks the translation,</li> <li> Proper icons to be used for the button: a closed lock for enabled button, a grayed-out opened lock for the disabled button. Proper tooltip to be rendered</li> </ul> </li> <li>For the Locale module we should propagate the locked value to the <code>customized</code> column from <code>{locales_target}</code>.</li> </ul>
issue