Skip to content

Commit

Permalink
changes: Do not track duplicate languages in changes
Browse files Browse the repository at this point in the history
- alert is a better place to notify about this
- duplicate languages typically do not disappear, so the change would
  repeat on every commit or file update
- this is essetially same as 81aa107,
  see #9593
  • Loading branch information
nijel committed Aug 8, 2023
1 parent 8d753a6 commit 8ebd538
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 10 deletions.
88 changes: 88 additions & 0 deletions weblate/trans/migrations/0179_alter_change_action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Generated by Django 4.2.3 on 2023-08-08 12:09

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("trans", "0178_rename_details_new_alert_details_and_more"),
]

operations = [
migrations.AlterField(
model_name="change",
name="action",
field=models.IntegerField(
choices=[
(0, "Resource update"),
(1, "Translation completed"),
(2, "Translation changed"),
(5, "New translation"),
(3, "Comment added"),
(4, "Suggestion added"),
(6, "Automatic translation"),
(7, "Suggestion accepted"),
(8, "Translation reverted"),
(9, "Translation uploaded"),
(13, "New source string"),
(14, "Component locked"),
(15, "Component unlocked"),
(17, "Committed changes"),
(18, "Pushed changes"),
(19, "Reset repository"),
(20, "Merged repository"),
(21, "Rebased repository"),
(22, "Failed merge on repository"),
(23, "Failed rebase on repository"),
(28, "Failed push on repository"),
(24, "Parse error"),
(25, "Removed translation"),
(26, "Suggestion removed"),
(27, "Search and replace"),
(29, "Suggestion removed during cleanup"),
(30, "Source string changed"),
(31, "New string added"),
(32, "Bulk status change"),
(33, "Changed visibility"),
(34, "Added user"),
(35, "Removed user"),
(36, "Translation approved"),
(37, "Marked for edit"),
(38, "Removed component"),
(39, "Removed project"),
(41, "Renamed project"),
(42, "Renamed component"),
(43, "Moved component"),
(44, "New string to translate"),
(45, "New contributor"),
(46, "New announcement"),
(47, "New alert"),
(48, "Added new language"),
(49, "Requested new language"),
(50, "Created project"),
(51, "Created component"),
(52, "Invited user"),
(53, "Received repository notification"),
(54, "Replaced file by upload"),
(55, "License changed"),
(56, "Contributor agreement changed"),
(57, "Screnshot added"),
(58, "Screnshot uploaded"),
(59, "String updated in the repository"),
(60, "Add-on installed"),
(61, "Add-on configuration changed"),
(62, "Add-on uninstalled"),
(63, "Removed string"),
(64, "Removed comment"),
(65, "Resolved comment"),
(66, "Explanation updated"),
],
db_index=True,
default=2,
),
),
]
24 changes: 24 additions & 0 deletions weblate/trans/migrations/0180_change_duplicate_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Generated by Django 4.2.3 on 2023-08-08 12:10

from django.db import migrations


def change_duplicate_language(apps, schema_editor):
Change = apps.get_model("trans", "Change")
Change.objects.using(schema_editor.connection.alias).filter(action=40).delete()


class Migration(migrations.Migration):
dependencies = [
("trans", "0179_alter_change_action"),
]

operations = [
migrations.RunPython(
change_duplicate_language, migrations.RunPython.noop, elidable=True
)
]
5 changes: 1 addition & 4 deletions weblate/trans/models/change.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Change(models.Model, UserDisplayMixin):
ACTION_MARKED_EDIT = 37
ACTION_REMOVE_COMPONENT = 38
ACTION_REMOVE_PROJECT = 39
ACTION_DUPLICATE_LANGUAGE = 40
# Used to be ACTION_DUPLICATE_LANGUAGE = 40
ACTION_RENAME_PROJECT = 41
ACTION_RENAME_COMPONENT = 42
ACTION_MOVE_COMPONENT = 43
Expand Down Expand Up @@ -340,8 +340,6 @@ class Change(models.Model, UserDisplayMixin):
# Translators: Name of event in the history
(ACTION_REMOVE_PROJECT, gettext_lazy("Removed project")),
# Translators: Name of event in the history
(ACTION_DUPLICATE_LANGUAGE, gettext_lazy("Found duplicated language")),
# Translators: Name of event in the history
(ACTION_RENAME_PROJECT, gettext_lazy("Renamed project")),
# Translators: Name of event in the history
(ACTION_RENAME_COMPONENT, gettext_lazy("Renamed component")),
Expand Down Expand Up @@ -449,7 +447,6 @@ class Change(models.Model, UserDisplayMixin):
ACTION_FAILED_PUSH,
ACTION_LOCK,
ACTION_UNLOCK,
ACTION_DUPLICATE_LANGUAGE,
}

# Actions where target is rendered as translation string
Expand Down
6 changes: 0 additions & 6 deletions weblate/trans/models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -2315,12 +2315,6 @@ def _create_translations( # noqa: C901
filenames = f"{path}, {languages[lang.code].filename}"
detail = f"{lang.code} ({codes})"
self.log_warning("duplicate language found: %s", detail)
Change.objects.create(
component=self,
user=request.user if request else self.acting_user,
target=detail,
action=Change.ACTION_DUPLICATE_LANGUAGE,
)
self.trigger_alert(
"DuplicateLanguage",
codes=codes,
Expand Down

0 comments on commit 8ebd538

Please sign in to comment.