Files
crewli/resources/vuexy-admin-v10.11.1/nextjs-version/javascript-version/full-version/src/hocs/TranslationWrapper.jsx

20 lines
597 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Component Imports
import LangRedirect from '@components/LangRedirect'
// Config Imports
import { i18n } from '@configs/i18n'
// We've to create this array because next.js makes request with `_next` prefix for static/asset files
const invalidLangs = ['_next']
const TranslationWrapper = props => {
const doesLangExist = i18n.locales.includes(props.lang)
// This doesn't mean MISSING, it means INVALID
const isInvalidLang = invalidLangs.includes(props.lang)
return doesLangExist || isInvalidLang ? props.children : <LangRedirect />
}
export default TranslationWrapper