-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 #611 from idurar/feat/add-lang-select-in-login-page
🚀 Add ChanLaguage in Login page
- Loading branch information
Showing
5 changed files
with
74 additions
and
44 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
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,54 @@ | ||
import React from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import { languages } from '@/utils'; | ||
import { selectLangCode } from '@/redux/translate/selectors'; | ||
|
||
// import Notifications from '@/components/Notification'; | ||
|
||
import { translateAction } from '@/redux/translate/actions'; | ||
|
||
import useLanguage from '@/lang/useLanguage'; | ||
|
||
import { Select } from 'antd'; | ||
|
||
const ChangeLanguage = () => { | ||
const translate = useLanguage(); | ||
const dispatch = useDispatch(); | ||
|
||
const langCode = useSelector(selectLangCode); | ||
|
||
return ( | ||
<Select | ||
showSearch | ||
placeholder={translate('select language')} | ||
defaultValue={langCode} | ||
style={{ marginTop: '15px', width: '120px', float: 'right' }} | ||
optionFilterProp="children" | ||
filterOption={(input, option) => (option?.label ?? '').includes(input)} | ||
filterSort={(optionA, optionB) => | ||
(optionA?.label ?? '').toLowerCase().startsWith((optionB?.label ?? '').toLowerCase()) | ||
} | ||
onSelect={(value) => { | ||
dispatch(translateAction.translate(value)); | ||
}} | ||
> | ||
{languages.map((language) => ( | ||
<Select.Option | ||
key={language.value} | ||
value={language.value} | ||
label={language.label.toLowerCase()} | ||
> | ||
<div className="demo-option-label-item"> | ||
<span role="img" aria-label={language.label}> | ||
{language.icon} | ||
</span> | ||
{language.label} | ||
</div> | ||
</Select.Option> | ||
))} | ||
</Select> | ||
); | ||
}; | ||
|
||
export default ChangeLanguage; |
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