Repository: bradymholt/cRonstrue
Pull request #291 (2023-08-11 15:18:27)

feat: Add Malay (Malaysia) Locale
Hi!

Adding `my` Malay (Malaysia) Locales to the mix.

Cheers!

bradymholt: Thanks!

Patch:
diff --git a/README.md b/README.md
index 578c854..9e4b13c 100644
--- a/README.md
+++ b/README.md
@@ -232,6 +232,7 @@ cronstrue.toString("*/5 * * * *", { locale: "es" }); // => Cada 5 minutos
 - hu - Hungarian ([Orcsity Norbert](https://github.com/Northber), Szabó Dániel)
 - af - Afrikaans (Michael van Niekerk(https://github.com/mvniekerk))
 - vi - Vietnamese ([Nguyen Tan Phap](https://github.com/rikkapro0128))
+- my - Malay (Malaysia) ([Ikhwan Abdullah](https://github.com/leychay))
 
 ## License
 
diff --git a/src/i18n/allLocales.ts b/src/i18n/allLocales.ts
index 1438b6a..dea2de2 100644
--- a/src/i18n/allLocales.ts
+++ b/src/i18n/allLocales.ts
@@ -33,3 +33,4 @@ export { af } from "./locales/af"; // Afrikaans
 export { th } from "./locales/th"; // Thai
 export { ar } from './locales/ar'; // Arabic
 export { vi } from './locales/vi'; // Vietnamese
+export { my } from './locales/my'; // Malay
diff --git a/src/i18n/locales/my.ts b/src/i18n/locales/my.ts
new file mode 100644
index 0000000..6032e98
--- /dev/null
+++ b/src/i18n/locales/my.ts
@@ -0,0 +1,179 @@
+// Malay
+
+import { Locale } from "../locale";
+export class my implements Locale {
+  atX0SecondsPastTheMinuteGt20(): string|null {
+    return null;
+  }
+  atX0MinutesPastTheHourGt20(): string|null {
+    return null;
+  }
+  commaMonthX0ThroughMonthX1(): string|null {
+    return null;
+  }
+  commaYearX0ThroughYearX1(): string|null {
+    return null;
+  }
+
+  use24HourTimeFormatByDefault() {
+    return false;
+  }
+
+  anErrorOccuredWhenGeneratingTheExpressionD() {
+    return "Terdapat ralat semasa menjana penerangan ungkapan. Sila periksa sintaks ungkapan cron.";
+  }
+  everyMinute() {
+    return "setiap minit";
+  }
+  everyHour() {
+    return "setiap jam";
+  }
+  atSpace() {
+    return "Pada ";
+  }
+  everyMinuteBetweenX0AndX1() {
+    return "Setiap minit antara %s dan %s";
+  }
+  at() {
+    return "Pada";
+  }
+  spaceAnd() {
+    return " dan";
+  }
+  everySecond() {
+    return "setiap saat";
+  }
+  everyX0Seconds() {
+    return "setiap %s saat";
+  }
+  secondsX0ThroughX1PastTheMinute() {
+    return "saat ke %s hingga %s selepas minit";
+  }
+  atX0SecondsPastTheMinute() {
+    return "pada %s saat selepas minit";
+  }
+  everyX0Minutes() {
+    return "setiap %s minit";
+  }
+  minutesX0ThroughX1PastTheHour() {
+    return "minit ke %s hingga %s selepas jam";
+  }
+  atX0MinutesPastTheHour() {
+    return "pada %s minit selepas jam";
+  }
+  everyX0Hours() {
+    return "setiap %s jam";
+  }
+  betweenX0AndX1() {
+    return "antara %s dan %s";
+  }
+  atX0() {
+    return "pada %s";
+  }
+  commaEveryDay() {
+    return ", setiap hari";
+  }
+  commaEveryX0DaysOfTheWeek() {
+    return ", setiap %s hari dalam minggu";
+  }
+  commaX0ThroughX1() {
+    return ", %s hingga %s";
+  }
+  commaAndX0ThroughX1() {
+    return ", dan %s hingga %s";
+  }
+  first() {
+    return "pertama";
+  }
+  second() {
+    return "kedua";
+  }
+  third() {
+    return "ketiga";
+  }
+  fourth() {
+    return "keempat";
+  }
+  fifth() {
+    return "kelima";
+  }
+  commaOnThe() {
+    return ", pada ";
+  }
+  spaceX0OfTheMonth() {
+    return " %s pada bulan";
+  }
+  lastDay() {
+    return "hari terakhir";
+  }
+  commaOnTheLastX0OfTheMonth() {
+    return ", pada %s terakhir bulan";
+  }
+  commaOnlyOnX0() {
+    return ", hanya pada %s";
+  }
+  commaAndOnX0() {
+    return ", dan pada %s";
+  }
+  commaEveryX0Months() {
+    return ", setiap bulan %s";
+  }
+  commaOnlyInX0() {
+    return ", hanya pada %s";
+  }
+  commaOnTheLastDayOfTheMonth() {
+    return ", pada hari terakhir bulan";
+  }
+  commaOnTheLastWeekdayOfTheMonth() {
+    return ", pada minggu terakhir bulan";
+  }
+  commaDaysBeforeTheLastDayOfTheMonth() {
+    return ", %s hari sebelum hari terakhir bulan";
+  }
+  firstWeekday() {
+    return "hari pertama minggu bekerja";
+  }
+  weekdayNearestDayX0() {
+    return "hari bekerja yang terdekat dengan %s";
+  }
+  commaOnTheX0OfTheMonth() {
+    return ", pada %s bulan";
+  }
+  commaEveryX0Days() {
+    return ", setiap %s hari";
+  }
+  commaBetweenDayX0AndX1OfTheMonth() {
+    return ", antara hari %s dan %s dalam bulan";
+  }
+  commaOnDayX0OfTheMonth() {
+    return ", pada hari %s dalam bulan";
+  }
+  commaEveryHour() {
+    return ", setiap jam";
+  }
+  commaEveryX0Years() {
+    return ", setiap %s tahun";
+  }
+  commaStartingX0() {
+    return ", bermula %s";
+  }
+  daysOfTheWeek() {
+    return ["Ahad", "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu"];
+  }
+  monthsOfTheYear() {
+    return [
+      "Januari",
+      "Februari",
+      "Mac",
+      "April",
+      "Mei",
+      "Jun",
+      "Julai",
+      "Ogos",
+      "September",
+      "Oktober",
+      "November",
+      "Disember",
+    ];
+  }
+}


Test patch:
diff --git a/test/i18n.ts b/test/i18n.ts
index 5daeb64..c55b831 100644
--- a/test/i18n.ts
+++ b/test/i18n.ts
@@ -344,4 +344,45 @@ describe("i18n", function () {
       assert.equal(cronstrue.toString(this.test?.title as string, { locale: "ar" }), "كل دقيقة");
     });
   });
+  describe("my", function () {
+    it("* * * * *", function () {
+      assert.equal(cronstrue.toString(this.test?.title as string, { locale: "my" }), "Setiap minit");
+    });
+
+    it("0 * * * *", function () {
+      assert.equal(
+        cronstrue.toString(this.test?.title as string, { locale: "my", use24HourTimeFormat: true }),
+        "Setiap jam"
+      );
+    });
+
+    it("*/5 15 * * MON-FRI", function () {
+      assert.equal(
+        cronstrue.toString(this.test?.title as string, { locale: "my", use24HourTimeFormat: true }),
+        "Setiap 5 minit, antara 15:00 dan 15:59, Isnin hingga Jumaat"
+      );
+    });
+
+    it("0 5 1/1 * *", function () {
+      assert.equal(
+        cronstrue.toString(this.test?.title as string, { locale: "my", use24HourTimeFormat: true }),
+        "Pada 05:00"
+      );
+    });
+
+    it("15 11 * 1/5 MON", function () {
+      assert.equal(
+        cronstrue.toString(this.test?.title as string, { locale: "my", use24HourTimeFormat: true }),
+        "Pada 11:15, hanya pada Isnin, setiap bulan 5"
+      );
+    });
+
+    it("0 7 * * MON,TUE,THU,FRI,SUN", function () {
+      assert.equal(
+        cronstrue.toString(this.test?.title as string, { locale: "my", use24HourTimeFormat: true }),
+        "Pada 07:00, hanya pada Isnin, Selasa, Khamis, Jumaat, dan Ahad"
+      );
+    });
+
+  });
 });