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

Add workflow to validate XML translation files #1033

Merged
merged 15 commits into from
Feb 24, 2023
Merged

Add workflow to validate XML translation files #1033

merged 15 commits into from
Feb 24, 2023

Conversation

cewert
Copy link
Member

@cewert cewert commented Feb 20, 2023

This adds a github workflow called lint.yml which is our old workflow validate.yml copied over with a new step to validate translation files. The new step also checks for duplicate entries per file but currently doesn't throw an error when it finds them. There are a bunch around 1300 between all the translation files that need to be fixed. After that, we can make the workflow throw an error to prevent manually adding a duplicate entry

Context: A while back we had a translation file get malformed (missing a closing tag I believe) and that broke a lot (all?) of the translation strings for the app. This workflow should prevent that from happening again

Changes

  • Create lint.yml
    • Copy over old workflow validate.yml into "brightscript" step
    • Create new "translation-files" step
      • validate syntax of all translation XML files (.ts)
      • check for duplicate entries in each file (using the "source" tag)
  • Delete old workflow validate.yml
  • recommend vscode red hat XML extension
  • use vscode extension to format all translation files
    • add user setting for XML extension. this will keep tags on one line instead of two when formatting on save. Needed for duplicate checking

Issues
Fixes #708

@cewert
Copy link
Member Author

cewert commented Feb 20, 2023

I also looked into validating the XML files against the DTD that .ts files use but because the DTD is invalid according to the file itself "This element wildcard is no valid DTD. No better solution available." all of the apps I used to try and validate our XML files just spit out errors about the DTD file being malformed. I managed to edit the DTD file and validate the files against that but since DTD files are new to me I didn't feel confident in adding my hacked DTD file to this PR

After hacking the DTD file so i could validate, all our files looked fine with the exception of extracomment and any other tags we are manually adding being in the wrong order. the order of the XML tags in our translation file should match the order they appear in the DTD file which is this line I believe: <!ELEMENT message (location*, source?, oldsource?, comment?, oldcomment?, extracomment?, translatorcomment?, translation?, userdata?, extra-**) >

so it should look like this

<message>
     <source></source>
     <extracomment></extracomment>
     <translation></translation>
</message>

not this

<message>
     <source></source>
     <translation></translation>
     <extracomment></extracomment>
</message>

edit: or maybe my hacked DTD file was wrong? weblate seems to commit them in the "wrong" order. I'm not sure but I'm not really worried about validating with the DTD file. I think syntax and duplicate checking would be enough.

@cewert
Copy link
Member Author

cewert commented Feb 23, 2023

I think I'm done messing with this PR now. I have a couple more things I want to do with workflows but I'll start a new PR

@cewert cewert merged commit 710cd27 into jellyfin:unstable Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add XML linting to CI
2 participants