diff --git a/development.md b/development.md index 31b89bcc..15cb9c61 100644 --- a/development.md +++ b/development.md @@ -43,7 +43,7 @@ To set up the project locally for development and testing, please follow these s ``` - **constants** - all constants that are globally used and should not change during usage of app, e.g.: height and width of cell, width of single tile. - **context** - folder that consists CalendarProvider and LocaleProvider -- **locales** - folder that consists files with translations (currently en / pl / de) +- **locales** - folder that consists files with translations (currently en / pl / de / lt) - **types** - folder that consists all global types and type guards - **utils** - folder that consists all utility functions used within app (e.g. drawing all the grid, data parsers etc.) diff --git a/readme.md b/readme.md index e290bb63..2f42b96d 100644 --- a/readme.md +++ b/readme.md @@ -168,7 +168,7 @@ const mockedSchedulerData: SchedulerData = [ | zoom | `0` or `1` | 0 | `0` - display grid divided into weeks `1` - display grid divided into days | | filterButtonState | `number` | 0 | `< 0` - hides filter button, `0` - state for when filters were not set, `> 0` - state for when some filters were set (allows to also handle `onClearFilterData` event) | | maxRecordsPerPage | `number` | 50 | number of items from `SchedulerData` visible per page | -| lang | `en` or `pl` | en | scheduler's language | +| lang | `en`, `lt` or `pl` | en | scheduler's language | | includeTakenHoursOnWeekendsInDayView | `boolean` | `false` | show weekends as taken when given resource is longer than a week | | showTooltip | `boolean` | `true` | show tooltip when hovering over tiles | | translations | `LocaleType[]` | `undefined` | option to add specific langs translations | @@ -245,6 +245,7 @@ const langs: LocaleType[] = [ | today | `string` | | view | `string` | + ##### Scheduler Data array of chart rows with shape of diff --git a/src/context/LocaleProvider/LocaleProvider.tsx b/src/context/LocaleProvider/LocaleProvider.tsx index 3afa8bc5..d4818a94 100644 --- a/src/context/LocaleProvider/LocaleProvider.tsx +++ b/src/context/LocaleProvider/LocaleProvider.tsx @@ -13,11 +13,13 @@ const LocaleProvider = ({ children, lang, translations }: LocaleProviderProps) = return l.id === localLang; }); + if (typeof locale?.dayjsTranslations === "object") { dayjs.locale(locale.dayjsTranslations); } return locale || localesData[0]; + }, [localLang]); const [currentLocale, setCurrentLocale] = useState(findLocale()); diff --git a/src/context/LocaleProvider/locales.ts b/src/context/LocaleProvider/locales.ts index 62b89202..28243726 100644 --- a/src/context/LocaleProvider/locales.ts +++ b/src/context/LocaleProvider/locales.ts @@ -1,7 +1,9 @@ + import enDayjsTranslations from "dayjs/locale/en"; import plDayjsTranslations from "dayjs/locale/pl"; import deDayjsTranslations from "dayjs/locale/de"; -import { en, pl, de } from "@/locales"; +import ltDayjsTranslations from "dayjs/locale/lt"; +import { en, pl, de, lt } from "@/locales"; import { LocaleType } from "./types"; export const localesData: LocaleType[] = [ @@ -14,9 +16,15 @@ export const localesData: LocaleType[] = [ { id: "pl", lang: pl, - translateCode: "pl-PL", + translateCode: "pl-PL" dayjsTranslations: plDayjsTranslations }, + { + id: "lt", + lang: lt, + translateCode: "lt-LT" + dayjsTranslations: ltDayjsTranslations + }, { id: "de", lang: de, diff --git a/src/locales/lt.ts b/src/locales/lt.ts new file mode 100644 index 00000000..786c5d33 --- /dev/null +++ b/src/locales/lt.ts @@ -0,0 +1,17 @@ +export const lt = { + feelingEmpty: "Jaučiuosi toks tuščias...", + free: "Laisva", + loadNext: "Kitas", + loadPrevious: "Ankstesnis", + over: "virš", + taken: "Užimta", + topbar: { + filters: "Filtras", + next: "kitas", + prev: "ankstesnis", + today: "Šiandien", + view: "Rodinys" + }, + search: "ieškoti", + week: "savaitė" +}; diff --git a/src/types/global.ts b/src/types/global.ts index 8f506893..dc5104fc 100644 --- a/src/types/global.ts +++ b/src/types/global.ts @@ -7,7 +7,9 @@ export type FilterButtonState = -1 | 0 | 1; type ZoomLevelTuple = typeof allZoomLevel; export type ZoomLevel = ZoomLevelTuple[number]; -export type LangCodes = "en" | "pl" | "de"; + +export type LangCodes = "en" | "pl" | "de" | "lt"; + export type Config = { zoom: ZoomLevel; /**