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

propagate/[re]trigger checks on other units for a "translations must be unique" check #3873

Open
cloph opened this issue May 14, 2020 · 4 comments
Labels
enhancement Adding or requesting a new feature.

Comments

@cloph
Copy link

cloph commented May 14, 2020

Is your feature request related to a problem? Please describe.
Currently/to my knowledge it is not possible to write a check that spans multiple units, for example: "all strings with context:"foo" must have unique strings in translation" – or rather while it is possible to write such a check, there is no way to way to trigger a recheck when any of the strings is updated. You can clear the check flag in the currently edited unit, but other strings flagged won't get rechecked/still would have the "duplicate translation" error assigned.

Describe the solution you'd like
Be able to define a constraint on multiple units, be it by context, flag or some other existing property or on the current component, and have the check evaluated on all the units matching the constraint whenever a matching unit changes check-state.

Describe alternatives you've considered
Alternatives would be to just trigger updatechecks in a cronjob constantly, but that to my knowledge cannot be limited to a specific check/has additional overhead and no immediate feedback.

Additional context
Other solutions of course welcome, I might not be aware of another way that already can do what I want. (could need this in LibreOffice project - Calc function names need to have a unique translation for example. In our case it would also work be desirable (and/or sufficient, depending how you look at it) if it would limit the search for matching units to the current component. So "component-wide" check or "units matching a constraint" would both work for me.

@nijel
Copy link
Member

nijel commented May 14, 2020

There already is Inconsistent check which does similar thing:

class ConsistencyCheck(TargetCheck):
"""Check for inconsistent translations."""
check_id = "inconsistent"
name = _("Inconsistent")
description = _(
"This string has more than one translation in this project "
"or is not translated in some components."
)
ignore_untranslated = False
severity = "warning"
propagates = True
def check_target_unit(self, sources, targets, unit):
for other in unit.same_source_units:
if unit.target == other.target:
continue
if unit.translated or other.state >= STATE_TRANSLATED:
return True
return False
def check_single(self, source, target, unit):
"""We don't check target strings here."""
return False

That also uses the only constraint currently supported.

@nijel nijel added the enhancement Adding or requesting a new feature. label May 14, 2020
@nijel
Copy link
Member

nijel commented May 14, 2020

There is also #1994 which pretty much describes same problem.

@comradekingu
Copy link
Contributor

comradekingu commented May 16, 2020

Variant of this, the letter following a _ or & must be unique in the translation (provided it isn't a URL).

@nijel
Copy link
Member

nijel commented May 17, 2020

@comradekingu It must be unique in single scope, what is something Weblate doesn't know without additional metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature.
Projects
None yet
Development

No branches or pull requests

3 participants