Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

French: "de le" should be "du" and "de à" should be "de" #337

Open
1 task done
QuentiumYT opened this issue Feb 25, 2025 · 3 comments
Open
1 task done

French: "de le" should be "du" and "de à" should be "de" #337

QuentiumYT opened this issue Feb 25, 2025 · 3 comments

Comments

@QuentiumYT
Copy link

QuentiumYT commented Feb 25, 2025

Cron Expression
* * 3/6 * *

Expected Output
"Toutes les minutes, tous les 6 jours, à partir du 3 du mois"

Actual Output
"Toutes les minutes, tous les 6 jours, à partir de le 3 du mois"

Also it overlaps with the same bug for hours

Cron Expression
* 3/6 * * *

Expected Output
"Toutes les minutes, toutes les 6 heures, à partir de 03:00"

Actual Output
"Toutes les minutes, toutes les 6 heures, à partir de à 03:00"

Prerequisites

  • The cron expression being passed in is a valid expression. cRonstrue does not validate expressions and assumes the one you pass is already valid. See the FAQ for more details.
@QuentiumYT QuentiumYT changed the title French, "de le" should be "du" and "de à" should be "de" French: "de le" should be "du" and "de à" should be "de" Feb 25, 2025
@bradymholt
Copy link
Owner

@QuentiumYT - Do you know what updates need to be made to https://github.com/bradymholt/cRonstrue/blob/main/src/i18n/locales/fr.ts? Would you be up for submitting a PR?

@QuentiumYT
Copy link
Author

Hello, thanks for the quick reply. I have already tested a few things but it seems a bit hard to understand what everything does and what it could break. If you have a bit of time writing tests in french to ensure every actual possibility will not fail. Else I will look into it when I have a bit of time :)

@bradymholt
Copy link
Owner

Here are some French translation tests you could use to help.

Create a file named i18n-fr.ts with the following contents and drop it in the test/ folder.

import "mocha";
import chai = require("chai");

import cronstrue from "../src/cronstrue-i18n";
import "../src/i18n/locales/fr";

let assert = chai.assert;

describe("Cronstrue (fr)", function () {
  before(function () {
      cronstrue.defaultLocale = "fr"
    });

  describe("every", function () {
    it("* * * * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les secondes");
    });

    it("* * * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les minutes");
    });

    it("*/1 * * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les minutes");
    });

    it("*/5 * * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les 5 minutes");
    });

    it("0 0/1 * * * ?", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les minutes");
    });

    it("0 0 * * * ?", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les heures");
    });

    it("0 0 0/1 * * ?", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les heures");
    });
  });

  describe("interval", function () {
    it("*/45 * * * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les 45 secondes");
    });

    it("*/5 * * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les 5 minutes");
    });

    it("*/10 * * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les 10 minutes");
    });

    it("0 */5 * * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les 5 minutes");
    });

    it("0 * ? * 2/1 *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les heures, de mardi à samedi");
    });

    it("0 * ? * 1/1", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les heures, de lundi à samedi");
    });

    it("0 * ? * 2/1", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les heures, de mardi à samedi");
    });
  });

  describe("ranges", function () {

    it("23 12 * Jan-Mar *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 12:23, de janvier à mars");
    });

    it("23 12 * JAN-FEB *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 12:23, de janvier à février");
    });
  });

  describe("at", function () {
    it("29 10 * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 10:29");
    });

    it("30 10 * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 10:30");
    });

    it("29 10 * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 10:29");
    });

    it("30 10 * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 10:30");
    });

    it("23 12 * * SUN", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 12:23, uniquement le dimanche");
    });

    it("30 02 14 * * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 14:02:30");
    });

    it("0 0 6 1/1 * ?", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 06:00");
    });

    it("0 5 0/1 * * ?", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "5 minutes après l'heure");
    });

    it("23 12 * JAN *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 12:23, uniquement en janvier");
    });

    it("23 12 ? JAN *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 12:23, uniquement en janvier");    });

  });

  describe("weekday", function () {
    it("* * LW * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les minutes, le dernier jour ouvrable du mois");
    });

    it("* * WL * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les minutes, le dernier jour ouvrable du mois");
    });

    it("* * 1W * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les minutes, le premier jour ouvrable du mois");
    });

    it("* * W1 * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les minutes, le premier jour ouvrable du mois");
    });
  });

  describe("last", function () {
    it("* * * * 4L", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les minutes, le dernier jeudi du mois");
    });

    it("0 15 10 L * *", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "À 10:15, le dernier jour du mois");
    });
  });

  describe("non-trivial expressions", function () {
    it("* * * * MON#3", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les minutes, le troisième lundi du mois");
    });

    it("* * 5/8 * * ?", function () {
      assert.equal(cronstrue.toString(this.test?.title as string), "Toutes les secondes, toutes les 8 heures, à partir de à 05:00");
    });
  });
});

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

No branches or pull requests

2 participants