From a86b28852d65b3f11509c1a7f87fa54148100a20 Mon Sep 17 00:00:00 2001 From: FinnRG Date: Fri, 26 May 2023 15:30:18 +0200 Subject: [PATCH] feat: Extend language options --- VocaDbWeb/Scripts/App.tsx | 3 ++ .../Shared/Partials/Knockout/DropdownList.tsx | 20 +++++-- .../Shared/Partials/Song/LyricsInfo.tsx | 6 +-- .../extendedUserLanguageCultures.ts | 11 ++++ VocaDbWeb/Scripts/CultureCodesContext.tsx | 52 +++++++++++++++++++ .../Pages/Song/Partials/LyricsForSongEdit.tsx | 26 ++++++++-- .../Scripts/Pages/Song/SongDetailsRoutes.tsx | 5 +- VocaDbWeb/Scripts/Pages/Song/SongLyrics.tsx | 5 +- VocaDbWeb/Scripts/i18n.ts | 2 +- VocaDbWeb/package-lock.json | 29 ++++++----- VocaDbWeb/package.json | 1 + VocaDbWeb/public/locales/en/ViewRes.Song.json | 1 + 12 files changed, 132 insertions(+), 29 deletions(-) create mode 100644 VocaDbWeb/Scripts/Components/extendedUserLanguageCultures.ts create mode 100644 VocaDbWeb/Scripts/CultureCodesContext.tsx diff --git a/VocaDbWeb/Scripts/App.tsx b/VocaDbWeb/Scripts/App.tsx index f4401704ea..63d8badde1 100644 --- a/VocaDbWeb/Scripts/App.tsx +++ b/VocaDbWeb/Scripts/App.tsx @@ -18,6 +18,8 @@ import React from 'react'; import { Toaster } from 'react-hot-toast'; import { BrowserRouter } from 'react-router-dom'; +import { CultureCodesProvider } from './CultureCodesContext'; + const TetoDB = React.lazy(() => import('./styles/tetoDb')); const DarkAngel = React.lazy(() => import('./styles/darkAngel')); @@ -72,6 +74,7 @@ const App = (): React.ReactElement => { NostalgicDivaProvider, VdbPlayerProvider, MutedUsersProvider, + CultureCodesProvider, ]} > diff --git a/VocaDbWeb/Scripts/Components/Shared/Partials/Knockout/DropdownList.tsx b/VocaDbWeb/Scripts/Components/Shared/Partials/Knockout/DropdownList.tsx index 6578801433..64a2b40d58 100644 --- a/VocaDbWeb/Scripts/Components/Shared/Partials/Knockout/DropdownList.tsx +++ b/VocaDbWeb/Scripts/Components/Shared/Partials/Knockout/DropdownList.tsx @@ -13,7 +13,7 @@ import { SongListFeaturedCategory } from '@/Models/SongLists/SongListFeaturedCat import { UserEmailOptions } from '@/Models/Users/UserEmailOptions'; import { UserGroup } from '@/Models/Users/UserGroup'; import { useVdb } from '@/VdbContext'; -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; let nextEventCategoryOrder = 1; @@ -119,14 +119,28 @@ export const CultureDropdownList = React.memo( }, ); +interface UserLanguageCultureDropdownListProps extends DropdownListProps { + extended?: boolean; +} + export const UserLanguageCultureDropdownList = React.memo( - (props: DropdownListProps): React.ReactElement => { + (props: UserLanguageCultureDropdownListProps): React.ReactElement => { + const [cultures, setCultures] = useState(userLanguageCultures); + + useEffect(() => { + if (props.extended) { + import('../../../extendedUserLanguageCultures').then((res) => { + setCultures(res.extendedUserLanguageCultures); + }); + } + }, [props.extended]); + return (