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

Impossible to ignore the "auto-java-messageformat" flag with "ignore-java-format" (or "ignore-all-checks") #9268

Closed
2 tasks done
dwgigs opened this issue May 18, 2023 · 1 comment
Assignees
Labels
bug Something is broken.
Milestone

Comments

@dwgigs
Copy link

dwgigs commented May 18, 2023

Describe the issue

When using Java properties file, the flag "auto-java-messageformat" is automatically added to all strings.

The documentation states to use "ignore-java-format" to ignore this check.

But here's the implementation of the JavaMessageFormatCheck should_skip method:

def should_skip(self, unit):
    if "auto-java-messageformat" in unit.all_flags and "{0" in unit.source:
        return False

    return super().should_skip(unit)

The check for the auto flag is always checked before the "ignore-java-format" check that is done in the super. Making it impossible to disable this check when the file type is properly defined.

I believe this makes the documentation wrong, and the ignore flag useless.

Being able to ignore this check is important, for example, in my use case, we have custom code that automatically doubles single quotes, so we don't need the check and we can replace it with a placeholders flag instead.

I believe the correct implementation might be something like:

def should_skip(self, unit):
    return super().should_skip(unit) or not ("auto-java-messageformat" in unit.all_flags and "{0" in unit.source)

I already tried

  • I've read and searched the documentation.
  • I've searched for similar issues in this repository.

Steps to reproduce the behavior

  1. Create a component that uses Java Properties file
  2. Go the the components settings > Translation
  3. In the Translation flags field enter: ignore-java-format
  4. Save
  5. Add a new string to the component: key=TEST_KEY, value=T'is but a test {0}

For another repor:
Same steps but replace ignore-java-format by ignore-all-checks

Expected behavior

There is no failed check since the check should be ignored by flags

Screenshots

No response

Exception traceback

No response

How do you run Weblate?

weblate.org service

Weblate versions

Weblate 4.18-dev on hosted.weblate.org

Weblate deploy checks

No response

Additional context

No response

@nijel nijel self-assigned this May 19, 2023
@nijel nijel added the bug Something is broken. label May 19, 2023
@nijel nijel added this to the 4.18 milestone May 19, 2023
@nijel nijel closed this as completed in 7e35293 May 19, 2023
@github-actions
Copy link

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken.
Projects
None yet
Development

No branches or pull requests

2 participants