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

Refactor Translation Logic and Make It More Testable #962

Merged
merged 5 commits into from
Dec 4, 2023

Conversation

pjkaufman
Copy link
Collaborator

Fixes #689

There were some things noted about the translation helper that needed work. So I went ahead and gave it some more love to make it easier to work with logic-wise. There are still things that can be improved around it, but the helper methods and logic that was refactored should make things a decent bit clearer and easier to test.

Some tests were added to help make sure issues around locale files not mapping properly between their short code value and the file name could be caught earlier.

Changes Made:

  • Added UTs to make sure all locales that exist refer to a unique file that exists in the locales directory
  • Added a type for partial locales
  • Updated docs for adding a language to include info and a rationale about why the locale to file name mapping is important
  • Refactored esbuild setup to make things simpler to use and make sure that there would be less logic that needs updating when a change to the config is made
  • Setup some more helper methods around translations like getting the file referenced by a language short code/locale
  • Added a couple of validators for user input for the translation helper that helps with input validation and not needing to nest ifs
  • Refactored some translation helper logic to make sure common parts got reused better and helped clear up some complexity by removing if statements where possible

pjkaufman and others added 5 commits December 4, 2023 12:10
…hen and get mapped back to a unique and existing locale file when dealing with translations. It is not the best at making sure that imports match the exact file they reference, but that can be left up to the reviewer at least for now
@pjkaufman pjkaufman added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Dec 4, 2023
@pjkaufman pjkaufman self-assigned this Dec 4, 2023
@pjkaufman pjkaufman merged commit d8f7f0c into platers:master Dec 4, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean Up: Break Translation Helper Into Parts and Add UTs for It
1 participant