Fixes: Translations Are Not Correctly Tested in Our PR Workflow
What kind of change does this PR introduce?
Issue Number:
Fixes #2260
Did you add tests for your changes? No
Snapshots/Videos:
If relevant, did you update the documentation? No
Summary
- Modified compare_translations.py to handle nested JSON objects correctly. The previous implementation only compared top-level keys, causing issues with missing or extra keys in nested structures.
- Added the function "flatten_json" to recursively compare keys for nested json.
- Error messages now show the full key path using dot notation .
Does this PR introduce a breaking change? No
Other information
Have you read the contributing guide?
Yes
Summary by CodeRabbit
-
New Features
- Introduced a function to flatten nested JSON objects, improving data usability.
- Updated translation loading to return flattened data for easier handling.
- Expanded localization capabilities with new key-value pairs in multiple languages, enhancing user experience.
-
Bug Fixes
- Adjusted the default directory path for translation files to ensure correct file access.
Walkthrough
The pull request introduces a new function, flatten_json, to flatten nested JSON objects, enhancing the handling of translation data. The load_translation function is modified to return a flattened dictionary instead of the original. Additionally, the default directory path for translation files is updated from "locales" to "public/locales", affecting the file retrieval process during execution. Several new translations are added across multiple languages, improving the application's multilingual support.
Changes
| Files | Change Summary |
|---|---|
src/github/workflows/compare_translations.py |
Added flatten_json function for flattening nested JSON; modified load_translation to return a flattened dictionary; updated default directory path in main function. |
public/locales/en/translation.json |
Added numerous new key-value pairs for user interface strings related to authentication and organization management. |
public/locales/hi/translation.json |
Added new key-value pairs for user roles and chat functionality. |
public/locales/zh/translation.json |
Enhanced translations for user interface elements related to login and organization management. |
public/locales/fr/translation.json |
Added new translations for user authentication and management, improving usability. |
public/locales/sp/translation.json |
Introduced new translations and modified existing ones related to advertisements and user management. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Ensure translations are correctly tested during PR workflow (#2260) | ✅ | |
| Ensure all translations are present for non-default languages (#2260) | ❌ | The PR does not guarantee completeness of translations. |
Possibly related PRs
- #2021: Involves translation fixes in various JSON files, relevant to changes in translation handling.
- #2029: Updates translation.json with new translations and modifications, aligning with the main PR's focus on enhancing translation data usability.
- #2074: Fixes translation issues on user-related pages, relevant to localization and translation data.
- #2078: Focuses on adding translations for error and success messages, relating to the main PR's updates in processing translation data.
- #2254: Enhances localization support for user interface elements, which is directly related to the main PR's changes in translation handling.
Poem
In the burrow where translations play,
A flattening function brightens the day.
With paths now clear, the files align,
Ensuring our words in every design.
Hop, hop, hooray for changes so fine! 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
--
I pushed a fix in commit <commit_id>, please review it.--Generate unit testing code for this file.-
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples: --@coderabbitai generate unit testing code for this file.--@coderabbitai modularize this function. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: --@coderabbitai generate interesting stats about this repository and render them as a table.--@coderabbitai read src/utils.ts and generate unit testing code.--@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.--@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Our Pull Request Approval Process
We have these basic policies to make the approval process smoother for our volunteer team.
Testing Your Code
Please make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:
- The overall code coverage drops below the target threshold of the repository
- Any file in the pull request has code coverage levels below the repository threshold
- Merge conflicts
The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.
Reviewers
Do not assign reviewers. Our Queue Monitors will review your PR and assign them. When your PR has been assigned reviewers contact them to get your code reviewed and approved via:
- comments in this PR or
- our slack channel
Reviewing Your Code
Your reviewer(s) will have the following roles:
- arbitrators of future discussions with other contributors about the validity of your changes
- point of contact for evaluating the validity of your work
- person who verifies matching issues by others that should be closed.
- person who gives general guidance in fixing your tests
CONTRIBUTING.md
Read our CONTRIBUTING.md file. Most importantly:
- PRs with issues not assigned to you will be closed by the reviewer
- Fix the first comment in the PR so that each issue listed automatically closes
Other
- :dart: Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
- Read the CONTRIBUTING.md file make
Created a separate issue to sync the translations.
Please add the missing translations in this PR or else all new PRs will fail
Okay sure
- Please fix the failing tests. The translation check either isn't working correctly or you have missing translations.
- We cannot merge this PR until the checks are fixed or else all other PRs will fail before the code base is tested.
- Please fix the failing tests. The translation check either isn't working correctly or you have missing translations.
- We cannot merge this PR until the checks are fixed or else all other PRs will fail before the code base is tested.
Yes, two of the files were missing some translations. I have added them and no other translations are remaining now. Could you please review them?
Please fix the failing tests.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 97.54%. Comparing base (
ceb5cce) to head (7d61090). Report is 1 commits behind head on develop.
Additional details and impacted files
@@ Coverage Diff @@
## develop #2263 +/- ##
========================================
Coverage 97.54% 97.54%
========================================
Files 241 241
Lines 6883 6887 +4
Branches 2001 2005 +4
========================================
+ Hits 6714 6718 +4
Misses 157 157
Partials 12 12
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hi @palisadoes ! I have made all the changes, could you please review them?