diff --git a/scripts/sync_translations.py b/scripts/sync_translations.py index f1ab292a4e1..b98b289e2f3 100644 --- a/scripts/sync_translations.py +++ b/scripts/sync_translations.py @@ -113,6 +113,7 @@ def sync_translations(self, language_code, old_resource, new_resource): if old_attr_value != getattr(new_translation, attr, None): updates[attr] = old_attr_value + # Avoid overwriting more recent translations in the open-edx/openedx-translations project newer_translation_found = False if translation_from_old_project.datetime_translated and new_translation.datetime_translated: old_project_translation_time = datetime.fromisoformat( @@ -120,8 +121,7 @@ def sync_translations(self, language_code, old_resource, new_resource): new_project_translation_time = datetime.fromisoformat( new_translation.datetime_translated.replace('Z', '+00:00')) - if new_project_translation_time > old_project_translation_time: - newer_translation_found = True + newer_translation_found = new_project_translation_time > old_project_translation_time if updates: if newer_translation_found: diff --git a/scripts/tests/test_sync_translations.py b/scripts/tests/test_sync_translations.py index 5f752c4c943..338cfc4bd7a 100644 --- a/scripts/tests/test_sync_translations.py +++ b/scripts/tests/test_sync_translations.py @@ -88,3 +88,10 @@ def test_get_translations(): items = list(data) assert len(items) == 1 assert items[0].id == response_data.RESPONSE_GET_LANGUAGE['data'][0]['id'] + + +@responses.activate +def test_more_recent_translations_not_overridden(): + """ + Verify that the more recent translations in the open-edx/openedx-translations project are not overridden. + """