-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XS-30 | Multi language support - Xola app content (#334)
* XS-25 feat(purchase-guests): adds `CircleCheckFilledIcon` and `WarningFilledIcon` * feat: adds localization support for DatePicker * XS-30: adds translation-blacklist tag for DatePicker and Key * fix: updates sidebar component to support `className` and `align` props * XS-30 fixed date picker locale issues * XS-30 fixed locale in month year selector * XS-30 refactor * XS-30 fixed currency * XS-30 Added short months * XS-30 added console.logs * Moved locale files to import block * XS-30 changed lot messge * XS-30 fixed es-MX issue * XS-30 Added Support for classnames to sidemenubar text * XS-30 added condition for ignoring locale when its not there * XS-30 removed console.logs, lint fix * XS-30 Added XO config * XS-30 Dummy commit * Fix unicorn/no-console-spaces param * Update eslint.yml to use `ES_LINT_TOKEN` * npm audit fix by rushi --------- Co-authored-by: Manoj Vaibhav <[email protected]> Co-authored-by: Rushi Vishavadia <[email protected]>
- Loading branch information
1 parent
2b00715
commit b27eae8
Showing
14 changed files
with
162 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"complexity": ["warn", { "max": 25 }] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as de from "dayjs/locale/de"; | ||
import * as en from "dayjs/locale/en"; | ||
import * as enGB from "dayjs/locale/en-gb"; | ||
import * as es from "dayjs/locale/es"; | ||
import * as esMX from "dayjs/locale/es-mx"; | ||
import * as fr from "dayjs/locale/fr"; | ||
import type { DayPickerProps } from "react-day-picker"; | ||
|
||
export type LocaleCode = keyof typeof locales; | ||
|
||
interface ExtendedDayPickerProps extends DayPickerProps { | ||
monthsShort?: string; | ||
} | ||
|
||
export type LocalizationProps = Pick< | ||
ExtendedDayPickerProps, | ||
"locale" | "months" | "monthsShort" | "weekdaysLong" | "weekdaysShort" | "firstDayOfWeek" | ||
>; | ||
|
||
const locales = { | ||
en: en, | ||
en_US: en, | ||
en_GB: enGB, | ||
|
||
es: es, | ||
es_ES: es, | ||
es_MX: esMX, | ||
|
||
fr: fr, | ||
de: de, | ||
}; | ||
|
||
export const getLocalizationProps = async (localeCode: LocaleCode): Promise<Partial<LocalizationProps>> => { | ||
try { | ||
const locale = await locales[localeCode]; | ||
|
||
return { | ||
locale: localeCode, | ||
weekdaysLong: locale.weekdays, | ||
weekdaysShort: locale.weekdaysShort, | ||
months: locale.months, | ||
monthsShort: locale.monthsShort, | ||
firstDayOfWeek: locale.weekStart, | ||
}; | ||
} catch (error) { | ||
console.error("Error: React Day Picker localization error", error); | ||
throw error; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import clsx from "clsx"; | ||
import React, { forwardRef, useContext, useEffect, useState } from "react"; | ||
import DayPicker, { DayPickerProps } from "react-day-picker"; | ||
import { Context } from "../Provider"; | ||
import { getLocalizationProps, LocaleCode, LocalizationProps } from "./DatePicker.helpers"; | ||
|
||
export const LocalizedDayPicker = forwardRef<any, DayPickerProps>(({ className, ...rest }, ref) => { | ||
const { locale } = useContext(Context); | ||
const [localizationProps, setLocalizationProps] = useState<Partial<LocalizationProps>>({}); | ||
console.log("Locale", locale); | ||
|
||
useEffect(() => { | ||
setLocalizationProps({}); | ||
|
||
/** We don't want any localization-related props for "English" */ | ||
if (!locale || locale === "en" || locale === "en_US") return; | ||
|
||
getLocalizationProps(locale as LocaleCode).then(setLocalizationProps); | ||
}, [locale]); | ||
|
||
return <DayPicker ref={ref} className={clsx(className)} {...localizationProps} {...rest} />; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.