talawa-admin icon indicating copy to clipboard operation
talawa-admin copied to clipboard

Fixes: Translations Are Not Correctly Tested in Our PR Workflow

Open Nandika-A opened this issue 1 year ago • 4 comments

What kind of change does this PR introduce?

Issue Number:

Fixes #2260

Did you add tests for your changes? No

Snapshots/Videos:

image

If relevant, did you update the documentation? No

Summary

  1. 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.
  2. Added the function "flatten_json" to recursively compare keys for nested json.
  3. 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.

Nandika-A avatar Sep 11 '24 09:09 Nandika-A

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?

Share
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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere 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.

coderabbitai[bot] avatar Sep 11 '24 10:09 coderabbitai[bot]

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:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. 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:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. :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.
  2. Read the CONTRIBUTING.md file make

github-actions[bot] avatar Sep 11 '24 10:09 github-actions[bot]

Created a separate issue to sync the translations.

pranshugupta54 avatar Sep 13 '24 17:09 pranshugupta54

Please add the missing translations in this PR or else all new PRs will fail

Okay sure

Nandika-A avatar Sep 13 '24 18:09 Nandika-A

  1. Please fix the failing tests. The translation check either isn't working correctly or you have missing translations.
  2. We cannot merge this PR until the checks are fixed or else all other PRs will fail before the code base is tested.

palisadoes avatar Sep 15 '24 03:09 palisadoes

  1. Please fix the failing tests. The translation check either isn't working correctly or you have missing translations.
  2. 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?

Nandika-A avatar Sep 15 '24 09:09 Nandika-A

Please fix the failing tests.

palisadoes avatar Sep 15 '24 13:09 palisadoes

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.

codecov[bot] avatar Sep 15 '24 19:09 codecov[bot]

Hi @palisadoes ! I have made all the changes, could you please review them?

Nandika-A avatar Sep 17 '24 10:09 Nandika-A