matthewbub / calendar-widgets

Craft beautifully robust date components in React.
http://calendar-widgets.com/
MIT License
4 stars 13 forks source link

provide support for various locales #59

Closed matthewbub closed 1 year ago

matthewbub commented 1 year ago

We were originally using ChatGPT to translate languages, but I'm not 100% confident in it that. PRs are welcome here 👋 This will ultimately be outsourced when we reach a stable release

Supported so far

Ankan-cyber commented 1 year ago

I can help with bn-IN that's my native language

Ankan-cyber commented 1 year ago

added pr to merge for added bn-IN locale

matthewbub commented 1 year ago

Incredible stuff @Ankan-cyber many thanks!! 🙇‍♂️

Ankan-cyber commented 1 year ago

added pr to merge for added gu-IN locale #95

matthewbub commented 1 year ago

updated this list to display gu-IN as a supported portal in an upcoming release 🙂

matthewbub commented 1 year ago

marking this as closed as it may face depreciation soon. It is capable to replace this with the Date object

import { ONE, TWELVE, TWO_THOUSAND } from '../constants';

export type MonthFormat = 'long' | 'short' | 'narrow' | 'numeric' | '2-digit';

/**
 * Returns an array of localized month names.
 *
 * @param {string} locale - The BCP 47 language tag of the locale to use.
 * @param {MonthFormat} monthFormat - The format of the month names to return.
 * @returns {string[]} An array of localized month names.
 */
export const listLocalizedMonths = (locale: string, monthFormat: MonthFormat): Array<string> =>
  Array.from({ length: TWELVE }, (_, i) =>
    new Date(Date.UTC(TWO_THOUSAND, i, ONE)).toLocaleString(locale, { month: monthFormat })
  );