Add six localized cron languages#20
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds six new locale support entries (German, Portuguese, Italian, Dutch, Simplified Chinese, Japanese) to CronCraft. Changes span day-name dictionaries in ChangesMulti-language Localization Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR expands CronCraft’s localization support by adding six new language codes (de, pt, it, nl, zh, ja) so CronSettings.Language can produce localized, human-readable cron descriptions rather than falling back to English.
Changes:
- Added new locale dispatch branches and phrase dictionaries for German, Portuguese, Italian, Dutch, Simplified Chinese, and Japanese.
- Added localized day-name mappings (full/short/single) for each new locale in
DayNameProvider. - Documented supported language codes in both READMEs and added 36 new localization test cases.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the newly supported language codes at the repository level. |
| CronCraft/README.md | Mirrors the supported language documentation for the package README. |
| CronCraft/Providers/DayNameProvider.cs | Adds day-name maps (full/short/single) for de/pt/it/nl/zh/ja and wires them into GetDayMap. |
| CronCraft/Models/CronSettings.cs | Updates XML docs to list all supported Language values. |
| CronCraft/Extensions/CronHelper.cs | Adds locale dispatch and new phrase dictionaries; updates time formatting and ordinal handling. |
| CronCraft.Test/CronHelperTest.cs | Adds 36 tests validating localized output across intervals, day-name formats, and monthly schedules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -24,6 +24,12 @@ public static string ToHumanReadable(this string cronExpression, CronSettings se | |||
| { | |||
| if (dayOfMonth.EndsWith('W')) | ||
| { | ||
| var baseDay = Ordinal(dayOfMonth.TrimEnd('W')); | ||
| var baseDay = Ordinal(dayOfMonth.TrimEnd('W'), settings.Language); | ||
| return $"Nearest weekday to the {baseDay} of the month {Phrase("AtTime", time)}"; | ||
| } |
| description = | ||
| $"Every hour from {FormatTime(startHour, fixedMinute, timeZone)} to {FormatTime(endHour, fixedMinute, timeZone)}"; | ||
| $"Every hour from {FormatTime(startHour, fixedMinute, timeZone, phrases)} to {FormatTime(endHour, fixedMinute, timeZone, phrases)}"; | ||
| return true; |
| description = | ||
| $"Every minute from {FormatTime(fixedHour, startMinute, timeZone)} to {FormatTime(fixedHour, endMinute, timeZone)}"; | ||
| $"Every minute from {FormatTime(fixedHour, startMinute, timeZone, phrases)} to {FormatTime(fixedHour, endMinute, timeZone, phrases)}"; | ||
| return true; |
| from parsedMinute in minutes | ||
| select FormatTime(parsedHour, parsedMinute, timeZone)) | ||
| select FormatTime(parsedHour, parsedMinute, timeZone, phrases)) | ||
| .ToList(); | ||
|
|
||
| description = $"At {JoinDescriptions(times)}"; |
| var bounds = part.Split('-', StringSplitOptions.TrimEntries); | ||
| return bounds.Length == 2 | ||
| ? $"{Ordinal(bounds[0])} through the {Ordinal(bounds[1])}" | ||
| : Ordinal(part); | ||
| ? $"{Ordinal(bounds[0], language)} through the {Ordinal(bounds[1], language)}" | ||
| : Ordinal(part, language); |
|
🎉 Thank you for your contribution! This PR was included in CronCraft v1.0.6 and is now live on NuGet for everyone to use. We really appreciate the time and effort you put in — it makes the library better for the whole community! 🚀 |
What changed
de), Portuguese (pt), Italian (it), Dutch (nl), Simplified Chinese (zh), and Japanese (ja) phrase profilesWhy
CronCraft previously dispatched only English, Spanish, and French. Requests for the six additional language codes fell back to English phrases and English day names.
Impact
Consumers can now select any requested locale through
CronSettings.Language. Existing English, Spanish, and French behavior remains unchanged.Validation
dotnet test CronCraft.sln --no-restoregit diff --checkCloses #8
Summary by CodeRabbit
New Features
Documentation