-
Notifications
You must be signed in to change notification settings - Fork 12
feat: implement locale-aware utilities in edge-apps-library #585
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
base: master
Are you sure you want to change the base?
Conversation
- Add getLocale() and getTimeZone() with override settings and validation - Add getLocalizedDayNames() and getLocalizedMonthNames() formatters - Add detectHourFormat() for 12h/24h format detection - Add formatTime() with locale and timezone awareness
PR Reviewer Guide 🔍(Review updated until commit c3ae600)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to c3ae600
Previous suggestionsSuggestions up to commit 07c9acf
|
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.
Pull request overview
This PR implements locale-aware utility functions in the edge-apps-library to centralize and standardize locale/timezone handling across Vue-based Edge Apps, reducing code duplication.
Key Changes:
- Enhanced timezone and locale resolution with user override settings, validation, and robust fallback chains
- Added comprehensive date/time formatting utilities including localized day/month names and intelligent hour format detection
- Migrated from direct
screenlyglobal access to abstractedgetMetadata()andgetSettingWithDefault()functions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
edge-apps/edge-apps-library/src/utils/locale.ts |
Refactored getTimeZone() and getLocale() to support override settings with validation, changed to async patterns, and improved error handling with fallback chains |
edge-apps/edge-apps-library/src/utils/formatting.ts |
New module providing locale-aware formatting utilities: day/month name localization, hour format detection (12h/24h), and structured time formatting with timezone support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Create isValidLocale() to validate language codes match resolved locale - Add locale override validation to getLocale() with fallback - Use current year with fixed January 1st reference date in getLocalizedDayNames()
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Merge formatLocalizedDate, day names, month names, and time formatting into locale.ts - Remove separate formatting.ts file - Update index.ts exports
- Add 5 separate test files for locale utilities - Test coverage for date, time, and day/month name formatting - Support for en, de, ja, zh, fr, es, hi, th, ru locales - Include Thai and Chinese numeral system tests
|
Persistent review updated to latest commit c3ae600 |
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.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
edge-apps/edge-apps-library/src/utils/get-localized-month-names.test.ts
Outdated
Show resolved
Hide resolved
edge-apps/edge-apps-library/src/utils/get-localized-day-names.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Test valid override_timezone setting usage - Test fallback to GPS when invalid override_timezone provided - Test fallback to UTC when coordinates missing
- Test single underscore normalization (en_US → en-US) - Test multiple underscore normalization (en_US_POSIX → en-US-POSIX) - Test fallback to GPS detection for invalid override_locale
- Add regex validation for BCP 47 locale tag format - Check that requested locale structure is preserved in resolution - Catch malformed locales like 'en-', 'en-INVALID' early - Add tests for malformed locale rejection
- Replace manual string concatenation with Intl.Locale API - Properly merge numeral system extensions with existing locale extensions - Handle locales like 'zh-CN-u-ca-chinese' without creating duplicate extensions - Add graceful error handling and fallback to original locale - Add test for locales with existing extensions
- Split locale test loops into individual parametrized test cases - Each locale now runs as a separate test for better parallelization - Improves test reporting clarity (13 → 26 day name tests, 12 → 19 month name tests) - Tests can now run concurrently, reducing overall test suite time
- Add --parallel flag to test scripts in package.json - All test suites now run concurrently - Speeds up overall test execution time
User description
Implements locale-aware utilities in edge-apps-library to prevent code duplication across Vue-based Edge Apps.
Changes
Checklist
PR Type
Enhancement, Tests, Documentation
Description
Add locale/timezone utilities with overrides
Implement localized date/time formatting
Provide day and month names helpers
Add comprehensive unit tests across locales
Diagram Walkthrough
File Walkthrough
1 files
Add locale/timezone resolution and formatting utilities6 files
Tests for 12h/24h hour format detectionTests for locale-aware date formattingTests for locale and timezone time formattingTests for localized weekday names helpersTests for localized month names helpersMake timezone tests async for new API1 files
Document new localization utilities