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

Idea for localization #11

Open
seagullua opened this issue Apr 11, 2024 · 0 comments
Open

Idea for localization #11

seagullua opened this issue Apr 11, 2024 · 0 comments

Comments

@seagullua
Copy link

We tried in our project to localize the calendar. It is possible to localize the names of months and weekdays just by knowing the locale.

return {
      name: "gregorian_en",
      digits: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
      months: Array.from({ length: 12 }, (_, i) => {
        const month = new DateObject({ year: 2001, month: i + 1, day: 1 });
        return [
          new Intl.DateTimeFormat(locale, { month: "long" }).format(month.toDate()),
          new Intl.DateTimeFormat(locale, { month: "short" }).format(month.toDate())
        ];
      }),
      weekDays: Array.from({ length: 7 }, (_, i) => {
        const day = new DateObject({ year: 2001, month: 2, day: i + 3 });
        return [
          new Intl.DateTimeFormat(locale, { weekday: "long" }).format(day.toDate()),
          new Intl.DateTimeFormat(locale, { weekday: "short" }).format(day.toDate())
        ];
      }),
      meridiems: [
        ["AM", "am"],
        ["PM", "pm"],
      ],
    };
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

1 participant