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(i18n)]: add translations for productivity table #3617

Merged
merged 2 commits into from
Feb 23, 2025

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Feb 23, 2025

  • Add new translation keys for productivity table headers and messages
  • Implement translations in ProductivityTable component
  • Add translations in all supported languages (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh)
  • Improve UI by making progress bar full width
  • Replace hardcoded English text with translation keys

Description

Please include a summary of the changes and the related issues.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Previous screenshots

Please add here videos or images of the previous status

Current screenshots

Please add here videos or images of the current (new) status

Summary by CodeRabbit

  • New Features

    • The dashboard now dynamically renders table labels and informational messages in the user's selected language.
    • Expanded localization support by adding comprehensive translations in multiple languages including Arabic, Bulgarian, German, English, Spanish, French, Hebrew, Italian, Dutch, Polish, Portuguese, Russian, and Chinese.
    • Default date range for reports is now set to the first and last day of the current month.
  • Style

    • Adjusted the loader’s width for improved responsiveness and better alignment within its container.

- Add new translation keys for productivity table headers and messages
- Implement translations in ProductivityTable component
- Add translations in all supported languages (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh)
- Improve UI by making progress bar full width
- Replace hardcoded English text with translation keys
Copy link
Contributor

coderabbitai bot commented Feb 23, 2025

Walkthrough

This pull request integrates internationalization support in the ProductivityTable component by replacing hardcoded text with dynamic translation calls using the useTranslations hook from next-intl. It updates table headers and no-data messages with localized keys. Alongside this, several locale JSON files (for Arabic, Bulgarian, German, English, Spanish, French, Hebrew, Italian, Dutch, Polish, Portuguese, Russian, and Chinese) gain five new translation entries: APPLICATION, TIME_SPENT, PERCENT_USED, NO_ACTIVITY_DATA, and SELECT_DIFFERENT_DATE. Additionally, the skeleton loader’s width is adjusted from a fixed size to full width.

Changes

File(s) Change Summary
apps/web/app/[locale]/.../ProductivityTable.tsx Replaced static headers ("Member", "Project", etc.) and no-data messages with dynamic translation calls using t; updated skeleton loader from w-24 to w-full.
apps/web/locales/{ar,bg,de,en,es,fr,he,it,nl,pl,pt,ru,zh}.json Added five new key-value pairs (APPLICATION, TIME_SPENT, PERCENT_USED, NO_ACTIVITY_DATA, and SELECT_DIFFERENT_DATE) to enhance localization support in various languages.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant PT as ProductivityTable
    participant TT as useTranslations (next-intl)
    participant L as Localization File
    U->>PT: Load dashboard
    PT->>TT: Request localized strings
    TT->>L: Fetch translation keys for current locale
    L-->>TT: Return translation data
    TT-->>PT: Provide localized strings
    PT->>U: Render table with dynamic text and full-width loader
Loading

Possibly related PRs

Suggested labels

feature, WEB, Ever Teams

Suggested reviewers

  • evereq

Poem

I'm a coding bunny, hopping with delight,
Translating texts from morning 'til night.
From English to French, and more along the way,
I nibble on keys in a joyful display.
With every locale set, my code sings a new tune,
Celebrating i18n under the coding moon! 🐇💻

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.

apps/web/app/hooks/features/useReportActivity.ts

