fix(translate): leave user-edited translations alone on glossary edits
This commit is contained in:
1 parent
5d00262c19
commit
dbb2f07713
1 file changed
+6
-2
@@ -255,6 +255,12 @@ void TranslationService::applyGlossaryEdits(const GlossaryStore::Glossary &previ
|
|||||||
if (m_lastTranslationPath.isEmpty() || !QFileInfo::exists(m_lastTranslationPath)) {
|
if (m_lastTranslationPath.isEmpty() || !QFileInfo::exists(m_lastTranslationPath)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// A translation the user has edited since is theirs; leave it alone.
|
||||||
|
const QString registryFile = TranslationStore::registryFile();
|
||||||
|
TranslationStore::Registry registry = TranslationStore::load(registryFile);
|
||||||
|
if (!TranslationStore::isOwned(registry, m_lastTranslationPath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
QFile file(m_lastTranslationPath);
|
QFile file(m_lastTranslationPath);
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
return;
|
return;
|
||||||
@@ -307,8 +313,6 @@ void TranslationService::applyGlossaryEdits(const GlossaryStore::Glossary &previ
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Still QtPotato's file, so a later translation may replace it.
|
// Still QtPotato's file, so a later translation may replace it.
|
||||||
const QString registryFile = TranslationStore::registryFile();
|
|
||||||
TranslationStore::Registry registry = TranslationStore::load(registryFile);
|
|
||||||
TranslationStore::recordRewrite(registry, m_lastTranslationPath, data);
|
TranslationStore::recordRewrite(registry, m_lastTranslationPath, data);
|
||||||
TranslationStore::save(registryFile, registry);
|
TranslationStore::save(registryFile, registry);
|
||||||
Q_EMIT translated(QUrl::fromLocalFile(m_lastTranslationPath), true);
|
Q_EMIT translated(QUrl::fromLocalFile(m_lastTranslationPath), true);
|
||||||
|
|||||||
Reference in new issue
Block a user