Skip to content

Commit 7ab44ca

Browse files
committed
feat: add support for korean
1 parent b208ad2 commit 7ab44ca

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

next-i18next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require("path");
33

44
module.exports = {
55
i18n: {
6-
locales: ["en", "bg", "es", "hr"],
6+
locales: ["en", "bg", "es", "hr", "ko", "zh"],
77
defaultLocale: "en",
88
},
99
localePath: path.resolve("./public/locales"),

src/constants/languages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ export const languages: { [key: string]: string } = {
33
es: "Español",
44
bg: "Bulgarian",
55
hr: "Croatian",
6+
ko: "Korean",
7+
zh: "Chinese",
68
};

src/constants/locales.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const LOCALES = ["en", "bg", "es", "hr"];
1+
export const LOCALES = ["en", "bg", "es", "hr", "ko", "zh"];
22

33
export default LOCALES;

src/utilities/DateManager.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { formatDistance, millisecondsToMinutes, formatDuration, format as dateFormatter, intlFormat } from "date-fns";
2-
import { es, enUS, hr, bg, fr } from "date-fns/locale";
2+
import { es, enUS, hr, bg, fr, ko, zhCN } from "date-fns/locale";
33

44
export type LocaleDateFormat = string;
55

@@ -21,18 +21,8 @@ type FormatOptions = {
2121
*/
2222

2323
function getLocale(locale: LocaleDateFormat = "en"): Locale {
24-
switch (locale) {
25-
case "es":
26-
return es;
27-
case "hr":
28-
return hr;
29-
case "bg":
30-
return bg;
31-
case "fr":
32-
return fr;
33-
default:
34-
return enUS;
35-
}
24+
const locales = [es, enUS, hr, bg, fr, ko, zhCN];
25+
return locales.find(({ code }) => code === locale) || locales.find(({ code }) => code?.includes(locale)) || enUS;
3626
}
3727

3828
/**

0 commit comments

Comments
 (0)