-
Notifications
You must be signed in to change notification settings - Fork 1
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 #45 from Chia-Network/nwo-enhancements
feat: implement localization to broadcast locale changes to child apps
- Loading branch information
Showing
3 changed files
with
85 additions
and
20 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,39 @@ | ||
import React, { useState } from "react"; | ||
import styled, { withTheme } from "styled-components"; | ||
import { Dropdown } from "flowbite-react"; | ||
|
||
const LANGUAGE_CODES = Object.freeze({ | ||
ENGLISH: "en-US", | ||
SPANISH: "es-ES", | ||
FRENCH: "fr-FR", | ||
GERMAN: "de-DE", | ||
CHINESE: "cn", | ||
}); | ||
|
||
const LocaleSwitcher = ({ handleLocaleChange }) => { | ||
const [currentLanguage, setCurrentLanguage] = useState( | ||
LANGUAGE_CODES["ENGLISH"] | ||
); | ||
|
||
const handleChange = (value) => { | ||
setCurrentLanguage(value); | ||
handleLocaleChange(value); | ||
}; | ||
return ( | ||
<Dropdown | ||
label={currentLanguage} | ||
> | ||
{Object.keys(LANGUAGE_CODES).map((key) => ( | ||
<Dropdown.Item | ||
key={LANGUAGE_CODES[key]} | ||
onClick={() => handleChange(LANGUAGE_CODES[key])} | ||
value={LANGUAGE_CODES[key]} | ||
> | ||
{key} | ||
</Dropdown.Item> | ||
))} | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export { LocaleSwitcher }; |
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