1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-12-01 17:04:19 +00:00
pds-2021-g2-nest/nest_frontend/components/providers/GlobalLanguage.js

27 lines
705 B
JavaScript
Raw Normal View History

2021-05-18 00:48:34 +00:00
import React from "react"
2021-05-18 00:04:06 +00:00
import useLocalStorageState from "../../hooks/useLocalStorageState"
import ContextLanguage from "../../contexts/ContextLanguage"
import LocalizationStrings from "../../LocalizationStrings"
/**
* Provides {@link ContextLanguage} to all contained elements.
*
* Defaults to using Italian.
*
* @param children
* @returns {JSX.Element}
* @constructor
*/
export default function GlobalLanguage({ children }) {
const [lang, setLang] = useLocalStorageState("language", "it")
const strings = LocalizationStrings[lang]
return (
<ContextLanguage.Provider value={{ lang, setLang, strings }}>
{children}
</ContextLanguage.Provider>
)
}