Oops! Something went wrong! :(

ESLint: 8.46.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 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 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@Innocent-Akim Innocent-Akim changed the title [Feat(i18n): add translations for productivity table [Feat(i18n)]: add translations for productivity table Feb 23, 2025
@Innocent-Akim Innocent-Akim self-assigned this Feb 23, 2025
@Innocent-Akim Innocent-Akim requested a review from evereq February 23, 2025 16:01
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: 0

🔭 Outside diff range comments (1)
apps/web/app/[locale]/dashboard/app-url/components/ProductivityTable.tsx (1)

106-107: 🛠️ Refactor suggestion

Hardcoded English text needs translation.

The message "No activities recorded for this day" should use a translation key for consistency.

Apply this diff to fix the hardcoded text:

-                      No activities recorded for this day
+                      {t('common.NO_ACTIVITIES_RECORDED')}
🧹 Nitpick comments (2)
apps/web/app/[locale]/dashboard/app-url/components/ProductivityTable.tsx (1)

141-141: Hardcoded project name needs dynamic value.

The project name "Ever Teams" is hardcoded. Consider making it dynamic based on the actual project.

Apply this diff to make the project name dynamic:

-                      <TableCell>Ever Teams</TableCell>
+                      <TableCell>{project?.name || t('common.DEFAULT_PROJECT_NAME')}</TableCell>
apps/web/locales/nl.json (1)

22-26: New Dutch Translation Keys Added – Minor Grammar Nitpick
The keys "APPLICATION", "TIME_SPENT", "PERCENT_USED", "NO_ACTIVITY_DATA", and "SELECT_DIFFERENT_DATE" have been added appropriately to the "common" section. The Dutch translations are well aligned with the PR objectives. As a minor note, consider revising the phrase in "SELECT_DIFFERENT_DATE" from

"Selecteer een andere datumbereik of probeer later opnieuw"

to

"Selecteer een ander datumbereik of probeer later opnieuw"

to better match the neuter noun "datumbereik."

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f17ceec and 936a294.

📒 Files selected for processing (14)
  • apps/web/app/[locale]/dashboard/app-url/components/ProductivityTable.tsx (6 hunks)
  • apps/web/locales/ar.json (1 hunks)
  • apps/web/locales/bg.json (1 hunks)
  • apps/web/locales/de.json (1 hunks)
  • apps/web/locales/en.json (1 hunks)
  • apps/web/locales/es.json (1 hunks)
  • apps/web/locales/fr.json (1 hunks)
  • apps/web/locales/he.json (1 hunks)
  • apps/web/locales/it.json (1 hunks)
  • apps/web/locales/nl.json (1 hunks)
  • apps/web/locales/pl.json (1 hunks)
  • apps/web/locales/pt.json (1 hunks)
  • apps/web/locales/ru.json (1 hunks)
  • apps/web/locales/zh.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
apps/web/locales/es.json (1)
Learnt from: CREDO23
PR: ever-co/ever-teams#3309
File: apps/web/locales/es.json:335-337
Timestamp: 2024-11-12T14:06:02.202Z
Learning: When reviewing additions of new translation keys in `apps/web/locales/`, ensure to verify whether the keys have been added to all relevant locale files before suggesting they are missing.
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (17)
apps/web/app/[locale]/dashboard/app-url/components/ProductivityTable.tsx (5)

10-10: LGTM! Proper i18n setup.

The useTranslations hook is correctly imported and initialized.

Also applies to: 20-20


27-31: LGTM! Consistent translation key usage in loading state.

The table headers in the loading state correctly use translation keys from common and sidebar namespaces.


59-60: LGTM! Clear no-data messaging with translations.

The no-data state messages are properly internationalized using appropriate translation keys.


71-75: LGTM! Consistent translation key usage in data view.

The table headers in the data view match the loading state translations, maintaining consistency.


46-46:

❓ Verification inconclusive

Consider the impact of full-width skeleton.

The skeleton loader width change from w-24 to w-full might cause layout shifts. Ensure this matches the actual content width.

Run this script to check the actual content width in the codebase:


🏁 Script executed:

#!/bin/bash
# Search for width-related classes in the component
rg -A 2 'w-\d+|w-full' apps/web/app/[locale]/dashboard/app-url/components/ProductivityTable.tsx

Length of output: 962


Review: Verify Full-Width Skeleton Consistency

It appears that most table cells in this component use fixed-width skeletons (e.g., w-24 or w-16), while one cell still uses a full-width skeleton (w-full). This discrepancy may lead to layout shifts if the actual content does not span the full width. Please ensure that the full-width skeleton is intentional—if the cell’s content should not be full width, adjust the skeleton width accordingly for consistency.

  • Confirm that the intended content width in this table cell aligns with using w-full.
  • If not, consider using a fixed width that matches the other cells to prevent layout shifts.
apps/web/locales/zh.json (1)

22-26: LGTM! Accurate Chinese translations.

The new translations are semantically correct and maintain consistency with the existing translations.

apps/web/locales/he.json (1)

22-26: LGTM! Accurate Hebrew translations.

The new translations are semantically correct and maintain consistency with the existing translations.

apps/web/locales/ar.json (1)

4-8: New Arabic Translation Keys Added
The new keys for "APPLICATION", "TIME_SPENT", "PERCENT_USED", "NO_ACTIVITY_DATA", and "SELECT_DIFFERENT_DATE" have been correctly inserted into the "common" block. The Arabic translations accurately reflect the intended meanings and align with the PR objectives to support the productivity table's internationalization.

apps/web/locales/en.json (1)

22-26: New English Translation Keys Added
The addition of the keys "APPLICATION", "TIME_SPENT", "PERCENT_USED", "NO_ACTIVITY_DATA", and "SELECT_DIFFERENT_DATE" in the "common" section is implemented correctly. The English values are clear and consistent with the intended changes for replacing hardcoded strings, ensuring dynamic rendering in the ProductivityTable component.

apps/web/locales/bg.json (1)

22-26: New Bulgarian Translation Keys Added
The five translation keys ("APPLICATION", "TIME_SPENT", "PERCENT_USED", "NO_ACTIVITY_DATA", and "SELECT_DIFFERENT_DATE") have been correctly added in the "common" section. Please verify that the translations reflect the intended tone and context used in similar locales across the application.

apps/web/locales/pl.json (1)

22-26: Polish Localization Enhancements
The new keys for Polish—"APPLICATION": "Aplikacja", "TIME_SPENT": "Czas spędzony", "PERCENT_USED": "Procent wykorzystany", "NO_ACTIVITY_DATA": "Brak dostępnych danych o aktywności", and "SELECT_DIFFERENT_DATE": "Wybierz inny zakres dat lub sprawdź później"—are added appropriately in the "common" section. Ensure these translations are consistent with terminology used elsewhere in the product.

apps/web/locales/it.json (1)

22-26: Italian Translation Keys Addition
The new Italian entries ("APPLICATION", "TIME_SPENT", "PERCENT_USED", "NO_ACTIVITY_DATA", and "SELECT_DIFFERENT_DATE") have been incorporated correctly into the "common" section with accurate translations. Please double-check that these strings align with the product’s style guidelines and the context provided by components such as the ProductivityTable.

apps/web/locales/ru.json (1)

22-26: Translation Keys Addition Verified
The new keys in the "common" section (i.e. "APPLICATION", "TIME_SPENT", "PERCENT_USED", "NO_ACTIVITY_DATA", and "SELECT_DIFFERENT_DATE") have been correctly added with intuitive Russian translations. They are consistent with the overall i18n strategy.

apps/web/locales/pt.json (1)

22-26: Portuguese Translation Keys Added
The five new keys have been properly inserted in the "common" section using precise Portuguese translations. The wording aligns well with the intended meanings and mirrors the updates made across other locale files.

apps/web/locales/es.json (1)

22-26: Spanish Translation Keys Addition Checked
The additions of "APPLICATION", "TIME_SPENT", "PERCENT_USED", "NO_ACTIVITY_DATA", and "SELECT_DIFFERENT_DATE" in the "common" section are correctly translated and consistent with similar updates in other localization files (ar, bg, de, en, fr, he, it, nl, pl, pt, ru, zh). This ensures a uniform i18n experience across the application.

apps/web/locales/de.json (1)

22-26: New German Translation Keys Added.
The new keys "APPLICATION", "TIME_SPENT", "PERCENT_USED", "NO_ACTIVITY_DATA", and "SELECT_DIFFERENT_DATE" have been correctly added to the "common" section with appropriate German translations. These entries are in line with the updated internationalization requirements for the ProductivityTable component and maintain the key naming consistency across locale files.

apps/web/locales/fr.json (1)

22-26: New French Translation Keys Added.
The keys "APPLICATION", "TIME_SPENT", "PERCENT_USED", "NO_ACTIVITY_DATA", and "SELECT_DIFFERENT_DATE" have been accurately integrated into the "common" section with proper French translations. These modifications ensure that the ProductivityTable component can dynamically render the French locale and maintain synchronicity with other language files across the application.

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: 0

🧹 Nitpick comments (1)
apps/web/app/hooks/features/useReportActivity.ts (1)

55-56: Consider using a more robust date formatting approach.

While the current implementation works, consider using toLocaleDateString or a date formatting library to ensure consistent formatting across different locales, which would better align with the i18n focus of this PR.

Example implementation:

-	startDate: firstDayOfMonth.toISOString().split('T')[0],
-	endDate: lastDayOfMonth.toISOString().split('T')[0],
+	startDate: firstDayOfMonth.toLocaleDateString('en-CA'), // en-CA produces YYYY-MM-DD format
+	endDate: lastDayOfMonth.toLocaleDateString('en-CA'),

Or using a date formatting library like date-fns:

+import { format } from 'date-fns';
+
-	startDate: firstDayOfMonth.toISOString().split('T')[0],
-	endDate: lastDayOfMonth.toISOString().split('T')[0],
+	startDate: format(firstDayOfMonth, 'yyyy-MM-dd'),
+	endDate: format(lastDayOfMonth, 'yyyy-MM-dd'),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 936a294 and 7743fa8.

📒 Files selected for processing (1)
  • apps/web/app/hooks/features/useReportActivity.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (1)
apps/web/app/hooks/features/useReportActivity.ts (1)

36-38: LGTM! Clean implementation of month boundaries.

The implementation uses a reliable technique to calculate the first and last day of the current month.

@evereq evereq merged commit 9d54e21 into develop Feb 23, 2025
13 checks passed
@evereq evereq deleted the feat/productivity-table-i18n branch February 23, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants