Skip to content

TimeSpan.Humanize(toWords: true) returns English "one" for a single unit in 19 locales #2005

Open

Description

@XakimovNosirbek

TimeSpan.Humanize(toWords: true) returns the English word "one" for a single unit in 19 non-English locales:

TimeSpan.FromHours(1).Humanize(toWords: true, culture: new CultureInfo("pl"));         // "one godzina"
TimeSpan.FromDays(1).Humanize(toWords: true, culture: new CultureInfo("uz-Latn-UZ"));  // "one kun"
TimeSpan.FromHours(1).Humanize(toWords: true, culture: new CultureInfo("zh-Hans"));    // "one 小时"

Two units and up are fine ("dua jam", "uch soat", "二 小时"). Affected locales: az, cs, el, hr, id, lv, ms, nl, pl, sk, sl, sr, sr-Latn, sv (6 units), th, uz-Cyrl-UZ, uz-Latn-UZ, zh-Hans, zh-Hant.

The cause is phrases.duration.<unit>.single.words, which still holds the English placeholder (words: 'one godzina'). I saw that #1879 kept the legacy toWords surfaces byte-identical on purpose, and CaseAwareCitationDoesNotChangeLegacyToWords pins "one gün" / "bir gün". So I want to ask before opening a PR: would you take a change to the legacy output?

I have a branch ready: main...XakimovNosirbek:Humanizer:fix/duration-words-one

  • For the 13 locales that author a citation phrase in durationCases, the legacy single.words value is set to that authored phrase (jedna godzina, bir kun, μία ώρα, ...). Legacy toWords and HumanizeWithCase(GrammaticalCase.Nominative) then return the same string, and the existing test becomes LegacyToWordsMatchesNominativeCitation.
  • id, ms, nl, th, zh-Hans and zh-Hant have no durationCases. For them the value is the locale's own 1.ToWords() plus the unit (satu jam, een uur, หนึ่ง ชั่วโมง, 一 小时). Multi-count output is already built the same way.
  • TimeSpanHumanizeCases gets a single-hour toWords row for each locale. LocaleRegistrySweepTests gets a check that no shipped non-English locale starts a single-unit toWords duration with "one". That check fails on 20 rows on current main.

Tests on net11.0: 61,683 passed. The 18 failures are the HijriCalendar_* tests, which fail the same way on a clean main on this Windows machine.

If you'd rather keep the legacy surface as is, the sweep test alone might still be worth having, with an allow-list. Either way works for me.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions