Add Persian (fa) locale support#629
Open
ali-master wants to merge 15 commits intowanasit:masterfrom
Open
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.
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.
Author
|
Any updates? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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