-
Notifications
You must be signed in to change notification settings - Fork 365
Add Persian (fa) locale support #629
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
…lities - Add support for optional "این" prefix in casual time expressions. - Introduce FARelativeDateFormatParser for handling relative date formats. - Implement FATimeUnitCasualRelativeFormatParser for explicit time units. - Update FATimeExpressionParser to extract minutes from specific patterns. - Modify FAWeekdayParser to recognize "این" as a prefix modifier.
- Add `FAWeekdayRangeParser` to support parsing weekday ranges like "از دوشنبه تا جمعه." - Implement `FAMergeWeekdayDateRefiner` to merge adjacent weekday and date expressions. - Update `FAWeekdayParser` to prefer current day for same-weekday matches. - Refactor refiners and parsers for better clarity and extensibility. - Adjust test cases to align with parser and refiner updates.
- Update `FAStrictModeRefiner` to filter out vague and standalone time expressions like "صبح" and "عصر." - Enhance `FATimeUnitWithinFormatParser` with stricter pattern matching and tagging for better identification. - Adjust `FARelativeDateFormatParser` to exclude ambiguous casual expressions like "روز بعد." - Rearrange parser initialization order in `fa/index.ts` for better processing flow.
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
Adds comprehensive Persian (fa) locale support to Chrono, including parsers/refiners, exports, and extensive tests. Also updates timezone handling for IRST and modernizes tooling/config.
- New fa locale: Parsers for weekdays, ranges, time units (ago/within/later), month names (SH and Gregorian), casual phrases, and refiners for merging and strict mode.
- Tests: Extensive unit tests covering Persian expressions, edge cases, and negative cases; minor Jest matcher update.
- Tooling/Docs: Export fa in root, README updates, eslint flat config, and Jest/TS deps bump.
Reviewed Changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/locales/fa/** | New Persian locale implementation (parsers/refiners/constants/config). |
| test/fa/** | New test suites validating Persian parsing behaviors and edge cases. |
| src/index.ts | Exports fa locale. |
| README.md | Documents fa as supported locale and usage example. |
| src/timezone.ts | Changes IRST to DST-aware mapping. |
| src/results.ts | Minor const refactor in relative date creation. |
| test/debugging.test.ts | Updates deprecated Jest matchers. |
| package.json | Bumps Jest/TS/Eslint deps; sets TZ=UTC in scripts; moves eslint config to flat file. |
| eslint.config.js | Introduces ESLint Flat Config. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Any updates? |
Summary
This PR adds Persian (fa) locale support to Chrono, enabling natural language date/time parsing for Persian speakers.
Changes
fa.casualconfiguration with Persian date/time expressionstest/fa/fa_casual.test.tsfalocale from root exportOther Changes:
eslint.config.jsfileTesting
Run Persian locale tests:
npm run test:silent -- test/fa/*.ts --no-coverageUsage
Notes