-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from nea-c/dev
v0.3.3
- Loading branch information
Showing
15 changed files
with
386 additions
and
188 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,34 @@ | ||
import React, { useState } from 'react' | ||
import { Menu, MenuButton, MenuList, MenuItem, IconButton, Box } from '@yamada-ui/react' | ||
import { SegmentedControl, SegmentedControlButton, HStack, Text, CardHeader, CardBody } from '@yamada-ui/react' | ||
|
||
import { CheckIcon, GlobeIcon } from '@yamada-ui/lucide' | ||
import { GlobeIcon } from '@yamada-ui/lucide' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
export const LanguageChange = () => { | ||
const { i18n } = useTranslation() | ||
|
||
const [lang, setLang] = useState('') | ||
if (lang === '') { | ||
const get_lang = localStorage.getItem('lang') ?? 'ja' | ||
setLang(get_lang) | ||
i18n.changeLanguage(get_lang) | ||
} | ||
if (lang === '') setLang(localStorage.getItem('lang') ?? 'en') | ||
|
||
const onClickLang = (lang: string) => { | ||
i18n.changeLanguage(lang) | ||
localStorage.setItem('lang', lang) | ||
} | ||
|
||
return ( | ||
<Menu animation="top" gutter={0}> | ||
<MenuButton as={IconButton} icon={<GlobeIcon fontSize="lg" />} variant="outline" /> | ||
|
||
<MenuList style={{ padding: 0, margin: 0 }}> | ||
<MenuItem | ||
icon={<CheckIcon opacity={i18n.language === 'en' ? 1 : 0} fontSize="lg" />} | ||
onClick={() => onClickLang('en')} | ||
> | ||
<Box paddingBottom={0.5}>English</Box> | ||
</MenuItem> | ||
<MenuItem | ||
icon={<CheckIcon opacity={i18n.language === 'ja' ? 1 : 0} fontSize="lg" />} | ||
onClick={() => onClickLang('ja')} | ||
> | ||
<Box paddingBottom={0.5}>日本語</Box> | ||
</MenuItem> | ||
</MenuList> | ||
</Menu> | ||
<> | ||
<CardHeader> | ||
<HStack> | ||
<GlobeIcon fontSize="xl" /> | ||
<Text>Language / 言語</Text> | ||
</HStack> | ||
</CardHeader> | ||
<CardBody> | ||
<SegmentedControl value={i18n.language} onChange={onClickLang}> | ||
<SegmentedControlButton value="en">English</SegmentedControlButton> | ||
<SegmentedControlButton value="ja">日本語</SegmentedControlButton> | ||
</SegmentedControl> | ||
</CardBody> | ||
</> | ||
) | ||
} |
Oops, something went wrong.