Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consistent spelling for read-only #13364

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2192,7 +2192,7 @@ and XLIFF.
:>json string note: translation unit note
:>json string flags: translation unit flags
:>json array labels: translation unit labels, available on source units
:>json int state: unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved, 100 - read only
:>json int state: unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved, 100 - read-only
:>json boolean fuzzy: whether the unit is fuzzy or marked for review
:>json boolean translated: whether the unit is translated
:>json boolean approved: whether the translation is approved
Expand Down
4 changes: 2 additions & 2 deletions weblate/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3658,14 +3658,14 @@ def test_translate_unit(self) -> None:
kwargs={"pk": unit.pk},
method="patch",
code=400,
request={"state": "100", "target": "Test read only translation"},
request={"state": "100", "target": "Test read-only translation"},
)
self.do_request(
"api:unit-detail",
kwargs={"pk": unit.pk},
method="patch",
code=400,
request={"state": "0", "target": "Test read only translation"},
request={"state": "0", "target": "Test read-only translation"},
)
self.do_request(
"api:unit-detail",
Expand Down
6 changes: 3 additions & 3 deletions weblate/auth/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ def check_edit_approved(user: User, permission: str, obj: Model):
if isinstance(obj, Unit):
unit = obj
obj = unit.translation
# Read only check is unconditional as there is another one
# Read-only check is unconditional as there is another one
# in PluralTextarea.render
if unit.readonly:
if not unit.source_unit.translated:
return Denied(gettext("The source string needs review."))
return Denied(gettext("The string is read only."))
return Denied(gettext("The string is read-only."))
# Ignore approved state if review is not disabled. This might
# happen after disabling them.
if (
Expand All @@ -289,7 +289,7 @@ def check_edit_approved(user: User, permission: str, obj: Model):
if isinstance(obj, Translation):
component = obj.component
if obj.is_readonly:
return Denied(gettext("The translation is read only."))
return Denied(gettext("The translation is read-only."))
elif isinstance(obj, Component):
component = obj
if component is not None and component.is_glossary:
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
PLAIN_FLAGS["auto-java-messageformat"] = gettext_lazy(
"Automatically detect Java MessageFormat"
)
PLAIN_FLAGS["read-only"] = gettext_lazy("Read only")
PLAIN_FLAGS["read-only"] = gettext_lazy("Read-only")
PLAIN_FLAGS["strict-same"] = gettext_lazy("Strict unchanged check")
PLAIN_FLAGS["strict-format"] = gettext_lazy("Strict format string checks")
PLAIN_FLAGS["forbidden"] = gettext_lazy("Forbidden translation")
Expand Down
2 changes: 1 addition & 1 deletion weblate/formats/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
return True

def is_readonly(self) -> bool:
"""Check whether unit is read only."""
"""Check whether unit is read-only."""
return False

def set_target(self, target: str | list[str]) -> None:
Expand All @@ -293,7 +293,7 @@
return self.unit is not None

def clone_template(self) -> None:
self.mainunit = self.unit = copy(self.template)

Check failure on line 296 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible types in assignment (expression has type "TranslationUnit | BaseItem | None", variable has type "TranslationUnit | BaseItem")
self._invalidate_target()

def untranslate(self, language) -> None:
Expand Down Expand Up @@ -356,7 +356,7 @@
self.existing_units = [] if existing_units is None else existing_units

# Load store
self.store = self.load(storefile, template_store)

Check failure on line 359 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 2 to "load" of "TranslationFormat" has incompatible type "TranslationFormat | None"; expected "TranslationStore | BaseStore | None"

self.add_breadcrumb(
"Loaded translation file {}".format(
Expand Down Expand Up @@ -510,11 +510,11 @@
@property
def all_store_units(self) -> list[InnerUnit]:
"""Wrapper for all store units for possible filtering."""
return self.store.units

Check failure on line 513 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible return value type (got "list[Any] | Sequence[TranslationUnit | BaseItem]", expected "list[TranslationUnit | BaseItem]")

@cached_property
def template_units(self) -> list[TranslationUnit]:
return [self.unit_class(self, None, unit) for unit in self.all_store_units]

Check failure on line 517 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 2 to "TranslationUnit" has incompatible type "None"; expected "TranslationUnit | BaseItem"

def _get_all_bilingual_units(self) -> list[TranslationUnit]:
return [self.unit_class(self, unit) for unit in self.all_store_units]
Expand All @@ -522,14 +522,14 @@
def _build_monolingual_unit(self, unit: TranslationUnit) -> TranslationUnit:
return self.unit_class(
self,
self.find_unit_template(unit.context, unit.source, unit.id_hash),

Check failure on line 525 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 2 to "TranslationUnit" has incompatible type "TranslationUnit | BaseItem | None"; expected "TranslationUnit | BaseItem"
unit.template,
)

def _get_all_monolingual_units(self) -> list[TranslationUnit]:
return [
self._build_monolingual_unit(unit)
for unit in self.template_store.template_units

Check failure on line 532 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Item "None" of "TranslationFormat | None" has no attribute "template_units"
]

@cached_property
Expand Down Expand Up @@ -740,8 +740,8 @@
)[0]
else:
template_unit = None
result = self.unit_class(self, unit, template_unit)

Check failure on line 743 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 2 to "TranslationUnit" has incompatible type "weblate.formats.base.TranslationUnit"; expected "translate.storage.base.TranslationUnit | BaseItem"

Check failure on line 743 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 3 to "TranslationUnit" has incompatible type "weblate.formats.base.TranslationUnit | None"; expected "translate.storage.base.TranslationUnit | BaseItem | None"
mono_unit = self.unit_class(self, None, unit)

Check failure on line 744 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 2 to "TranslationUnit" has incompatible type "None"; expected "TranslationUnit | BaseItem"

Check failure on line 744 in weblate/formats/base.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 3 to "TranslationUnit" has incompatible type "weblate.formats.base.TranslationUnit"; expected "translate.storage.base.TranslationUnit | BaseItem | None"

# Update cached lookups
if "all_units" in self.__dict__:
Expand Down
2 changes: 1 addition & 1 deletion weblate/templates/snippets/unit-readonly-badge.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
{% elif unit.is_source %}
<span class="badge" title="{% trans "The source string cannot be edited." %}">{% trans "Source string" %}</span>
{% else %}
<span class="badge">{% trans "Read only" %}</span>
<span class="badge">{% trans "Read-only" %}</span>
{% endif %}
{% endif %}
2 changes: 1 addition & 1 deletion weblate/templates/translate.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ <h4 class="panel-title">
type="submit"
name="suggest"
{% if project_locked or not user_can_suggest or unit.readonly %}disabled="disabled"{% endif %}
{% if not user_can_suggest %} title="{% trans "Insufficient privileges for adding suggestions." %}" {% elif project_locked %} title="{% trans "This translation is currently locked." %}" {% elif unit.readonly %} title="{% trans "Read only" %}" {% endif %}>
{% if not user_can_suggest %} title="{% trans "Insufficient privileges for adding suggestions." %}" {% elif project_locked %} title="{% trans "This translation is currently locked." %}" {% elif unit.readonly %} title="{% trans "Read-only" %}" {% endif %}>
{% icon "suggest.svg" %} {% trans "Suggest" %}
</button>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions weblate/trans/migrations/0001_squashed_weblate_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ class Migration(migrations.Migration):
(10, "Needs editing"),
(20, "Translated"),
(30, "Approved"),
(100, "Read only"),
(100, "Read-only"),
],
default=0,
),
Expand All @@ -1042,7 +1042,7 @@ class Migration(migrations.Migration):
(10, "Needs editing"),
(20, "Translated"),
(30, "Approved"),
(100, "Read only"),
(100, "Read-only"),
],
default=0,
),
Expand Down
4 changes: 2 additions & 2 deletions weblate/trans/models/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,15 +685,15 @@ def get_unit_state(self, unit, flags: str | None, string_changed: bool = False):
return STATE_READONLY

if flags is not None:
# Read only from the source
# Read-only from the source
if (
not self.is_source
and self.source_unit.state < STATE_TRANSLATED
and self.translation.component.intermediate
):
return STATE_READONLY

# Read only from flags
# Read-only from flags
if "read-only" in self.get_all_flags(flags):
return STATE_READONLY

Expand Down
2 changes: 1 addition & 1 deletion weblate/trans/tests/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ def test_readonly(self) -> None:
self.component.edit_template = False
self.component.save()

# It should be now read only
# It should be now read-only
self.assertEqual(source.unit_set.all()[0].state, STATE_READONLY)


Expand Down
2 changes: 1 addition & 1 deletion weblate/utils/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class StringState(IntegerChoices):
STATE_FUZZY = 10, pgettext_lazy("String state", "Needs editing")
STATE_TRANSLATED = 20, pgettext_lazy("String state", "Translated")
STATE_APPROVED = 30, pgettext_lazy("String state", "Approved")
STATE_READONLY = 100, pgettext_lazy("String state", "Read only")
STATE_READONLY = 100, pgettext_lazy("String state", "Read-only")


STATE_EMPTY = StringState.STATE_EMPTY
Expand Down
Loading