Skip to content

Added translation support for dashboard analytics report scripts #2791

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

kzamanbd
Copy link
Contributor

@kzamanbd kzamanbd commented Jul 9, 2025

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

How to test the changes in this Pull Request:

  • Steps or issue link

Changelog entry

**enhancement:** Added translation support for dashboard analytics report scripts to improve internationalization (i18n).

Before Changes

Describe the issue before changes with screenshots(s).

After Changes

Describe the issue after changes with screenshot(s).

Feature Video (optional)

Link of detailed video if this PR is for a feature.

PR Self Review Checklist:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

  • New Features

    • Added localization support for the vendor analytics script on the front end.
  • Bug Fixes

    • Updated text domain for withdrawal form labels and placeholders to ensure correct localization.
  • Refactor

    • Simplified dashboard component loading by removing lazy loading and suspense mechanisms; components are now loaded synchronously.
    • Removed unused imports and code related to asynchronous component loading.

@kzamanbd kzamanbd requested a review from mrabbani July 9, 2025 04:54
@kzamanbd kzamanbd self-assigned this Jul 9, 2025
@kzamanbd kzamanbd added Needs: Testing This requires further testing Needs: Dev Review It requires a developer review and approval labels Jul 9, 2025
Copy link
Contributor

coderabbitai bot commented Jul 9, 2025

Walkthrough

The changes update text domains for internationalization from 'dokan' to 'dokan-lite' in several frontend components, add localization support for the vendor analytics script using wp_set_script_translations, and remove lazy loading (React.lazy/Suspense) for dashboard components in favor of synchronous imports. No logic or control flow is otherwise altered.

Changes

Files/Group Change Summary
includes/Analytics/Assets.php Added wp_set_script_translations call for 'vendor_analytics_script' with 'dokan-lite' text domain.
src/dashboard/withdraw/RequestWithdrawBtn.tsx Changed i18n text domain from 'dokan' to 'dokan-lite' for label and placeholder.
src/vendor-dashboard/reports/dashboard/default-sections.js,
src/vendor-dashboard/reports/dashboard/index.js,
src/vendor-dashboard/reports/layout/controller.js
Removed React.lazy/Suspense and Spinner fallback; switched to synchronous imports; removed lazy loading for dashboard sections and controller. Also removed unused imports.

Sequence Diagram(s)

sequenceDiagram
    participant WP as WordPress
    participant Assets as includes/Analytics/Assets.php
    participant Frontend as Vendor Analytics Script

    WP->>Assets: Enqueue vendor_analytics_script
    Assets->>WP: Call wp_set_script_translations('vendor_analytics_script', 'dokan-lite')
    WP->>Frontend: Serve localized analytics script with translations
Loading

Assessment against linked issues

Objective Addressed Explanation
Make "Transaction Date", "Balance Date", and "Balance" in Reports translatable (#4484) No code changes directly address the translation of these specific strings in the Reports UI.

Assessment against linked issues: Out-of-scope changes

Code Change (file_path) Explanation
Remove lazy loading and Suspense for dashboard components (src/vendor-dashboard/reports/dashboard/index.js, default-sections.js, layout/controller.js) These changes relate to frontend optimization and import structure, not to translation/localization or the linked issue objectives.

Possibly related PRs

Suggested labels

QA approved, :+1: Dev Review Done, Upcoming Release

Suggested reviewers

  • mrabbani
  • shohag121

Poem

In the dashboard’s gentle light,
Translations now take flight!
Scripts and styles, all in sync,
Lazy loads are gone in a blink.
Rabbits hop with glee anew—
“dokan-lite” brings words for you!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-14T07_59_44_447Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a105cb and 920eea4.

📒 Files selected for processing (1)
  • src/vendor-dashboard/reports/dashboard/default-sections.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/vendor-dashboard/reports/dashboard/default-sections.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: e2e tests (1, 3)
  • GitHub Check: e2e tests (3, 3)
  • GitHub Check: api tests (1, 1)
  • GitHub Check: e2e tests (2, 3)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/vendor-dashboard/reports/layout/controller.js (1)

8-8: Clean up: Unused lodash import.

The find import from lodash appears to be unused after the changes.

Consider removing the unused import:

-import { isEqual, last, omit } from "lodash";
+import { isEqual, last, omit } from "lodash";

Wait, I need to verify this. Let me check if find is actually used in the code...

Looking at the code, I don't see find being used anywhere. The import should be removed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 017d357 and f538c50.

📒 Files selected for processing (5)
  • includes/Analytics/Assets.php (1 hunks)
  • src/dashboard/withdraw/RequestWithdrawBtn.tsx (2 hunks)
  • src/vendor-dashboard/reports/dashboard/default-sections.js (1 hunks)
  • src/vendor-dashboard/reports/dashboard/index.js (1 hunks)
  • src/vendor-dashboard/reports/layout/controller.js (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/vendor-dashboard/reports/dashboard/index.js (2)
src/vendor-dashboard/reports/dashboard/components/vendor-earning.js (1)
  • VendorEarning (5-21)
src/vendor-dashboard/reports/dashboard/customizable.js (1)
  • CustomizableDashboard (83-367)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: e2e tests (3, 3)
  • GitHub Check: e2e tests (1, 3)
  • GitHub Check: e2e tests (2, 3)
  • GitHub Check: api tests (1, 1)
🔇 Additional comments (5)
includes/Analytics/Assets.php (1)

124-124: LGTM! Correct implementation of script translations.

The addition of wp_set_script_translations for the vendor analytics script is properly implemented following WordPress standards. This enables the translation of JavaScript strings in the vendor analytics dashboard.

src/dashboard/withdraw/RequestWithdrawBtn.tsx (1)

180-180: LGTM! Text domain updates are consistent.

The updates to use 'dokan-lite' text domain for the DokanPriceInput component align with the PR's standardization of the translation domain across the codebase.

Also applies to: 194-194

src/vendor-dashboard/reports/dashboard/index.js (1)

4-4: LGTM! Clean removal of lazy loading.

The changes consistently remove lazy loading by:

  • Switching to direct imports for VendorEarning and CustomizableDashboard components
  • Removing the Suspense wrapper from the render method
  • Simplifying the component imports

This approach is more straightforward and eliminates the complexity of asynchronous component loading.

Also applies to: 9-10, 13-22

src/vendor-dashboard/reports/dashboard/default-sections.js (2)

12-13: LGTM! Consistent removal of lazy loading.

The changes to direct imports for DashboardCharts and StorePerformance components are consistent with the broader refactoring to remove lazy loading across the dashboard.


76-83: Verify the intentional removal of Leaderboards section.

The Leaderboards section has been commented out, which removes this functionality from the dashboard. Please confirm this is intentional and not a temporary change.

If this is a permanent removal, consider removing the commented code entirely rather than leaving it commented out. If it's temporary, please add a TODO comment explaining when it should be re-enabled.

Copy link
Member

@mrabbani mrabbani left a comment

Choose a reason for hiding this comment

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

We need to find the root cause for not loading the translation for lazy loading.

@kzamanbd
Copy link
Contributor Author

We need to find the root cause for not loading the translation for lazy loading.

Currently, the WooCommerce Analytics reports are not fully translatable using Loco Translate. Because the translations are not loaded automatically when components are lazy-loaded. To ensure all strings are translatable, we need to avoid lazy loading at the component level. If the scripts are lazy-loaded, their corresponding translation files are not loaded in time, which causes the translations to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Dev Review It requires a developer review and approval Needs: Testing This requires further testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants