-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8140ec4
commit eed5360
Showing
14 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...s/routes/library/platform/home-screen/top-bar/top-bar-dropdown/config-language-button.tsx
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,25 @@ | ||
import { useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { BaseDialogTrigger } from '../../../../../../primitives/base-dialog-trigger' | ||
import { TopBarButton } from '../top-bar-button' | ||
import { ConfigLanguageDialogContent } from './config-language-dialog-content' | ||
|
||
export function ConfigLanguageButton() { | ||
const { t } = useTranslation() | ||
const [open, setOpen] = useState(false) | ||
|
||
function onOpenChange(open) { | ||
setOpen(open) | ||
} | ||
|
||
return ( | ||
<BaseDialogTrigger content={<ConfigLanguageDialogContent />} onOpenChange={onOpenChange} open={open}> | ||
<TopBarButton> | ||
<div className='flex items-center gap-2 px-4'> | ||
<span className='icon-[mdi--translate-variant] relative z-[1] h-8 w-8' /> | ||
{t('Language')} | ||
</div> | ||
</TopBarButton> | ||
</BaseDialogTrigger> | ||
) | ||
} |
53 changes: 53 additions & 0 deletions
53
.../library/platform/home-screen/top-bar/top-bar-dropdown/config-language-dialog-content.tsx
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,53 @@ | ||
import { DialogClose } from '@radix-ui/react-dialog' | ||
import { useLocalStorageValue } from '@react-hookz/web' | ||
import { useTranslation } from 'react-i18next' | ||
import { BaseButton } from '../../../../../../primitives/base-button' | ||
|
||
export function ConfigLanguageDialogContent() { | ||
const { t, i18n } = useTranslation() | ||
|
||
const { value, set, remove } = useLocalStorageValue<string>('i18nextLng', { | ||
parse(str) { | ||
return str | ||
}, | ||
stringify(data) { | ||
return `${data}` | ||
}, | ||
}) | ||
|
||
function updateLanguage(language: string) { | ||
if (language) { | ||
set(language) | ||
} else { | ||
remove() | ||
} | ||
i18n.changeLanguage() | ||
} | ||
|
||
return ( | ||
<div> | ||
<select className='w-52' onChange={(e) => updateLanguage(e.target.value)} value={value || ''}> | ||
<option value=''>{t('Auto detect')}</option> | ||
<option value='ar'>عربي</option> | ||
<option value='de'>Deutsch</option> | ||
<option value='en'>English</option> | ||
<option value='es'>Española</option> | ||
<option value='fr'>Français</option> | ||
<option value='it'>Italiana</option> | ||
<option value='ja'>日本語</option> | ||
<option value='pl'>Polski</option> | ||
<option value='pt'>Português</option> | ||
<option value='ru'>Русский</option> | ||
<option value='zh'>中文</option> | ||
</select> | ||
<div className='flex-center mt-8 gap-5'> | ||
<DialogClose asChild> | ||
<BaseButton className='autofocus' styleType='primary'> | ||
<span className='icon-[mdi--close] h-5 w-5' /> | ||
{t('Close')} | ||
</BaseButton> | ||
</DialogClose> | ||
</div> | ||
</div> | ||
) | ||
} |
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
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