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

Compare number of HTML/XML entities in check #6478

Closed
Findus23 opened this issue Aug 27, 2021 · 6 comments
Closed

Compare number of HTML/XML entities in check #6478

Findus23 opened this issue Aug 27, 2021 · 6 comments
Labels
wontfix Nobody will work on this.

Comments

@Findus23
Copy link
Contributor

Is your feature request related to a problem? If so, please describe.

Matomo currently on import of translations contains a check that makes sure translations only contain HTML entities when the source string contains them:
https://github.com/matomo-org/matomo/blob/115527353a9e75e01aa4d263408956ae45403bea/plugins/LanguagesManager/TranslationWriter/Filter/EncodedEntities.php

Now when moving to weblate, it would be great if the built-in checks could help with this. I saw in weblate/weblate/checks/markup.py that there are already quite a few checks around XML tags and highlighting of entities, so maybe something could be added here.

Describe the solution you'd like

A check that warns in e.g. this case:
Source: <b>some text</b>
Translation: &lt;b&gt;some text&lt;/b&gt;

Maybe a more generalized solution to this would be a check that compares if the same HTML entities are in source and translation. This would also catch the other case where the source text has an entity, but it is missing in the translation.

Describe alternatives you've considered

One could still keep the check as a CI test in Matomo, but having it in weblate makes it easier to fix.

Screenshots

Additional context

@github-actions
Copy link

github-actions bot commented Sep 7, 2021

This issue has been automatically marked as stale because there wasn’t any recent activity.

It will be closed soon if no further action occurs.

Thank you for your contributions!

@github-actions github-actions bot added the wontfix Nobody will work on this. label Sep 7, 2021
@Findus23
Copy link
Contributor Author

Findus23 commented Sep 7, 2021

I think this is not inactive. (Sorry for everyone who now gets a useless notification because of me)

Maybe you could update https://github.com/WeblateOrg/weblate/blob/main/.github/ISSUE_TEMPLATE/feature_request.md to add an

labels: [Enhancement]

so that feature requests are not automatically closed due to inactivity after a few days.

@nijel
Copy link
Member

nijel commented Sep 7, 2021

Sorry, we're a bit slow on triaging things. It's intentional that the template does not contain labels, they should be really set after triaging.

What might be useful to you is adding safe-html flag to your components, see https://docs.weblate.org/en/latest/user/checks.html#unsafe-html. But I'm not sure right now whether it covers entities as well (it does cover HTML tags).

@Findus23
Copy link
Contributor Author

Findus23 commented Sep 7, 2021

Hi,

No worries, triaging doesn't need to be fast. But it might be useful then to update the bot to only consider already triaged issues to avoid useless bumps.

safe-html can't detect this case at the moment as &lt;b&gt;some text&lt;/b&gt; cleaned by bleach stays the same. But maybe a fix for #6490 could also consider this case. (And now that we are done with the migration, I have to admit that there aren't that many cases where this check would be useful).

@nijel
Copy link
Member

nijel commented Sep 7, 2021

It should bump such issues to push us to triaging. Otherwise, they would be forgotten forever :-).

Ah the bleach check doesn't validate whether there are same tags, but that no other tags than in source are used. This should be done by the XML markup check, I think it should catch the string you've mentioned in the initial post.

@github-actions github-actions bot removed the wontfix Nobody will work on this. label Sep 8, 2021
@github-actions
Copy link

This issue has been automatically marked as stale because there wasn’t any recent activity.

It will be closed soon if no further action occurs.

Thank you for your contributions!

@github-actions github-actions bot added the wontfix Nobody will work on this. label Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Nobody will work on this.
Projects
None yet
Development

No branches or pull requests

2 participants