123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- import { buildLocalizeFn } from "../../_lib/buildLocalizeFn.js";
- const eraValues = {
- narrow: ["v.Chr.", "n.Chr."],
- abbreviated: ["v.Chr.", "n.Chr."],
- wide: ["vor Christus", "nach Christus"],
- };
- const quarterValues = {
- narrow: ["1", "2", "3", "4"],
- abbreviated: ["Q1", "Q2", "Q3", "Q4"],
- wide: ["1. Quartal", "2. Quartal", "3. Quartal", "4. Quartal"],
- };
- // Note: in German, the names of days of the week and months are capitalized.
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
- // Generally, formatted dates should look like they are in the middle of a sentence,
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
- const monthValues = {
- narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
- abbreviated: [
- "Jän",
- "Feb",
- "Mär",
- "Apr",
- "Mai",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Okt",
- "Nov",
- "Dez",
- ],
- wide: [
- "Jänner",
- "Februar",
- "März",
- "April",
- "Mai",
- "Juni",
- "Juli",
- "August",
- "September",
- "Oktober",
- "November",
- "Dezember",
- ],
- };
- // https://st.unicode.org/cldr-apps/v#/de_AT/Gregorian/
- const formattingMonthValues = {
- narrow: monthValues.narrow,
- abbreviated: [
- "Jän.",
- "Feb.",
- "März",
- "Apr.",
- "Mai",
- "Juni",
- "Juli",
- "Aug.",
- "Sep.",
- "Okt.",
- "Nov.",
- "Dez.",
- ],
- wide: monthValues.wide,
- };
- const dayValues = {
- narrow: ["S", "M", "D", "M", "D", "F", "S"],
- short: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
- abbreviated: ["So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."],
- wide: [
- "Sonntag",
- "Montag",
- "Dienstag",
- "Mittwoch",
- "Donnerstag",
- "Freitag",
- "Samstag",
- ],
- };
- // https://www.unicode.org/cldr/charts/32/summary/de.html#1881
- const dayPeriodValues = {
- narrow: {
- am: "vm.",
- pm: "nm.",
- midnight: "Mitternacht",
- noon: "Mittag",
- morning: "Morgen",
- afternoon: "Nachm.",
- evening: "Abend",
- night: "Nacht",
- },
- abbreviated: {
- am: "vorm.",
- pm: "nachm.",
- midnight: "Mitternacht",
- noon: "Mittag",
- morning: "Morgen",
- afternoon: "Nachmittag",
- evening: "Abend",
- night: "Nacht",
- },
- wide: {
- am: "vormittags",
- pm: "nachmittags",
- midnight: "Mitternacht",
- noon: "Mittag",
- morning: "Morgen",
- afternoon: "Nachmittag",
- evening: "Abend",
- night: "Nacht",
- },
- };
- const formattingDayPeriodValues = {
- narrow: {
- am: "vm.",
- pm: "nm.",
- midnight: "Mitternacht",
- noon: "Mittag",
- morning: "morgens",
- afternoon: "nachm.",
- evening: "abends",
- night: "nachts",
- },
- abbreviated: {
- am: "vorm.",
- pm: "nachm.",
- midnight: "Mitternacht",
- noon: "Mittag",
- morning: "morgens",
- afternoon: "nachmittags",
- evening: "abends",
- night: "nachts",
- },
- wide: {
- am: "vormittags",
- pm: "nachmittags",
- midnight: "Mitternacht",
- noon: "Mittag",
- morning: "morgens",
- afternoon: "nachmittags",
- evening: "abends",
- night: "nachts",
- },
- };
- const ordinalNumber = (dirtyNumber) => {
- const number = Number(dirtyNumber);
- return number + ".";
- };
- export const localize = {
- ordinalNumber,
- era: buildLocalizeFn({
- values: eraValues,
- defaultWidth: "wide",
- }),
- quarter: buildLocalizeFn({
- values: quarterValues,
- defaultWidth: "wide",
- argumentCallback: (quarter) => quarter - 1,
- }),
- month: buildLocalizeFn({
- values: monthValues,
- formattingValues: formattingMonthValues,
- defaultWidth: "wide",
- }),
- day: buildLocalizeFn({
- values: dayValues,
- defaultWidth: "wide",
- }),
- dayPeriod: buildLocalizeFn({
- values: dayPeriodValues,
- defaultWidth: "wide",
- formattingValues: formattingDayPeriodValues,
- defaultFormattingWidth: "wide",
- }),
- };
|