Skip to content

Idea for localization #11

Description

@seagullua

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"],
      ],
    };

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions