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

feat: se locale #3724

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5828,6 +5828,16 @@
"default": "./locale/ru.mjs"
}
},
"./locale/se": {
"require": {
"types": "./locale/se.d.ts",
"default": "./locale/se.js"
},
"import": {
"types": "./locale/se.d.mts",
"default": "./locale/se.mjs"
}
},
"./locale/sk": {
"require": {
"types": "./locale/sk.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/locale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export * from "./pt/index.js";
export * from "./pt-BR/index.js";
export * from "./ro/index.js";
export * from "./ru/index.js";
export * from "./se/index.js";
export * from "./sk/index.js";
export * from "./sl/index.js";
export * from "./sq/index.js";
Expand Down
110 changes: 110 additions & 0 deletions src/locale/se/_lib/formatDistance/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import type { FormatDistanceFn, FormatDistanceLocale } from "../../../types.js";

type FormatDistanceTokenValue =
| string
| {
one: string;
other: string;
};

const formatDistanceLocale: FormatDistanceLocale<FormatDistanceTokenValue> = {
lessThanXSeconds: {
one: "unnit go ovtta sekundda",
other: "unnit go {{count}} sekundda",
},

xSeconds: {
one: "sekundda",
other: "{{count}} sekundda",
},

halfAMinute: "bealle minuhta",

lessThanXMinutes: {
one: "unnit go bealle minuhta",
other: "unnit go {{count}} minuhta",
},

xMinutes: {
one: "minuhta",
other: "{{count}} minuhta",
},

aboutXHours: {
one: "sullii ovtta diimmu",
other: "sullii {{count}} diimmu",
},

xHours: {
one: "diimmu",
other: "{{count}} diimmu",
},

xDays: {
one: "beaivvi",
other: "{{count}} beaivvi",
},

aboutXWeeks: {
one: "sullii ovtta vahku",
other: "sullii {{count}} vahku",
},

xWeeks: {
one: "vahku",
other: "{{count}} vahku",
},

aboutXMonths: {
one: "sullii ovtta mánu",
other: "sullii {{count}} mánu",
},

xMonths: {
one: "mánu",
other: "{{count}} mánu",
},

aboutXYears: {
one: "sullii ovtta jagi",
other: "sullii {{count}} jagi",
},

xYears: {
one: "jagi",
other: "{{count}} jagi",
},

overXYears: {
one: "guhkit go jagi",
other: "guhkit go {{count}} jagi",
},

almostXYears: {
one: "measta jagi",
other: "measta {{count}} jagi",
},
};

export const formatDistance: FormatDistanceFn = (token, count, options) => {
let result;

const tokenValue = formatDistanceLocale[token];
if (typeof tokenValue === "string") {
result = tokenValue;
} else if (count === 1) {
result = tokenValue.one;
} else {
result = tokenValue.other.replace("{{count}}", String(count));
}

if (options?.addSuffix) {
if (options.comparison && options.comparison > 0) {
return "geahčen " + result;
} else {
return result + " áigi";
}
}

return result;
};
40 changes: 40 additions & 0 deletions src/locale/se/_lib/formatLong/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { FormatLong } from "../../../types.js";
import { buildFormatLongFn } from "../../../_lib/buildFormatLongFn/index.js";

const dateFormats = {
full: "EEEE MMMM d. 'b.' y",
long: "MMMM d. 'b.' y",
medium: "MMM d. 'b.' y",
short: "dd.MM.y",
};

const timeFormats = {
full: "'dii.' HH:mm:ss zzzz",
long: "HH:mm:ss z",
medium: "HH:mm:ss",
short: "HH:mm",
};

const dateTimeFormats = {
full: "{{date}} 'dii.' {{time}}",
long: "{{date}} 'dii.' {{time}}",
medium: "{{date}} {{time}}",
short: "{{date}} {{time}}",
};

export const formatLong: FormatLong = {
date: buildFormatLongFn({
formats: dateFormats,
defaultWidth: "full",
}),

time: buildFormatLongFn({
formats: timeFormats,
defaultWidth: "full",
}),

dateTime: buildFormatLongFn({
formats: dateTimeFormats,
defaultWidth: "full",
}),
};
17 changes: 17 additions & 0 deletions src/locale/se/_lib/formatRelative/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { FormatRelativeFn } from "../../../types.js";

const formatRelativeLocale = {
lastWeek: "'ovddit' eeee 'dii.' p",
yesterday: "'ikte dii.' p",
today: "'odne dii.' p",
tomorrow: "'ihtin dii.' p",
nextWeek: "EEEE 'dii.' p",
other: "P",
};

export const formatRelative: FormatRelativeFn = (
token,
_date,
_baseDate,
_options,
) => formatRelativeLocale[token];
129 changes: 129 additions & 0 deletions src/locale/se/_lib/localize/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import type { Localize, LocalizeFn } from "../../../types.js";
import { buildLocalizeFn } from "../../../_lib/buildLocalizeFn/index.js";

const eraValues = {
narrow: ["o.Kr.", "m.Kr."] as const,
abbreviated: ["o.Kr.", "m.Kr."] as const,
wide: ["ovdal Kristusa", "maŋŋel Kristusa"] as const,
};

const quarterValues = {
narrow: ["1", "2", "3", "4"] as const,
abbreviated: ["Q1", "Q2", "Q3", "Q4"] as const,
wide: ["1. kvartála", "2. kvartála", "3. kvartála", "4. kvartála"] as const,
};

const monthValues = {
narrow: ["O", "G", "N", "C", "M", "G", "S", "B", "Č", "G", "S", "J"] as const,
abbreviated: [
"ođđa",
"guov",
"njuk",
"cuo",
"mies",
"geas",
"suoi",
"borg",
"čakč",
"golg",
"skáb",
"juov",
] as const,
wide: [
"ođđajagemánnu",
"guovvamánnu",
"njukčamánnu",
"cuoŋománnu",
"miessemánnu",
"geassemánnu",
"suoidnemánnu",
"borgemánnu",
"čakčamánnu",
"golggotmánnu",
"skábmamánnu",
"juovlamánnu",
] as const,
};

const dayValues = {
narrow: ["S", "V", "M", "G", "D", "B", "L"] as const,
short: ["sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"] as const,
abbreviated: ["sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"] as const,
wide: [
"sotnabeaivi",
"vuossárga",
"maŋŋebárga",
"gaskavahkku",
"duorastat",
"bearjadat",
"lávvardat",
] as const,
};

const dayPeriodValues = {
narrow: {
am: "a",
pm: "p",
midnight: "gaskaidja",
noon: "gaskabeaivi",
morning: "iđđes",
afternoon: "maŋŋel gaska.",
evening: "eahkes",
night: "ihkku",
},
abbreviated: {
am: "a.m.",
pm: "p.m.",
midnight: "gaskaidja",
noon: "gaskabeaivvi",
morning: "iđđes",
afternoon: "maŋŋel gaskabea.",
evening: "eahkes",
night: "ihkku",
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "gaskaidja",
noon: "gaskabeavvi",
morning: "iđđes",
afternoon: "maŋŋel gaskabeaivvi",
evening: "eahkes",
night: "ihkku",
},
};

const ordinalNumber: LocalizeFn<number> = (dirtyNumber, _options) => {
const number = Number(dirtyNumber);
return number + ".";
};

export const localize: Localize = {
ordinalNumber,

era: buildLocalizeFn({
values: eraValues,
defaultWidth: "wide",
}),

quarter: buildLocalizeFn({
values: quarterValues,
defaultWidth: "wide",
argumentCallback: (quarter) => quarter - 1,
}),

month: buildLocalizeFn({
values: monthValues,
defaultWidth: "wide",
}),

day: buildLocalizeFn({
values: dayValues,
defaultWidth: "wide",
}),

dayPeriod: buildLocalizeFn({
values: dayPeriodValues,
defaultWidth: "wide",
}),
};