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

feat: add tests for translations #833

Conversation

Computerdores
Copy link
Collaborator

Summary

Test for the following problems:

  • translation keys that are present in en.json not being present in other translations
  • translation keys that are present other translations not being present in en.json
  • translations using format keys that aren't used by the equivalent in en.json
  • translations not using format keys that are used by the equivalent in en.json

(Note that these tests currently fail and that that is intentional as the translations are incorrect at the moment)

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86
    • Linux ARM
  • Tested For:
    • Basic functionality
    • PyInstaller executable

@CyanVoxel CyanVoxel added Type: Tests Tests or testing related Type: Translation Translates or improves translation capabilities Priority: Medium An issue that shouldn't be be saved for last labels Mar 5, 2025
@Computerdores Computerdores marked this pull request as ready for review March 5, 2025 21:41
@Computerdores Computerdores added the Status: Review Needed A review of this is needed label Mar 5, 2025
@Computerdores
Copy link
Collaborator Author

this is now ready for review

@CyanVoxel
Copy link
Member

(Very funny how the failing test is a good thing in this case 😁)

One issue I have by looking at this though is that the test should not fail in the case of a full translation key being present in en.json but missing in other translations. This is expected and anticipated behavior for incomplete translations, and would mean that pytest would always fail unless each language was 100% translated. But the other 3 test scenarios listed are great things to test for

@Computerdores
Copy link
Collaborator Author

(Very funny how the failing test is a good thing in this case 😁)

One issue I have by looking at this though is that the test should not fail in the case of a full translation key being present in en.json but missing in other translations. This is expected and anticipated behavior for incomplete translations, and would mean that pytest would always fail unless each language was 100% translated. But the other 3 test scenarios listed are great things to test for

fixed

Copy link
Member

@CyanVoxel CyanVoxel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this! Looks all good to me - Normally I'd recommend using implicit concatenation for the f-strings to prevent the E501, but in this case it would look pretty odd and I'll give it a pass since it's just a test file.

I'll mark this with "blocked" while I fix the remaining issues discovered from the test here on the Weblate side, and then pull the changes as a part of #826

@CyanVoxel CyanVoxel added Status: Blocked This issue or pull request is awaiting the outcome of another issue or pull request and removed Status: Review Needed A review of this is needed labels Mar 6, 2025
@CyanVoxel CyanVoxel added this to the Alpha v9.5.1 milestone Mar 6, 2025
@CyanVoxel
Copy link
Member

Actually, I'm noticing that these tests will only report a single issue per translation file at a time. Would it be straightforward to show all detected errors at once upfront?

@CyanVoxel CyanVoxel removed the Status: Blocked This issue or pull request is awaiting the outcome of another issue or pull request label Mar 6, 2025
@CyanVoxel
Copy link
Member

Actually, I'm noticing that these tests will only report a single issue per translation file at a time. Would it be straightforward to show all detected errors at once upfront?

I'll merge this in the meantime since it's critical for v9.5.1, but it's something to consider for the future

@CyanVoxel CyanVoxel merged commit 6d1ff90 into TagStudioDev:main Mar 6, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium An issue that shouldn't be be saved for last Type: Tests Tests or testing related Type: Translation Translates or improves translation capabilities
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants