-
Notifications
You must be signed in to change notification settings - Fork 537
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
[Fix] Dates should be translated when switching to other languages #8469
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes involve modifications to the Changes
Possibly related PRs
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 and nitpick comments (1)
packages/ui-core/shared/src/lib/components/date-range-title/date-range-title.component.ts (1)
61-65
: LGTM: Date formatting now respects language preference.The changes correctly implement language-based date formatting by using the preferred language from
ThemeLanguageSelectorService
. This aligns with the PR objective of translating dates when switching languages.Consider adding a comment explaining the purpose of the
language
constant for better code readability:// Get the user's preferred language for date formatting const language = this._themeLanguageService.preferredLanguage;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- packages/ui-core/shared/src/lib/components/date-range-title/date-range-title.component.ts (3 hunks)
🧰 Additional context used
🔇 Additional comments (3)
packages/ui-core/shared/src/lib/components/date-range-title/date-range-title.component.ts (3)
5-5
: LGTM: New service import added correctly.The import statement for
ThemeLanguageSelectorService
is properly formatted and consistent with the existing import style.
47-48
: LGTM: Constructor updated with new service injection.The
ThemeLanguageSelectorService
is correctly injected into the constructor using dependency injection. The parameter is appropriately marked asprivate
andreadonly
.
Line range hint
1-70
: Summary: Successful implementation of language-based date translation.The changes in this file successfully implement the functionality to translate dates when switching languages. Key points:
- The
ThemeLanguageSelectorService
is properly imported and injected.- The
title
getter now uses the user's preferred language for date formatting.- These changes align with the PR objective and should resolve the issue described.
The implementation is clean and follows Angular best practices. Great job on improving the internationalization support of the application!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
packages/ui-core/shared/src/lib/pipes/date-format.pipe.ts (2)
32-41
: Approved: Good use of RxJS operators and memory leak preventionThe subscription to
preferredLanguage$
is well-implemented with appropriate use of RxJS operators and theuntilDestroyed
operator for preventing memory leaks.Consider adding error handling to the subscription:
this.store.preferredLanguage$ .pipe( distinctUntilChange(), filter((preferredLanguage: string) => !!preferredLanguage), tap((preferredLanguage: string) => { this.locale = preferredLanguage; }), + catchError((error) => { + console.error('Error in preferredLanguage$ subscription:', error); + return EMPTY; + }), untilDestroyed(this) ) .subscribe();This will ensure that any errors in the subscription are logged and don't break the application.
67-67
: Approved: Correct implementation of locale prioritizationThe change correctly prioritizes
this.locale
when no specific locale is provided, which aligns with the PR objective of translating dates when switching languages.For improved clarity, consider adding a comment explaining the locale prioritization:
if (isEmpty(locale)) { + // Use the user's preferred language if no specific locale is provided locale = this.locale; }
This comment helps future developers understand the reasoning behind this prioritization.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- packages/ui-core/shared/src/lib/pipes/date-format.pipe.ts (3 hunks)
🧰 Additional context used
🔇 Additional comments (1)
packages/ui-core/shared/src/lib/pipes/date-format.pipe.ts (1)
Line range hint
1-83
: Approved: Successfully implements date translation with good practicesThe changes successfully address the PR objective of translating dates when switching languages. The implementation is clean, maintains backwards compatibility, and follows good Angular practices.
To ensure the robustness of these changes, please add unit tests covering the new functionality, particularly:
- The behavior of the
transform
method with different locale settings.- The
preferredLanguage$
subscription in the constructor.Here's a script to check for existing tests:
If no tests are found, consider adding them to ensure the new functionality is properly covered.
☁️ Nx Cloud ReportCI is running/has finished running commands for commit ba27118. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution
✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
PR
Please note: we will close your PR without comment if you do not check the boxes above and provide ALL requested information.
Summary by CodeRabbit
New Features
Bug Fixes