bradymholt / cRonstrue

JavaScript library that translates Cron expressions into human readable descriptions
http://bradymholt.github.io/cRonstrue/
MIT License
1.32k stars 171 forks source link

Plural correction of danish translation #329

Open Lars-Sommer opened 1 week ago

Lars-Sommer commented 1 week ago

Cron Expression 0 3 * * 0,5,6

Expected Output "Kl 03:00, på søndage, fredage, og lørdage"

Actual Output "Kl 03:00, på søndag, fredag, og lørdage"

I think this translation might be wrong. The first two days are definite singular, but the last day is plural. You therefore might get the impression that the cron runs only on this 'søndag' (sunday), this 'fredag' (friday) but on all 'lørdage' (saturdays).

@rmja

rmja commented 1 week ago

@bradymholt do you have a good suggestion on how to accomplish this?

bradymholt commented 1 week ago

Can the translations just be updated? (here)

rmja commented 6 days ago

@bradymholt Consider this test:

    it("0 3 * * 4,5", function () {
      assert.equal(
        cronstrue.toString(this.test?.title as string, { locale: "da" }),
        "Kl 03:00, på torsdage og fredage"
      );
    });

The issue is that in Danish, we use different endings on the day of week depending on whether we mean "next Thursday" in singular og "next and following Thursdays".

My initial pr added an "e" to the end of the dow name by simply modifying commaOnlyOnX0 from ", på %s" to ", på %se", eg.: "mandag" -> "mandage" "tirsdag" -> "tirsdage"

That works for a single dow, but as soon as we add more weekdays this of cause fails, because each of the days needs the "e" in the end. The pr only adds the e to the last dow.

bradymholt commented 6 days ago

Oh wow, this is a very specific variation with Danish it seems. Is there any way to change the translation so that it is more generic to account for both variations? Outside of that, the only other way I can think to handle this is to add daysOfTheWeekPlural (here) (or something similar) and pull from those when needed. But, I think Danish would be the only translation to use this.

rmja commented 6 days ago

@Lars-Sommer How about "Kl 03:00, på enhver søndag, fredag, og lørdag" or similar. That would remove the need for the plural weekday.

Lars-Sommer commented 3 days ago

@Lars-Sommer How about "Kl 03:00, på enhver søndag, fredag, og lørdag" or similar. That would remove the need for the plural weekday.

I think that would be a good alternative 👍