Skip to content

correct plural forms for week and millisecond in relative date phrases#1735

Open
sigmade wants to merge 7 commits into
Humanizr:mainfrom
sigmade:fix/ru-locale-plural-forms
Open

correct plural forms for week and millisecond in relative date phrases#1735
sigmade wants to merge 7 commits into
Humanizr:mainfrom
sigmade:fix/ru-locale-plural-forms

Conversation

@sigmade

@sigmade sigmade commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Here is a checklist you should tick through before submitting a pull request:

  • Implementation is clean
  • Code adheres to the existing coding standards; e.g. no curlies for one-line blocks, no redundant empty lines between methods or code blocks, spaces rather than tabs, etc.
  • No Code Analysis warnings
  • There is proper unit test coverage
  • If the code is copied from StackOverflow (or a blog or OSS) full disclosure is included. That includes required license files and/or file headers explaining where the code came from with proper attribution
  • There are very few or no comments (because comments shouldn't be needed if you write clean code)
  • Xml documentation is added/updated for the addition/change
  • Your PR is (re)based on top of the latest commits from the main branch (more info below)
  • Link to the issue(s) you're fixing from your PR description. Use fixes #<the issue number>
  • Readme is updated if you change an existing feature or add a new one
  • Run either build.cmd or build.ps1 and ensure there are no test failures

Copilot AI review requested due to automatic review settings April 19, 2026 06:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates Russian (ru) relative date phrase data so that week and millisecond use correct Russian grammatical-number forms (e.g., 2 недели, 2 миллисекунды) and adds regression coverage in the localisation phrase theory tests.

Changes:

  • Extend ru relative date phrase definitions for week and millisecond to use form maps (default/singular/dual) instead of a single plural form.
  • Add localisation theory test cases validating past/future phrasing for 1, 2, and 7 weeks/milliseconds in ru.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/Humanizer.Tests/Localisation/LocalePhraseTheoryData.cs Adds RU test cases for week/millisecond relative date phrases to verify corrected grammatical forms.
src/Humanizer/Locales/ru.yml Updates RU relativeDate week and millisecond multiple.forms to support Russian singular/paucal/default selection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts Russian locale phrase data to use grammar-aware plural forms for relative date phrases so that counted expressions (e.g., “через 2 …”) use the correct Russian inflections.

Changes:

  • Updated ru.yml relative-date phrases for week and millisecond to provide default/singular/dual forms instead of a single scalar form.
  • Updated the generated locale migration test to assert the presence of the Russian dual form for week in the phrase table.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/Humanizer.Tests/Localisation/GeneratedLocaleData/GeneratedLocaleDeRuPhraseMigrationTests.cs Updates expectations to validate the added Russian dual form for weeks in the phrase table.
src/Humanizer/Locales/ru.yml Adds grammar-aware plural forms for Russian relative-date weeks/milliseconds (past & future).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Assert.Equal("минуты", timeSpanMinute.Multiple?.Forms.Dual);
Assert.Equal("минут", timeSpanMinute.Multiple?.Forms.Default);

Assert.True(table.TryGetDatePhrase(TimeUnit.Week, Tense.Future, out var futureWeek));
Comment on lines 29 to 34
multiple:
forms: 'миллисекунд'
forms:
default: 'миллисекунд'
singular: 'миллисекунду'
dual: 'миллисекунды'
afterCount: 'назад'
@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b4b3d28a-bd6e-49e0-b6cf-2a893b28c28c

📥 Commits

Reviewing files that changed from the base of the PR and between cbb799d and 3b43c4e.

📒 Files selected for processing (1)
  • global.json
✅ Files skipped from review due to trivial changes (1)
  • global.json

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved Russian relative-date wording for multiple milliseconds and weeks in both past and future expressions.
    • Corrected plural form handling so dual forms now display properly for the affected time units.
    • Updated localization test expectations to match the refined pluralization behavior.

Walkthrough

Four Russian locale entries in ru.yml — past/future millisecond and past/future week multiples — change forms from a single string to an object with default, singular, and dual variants. The matching test now expects the dual form "недели" for future week. global.json also updates the .NET SDK version.

Changes

Russian locale pluralization forms

Layer / File(s) Summary
ru.yml pluralization forms and test update
src/Humanizer/Locales/ru.yml, tests/Humanizer.Tests/Localisation/GeneratedLocaleData/GeneratedLocaleDeRuPhraseMigrationTests.cs
past.millisecond.multiple, past.week.multiple, future.millisecond.multiple, and future.week.multiple forms expand from single strings to objects with default, singular, and dual keys; the migration test now expects "недели" for futureWeek.Multiple?.Forms.Dual.

SDK version update

Layer / File(s) Summary
SDK version bump
global.json
The configured .NET SDK version changes from 11.0.100-preview.3 to 11.0.100-preview.5.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Four words once lonely, now joined by three,
Default and singular, dual — a family!
Milliseconds and weeks in Russian now sing,
With grammar-aware forms for each plural thing.
Hop hop, the test now expects "недели" true! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing plural forms for week and millisecond relative-date phrases.
Description check ✅ Passed The description is generic, but it is still related to the PR and its checklist for the locale and test update.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/Humanizer.Tests/Localisation/GeneratedLocaleData/GeneratedLocaleDeRuPhraseMigrationTests.cs (1)

47-50: ⚡ Quick win

Add assertions for all modified RU relative-date entries.

This assertion is correct, but this PR changed four RU phrase blocks. Adding checks for past week and past/future millisecond forms would close the regression gap with minimal effort.

Suggested test additions
         Assert.True(table.TryGetDatePhrase(TimeUnit.Week, Tense.Future, out var futureWeek));
         Assert.Equal("недель", futureWeek.Multiple?.Forms.Default);
         Assert.Equal("недели", futureWeek.Multiple?.Forms.Dual);
+
+        Assert.True(table.TryGetDatePhrase(TimeUnit.Week, Tense.Past, out var pastWeek));
+        Assert.Equal("недели", pastWeek.Multiple?.Forms.Dual);
+
+        Assert.True(table.TryGetDatePhrase(TimeUnit.Millisecond, Tense.Future, out var futureMillisecond));
+        Assert.Equal("миллисекунду", futureMillisecond.Multiple?.Forms.Singular);
+        Assert.Equal("миллисекунды", futureMillisecond.Multiple?.Forms.Dual);
+        Assert.Equal("миллисекунд", futureMillisecond.Multiple?.Forms.Default);
+
+        Assert.True(table.TryGetDatePhrase(TimeUnit.Millisecond, Tense.Past, out var pastMillisecond));
+        Assert.Equal("миллисекунду", pastMillisecond.Multiple?.Forms.Singular);
+        Assert.Equal("миллисекунды", pastMillisecond.Multiple?.Forms.Dual);
+        Assert.Equal("миллисекунд", pastMillisecond.Multiple?.Forms.Default);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/Humanizer.Tests/Localisation/GeneratedLocaleData/GeneratedLocaleDeRuPhraseMigrationTests.cs`
around lines 47 - 50, The test only asserts the RU future-week phrase (using
table.TryGetDatePhrase(TimeUnit.Week, Tense.Future, out var futureWeek) and
checks futureWeek.Multiple.Forms), but the PR changed four RU relative-date
blocks; add assertions for the corresponding past-week entry and for both past
and future millisecond entries: call table.TryGetDatePhrase(TimeUnit.Week,
Tense.Past, out var pastWeek) and assert pastWeek.Multiple.Forms matches the
expected "недель"/"недели" variants, and call
table.TryGetDatePhrase(TimeUnit.Millisecond, Tense.Past, out var pastMs) and
table.TryGetDatePhrase(TimeUnit.Millisecond, Tense.Future, out var futureMs) and
assert their Single/Multiple Forms (or appropriate .Forms.Default/.Dual) equal
the expected RU millisecond strings to cover all modified phrase blocks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@tests/Humanizer.Tests/Localisation/GeneratedLocaleData/GeneratedLocaleDeRuPhraseMigrationTests.cs`:
- Around line 47-50: The test only asserts the RU future-week phrase (using
table.TryGetDatePhrase(TimeUnit.Week, Tense.Future, out var futureWeek) and
checks futureWeek.Multiple.Forms), but the PR changed four RU relative-date
blocks; add assertions for the corresponding past-week entry and for both past
and future millisecond entries: call table.TryGetDatePhrase(TimeUnit.Week,
Tense.Past, out var pastWeek) and assert pastWeek.Multiple.Forms matches the
expected "недель"/"недели" variants, and call
table.TryGetDatePhrase(TimeUnit.Millisecond, Tense.Past, out var pastMs) and
table.TryGetDatePhrase(TimeUnit.Millisecond, Tense.Future, out var futureMs) and
assert their Single/Multiple Forms (or appropriate .Forms.Default/.Dual) equal
the expected RU millisecond strings to cover all modified phrase blocks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f5a3932-05a9-4b0c-a250-6cc132762dae

📥 Commits

Reviewing files that changed from the base of the PR and between 19527a5 and 6ea2a21.

📒 Files selected for processing (2)
  • src/Humanizer/Locales/ru.yml
  • tests/Humanizer.Tests/Localisation/GeneratedLocaleData/GeneratedLocaleDeRuPhraseMigrationTests.cs

Copilot AI review requested due to automatic review settings June 28, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 2 out of 2 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings June 28, 2026 22:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread global.json
@sigmade

sigmade commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

@clairernovotny CodeQL was failing in actions/setup-dotnet before build/analyze because global.json pointed to the .NET 11 preview SDK version 11.0.100-preview.3, and that download was returning 404.

I updated the SDK pin to the full published preview version 11.0.100-preview.5.26302.115 so actions/setup-dotnet can install the SDK successfully. This change is only to unblock the CI setup step the failure was unrelated to the RU locale changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants