Download frontend/src/hooks/useLanguageOptions.js from leowuming/rag: direct link, hf CLI and curl.
- Browser
- Download file 598 Bytes
-
https://huggingface.co/spaces/leowuming/rag/resolve/main/frontend/src/hooks/useLanguageOptions.js
- Command line
-
hf download hf://spaces/leowuming/rag/frontend/src/hooks/useLanguageOptions.js
-
curl -L -o useLanguageOptions.js https://huggingface.co/spaces/leowuming/rag/resolve/main/frontend/src/hooks/useLanguageOptions.js
598 Bytes
| import i18n from "@/i18n"; | |
| import { resources as languages } from "@/locales/resources"; | |
| export function useLanguageOptions() { | |
| const supportedLanguages = Object.keys(languages); | |
| const languageNames = new Intl.DisplayNames(supportedLanguages, { | |
| type: "language", | |
| }); | |
| const changeLanguage = (newLang = "en") => { | |
| if (!Object.keys(languages).includes(newLang)) return false; | |
| i18n.changeLanguage(newLang); | |
| }; | |
| return { | |
| currentLanguage: i18n.language || "en", | |
| supportedLanguages, | |
| getLanguageName: (lang = "en") => languageNames.of(lang), | |
| changeLanguage, | |
| }; | |
| } | |