From d11008904f1c31263fc73c787e5cb732e66d83b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Art=C5=ABras=20Bon=C4=8Dkus?= Date: Thu, 11 Apr 2024 17:42:50 +0300 Subject: [PATCH 1/4] feat: added Lithuanian language localization --- src/App.tsx | 3 ++- src/context/LocaleProvider/LocaleProvider.tsx | 4 +--- src/context/LocaleProvider/locales.ts | 8 ++++++++ src/locales/lt.ts | 17 +++++++++++++++++ src/types/global.ts | 2 +- 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/locales/lt.ts diff --git a/src/App.tsx b/src/App.tsx index bb03e910..909d0582 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -66,7 +66,7 @@ function App() { isLoading={false} onTileClick={handleTileClick} onFilterData={handleFilterData} - config={{ zoom: 0, maxRecordsPerPage: maxRecordsPerPage }} + config={{ zoom: 0, maxRecordsPerPage: maxRecordsPerPage, lang: "lt" }} onItemClick={(data) => console.log("clicked: ", data)} /> ) : ( @@ -79,6 +79,7 @@ function App() { onTileClick={handleTileClick} onFilterData={handleFilterData} onItemClick={(data) => console.log("clicked: ", data)} + config={{ zoom: 0, lang: "en" }} /> )} diff --git a/src/context/LocaleProvider/LocaleProvider.tsx b/src/context/LocaleProvider/LocaleProvider.tsx index 16791c00..82dfa2c9 100644 --- a/src/context/LocaleProvider/LocaleProvider.tsx +++ b/src/context/LocaleProvider/LocaleProvider.tsx @@ -1,7 +1,5 @@ import { useCallback, useContext, useEffect, useState } from "react"; import dayjs from "dayjs"; -import en from "dayjs/locale/en"; -import pl from "dayjs/locale/pl"; import { LangCodes } from "@/types/global"; import { localeContext } from "./localeContext"; import { locales } from "./locales"; @@ -14,7 +12,7 @@ const LocaleProvider = ({ children, lang }: LocaleProviderProps) => { const locale = locales.find((l) => { return l.id === localLang; }); - locale?.id === "en" ? dayjs.locale({ ...en }) : dayjs.locale({ ...pl }); + locale && dayjs.locale(locale?.id); return locale || locales[0]; }, [localLang]); diff --git a/src/context/LocaleProvider/locales.ts b/src/context/LocaleProvider/locales.ts index b5bbc850..c67c6d8e 100644 --- a/src/context/LocaleProvider/locales.ts +++ b/src/context/LocaleProvider/locales.ts @@ -1,5 +1,7 @@ import { en } from "@/locales/en"; import { pl } from "@/locales/pl"; +import { lt } from "@/locales/lt"; + import { LocaleType } from "./types"; export const locales: LocaleType[] = [ @@ -14,5 +16,11 @@ export const locales: LocaleType[] = [ name: "POLISH", lang: pl, translateCode: "pl-PL" + }, + { + id: "lt", + name: "LITHUANIAN", + lang: lt, + translateCode: "lt-LT" } ]; diff --git a/src/locales/lt.ts b/src/locales/lt.ts new file mode 100644 index 00000000..8f72e8b6 --- /dev/null +++ b/src/locales/lt.ts @@ -0,0 +1,17 @@ +export const lt = { + feelingEmpty: "I feel so empty...", + 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 097875ba..92703877 100644 --- a/src/types/global.ts +++ b/src/types/global.ts @@ -5,7 +5,7 @@ export type FilterButtonState = -1 | 0 | 1; type ZoomLevelTuple = typeof allZoomLevel; export type ZoomLevel = ZoomLevelTuple[number]; -export type LangCodes = "en" | "pl"; +export type LangCodes = "en" | "pl" | "lt"; export type Config = { zoom: ZoomLevel; /** From 80b72a24a8bb03ba1fb45e44f2b266562b203951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Art=C5=ABras=20Bon=C4=8Dkus?= Date: Fri, 12 Apr 2024 09:27:26 +0300 Subject: [PATCH 2/4] refactor: revert example app to its original state --- src/App.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 909d0582..bb03e910 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -66,7 +66,7 @@ function App() { isLoading={false} onTileClick={handleTileClick} onFilterData={handleFilterData} - config={{ zoom: 0, maxRecordsPerPage: maxRecordsPerPage, lang: "lt" }} + config={{ zoom: 0, maxRecordsPerPage: maxRecordsPerPage }} onItemClick={(data) => console.log("clicked: ", data)} /> ) : ( @@ -79,7 +79,6 @@ function App() { onTileClick={handleTileClick} onFilterData={handleFilterData} onItemClick={(data) => console.log("clicked: ", data)} - config={{ zoom: 0, lang: "en" }} /> )} From d40ab42a2ab5847961857bc892ba591713117746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Art=C5=ABras=20Bon=C4=8Dkus?= Date: Fri, 12 Apr 2024 09:35:42 +0300 Subject: [PATCH 3/4] fix: add missing translation --- src/locales/lt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/lt.ts b/src/locales/lt.ts index 8f72e8b6..786c5d33 100644 --- a/src/locales/lt.ts +++ b/src/locales/lt.ts @@ -1,5 +1,5 @@ export const lt = { - feelingEmpty: "I feel so empty...", + feelingEmpty: "Jaučiuosi toks tuščias...", free: "Laisva", loadNext: "Kitas", loadPrevious: "Ankstesnis", From 50ca98bd1e8094d422c53e0f5ae40194362e88ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Art=C5=ABras=20Bon=C4=8Dkus?= Date: Fri, 12 Apr 2024 09:40:51 +0300 Subject: [PATCH 4/4] docs: updated readme.md and development.md --- development.md | 2 +- readme.md | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/development.md b/development.md index 0ed66a52..53dd3b8b 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) +- **locales** - folder that consists files with translations (currently en / pl / 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 1bb84ac5..1053d0a5 100644 --- a/readme.md +++ b/readme.md @@ -138,13 +138,13 @@ const mockedSchedulerData: SchedulerData = [ ##### Scheduler Config Object -| Property Name | Type | Default | Description | -| ------------------------------------ | ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 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 | -| includeTakenHoursOnWeekendsInDayView | `boolean` | `false` | show weekends as taken when given resource is longer than a week | +| Property Name | Type | Default | Description | +| ------------------------------------ | ------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 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`, `pl` or `lt` | en | scheduler's language | +| includeTakenHoursOnWeekendsInDayView | `boolean` | `false` | show weekends as taken when given resource is longer than a week | ##### Scheduler Data