UNPKG

gatsby-theme-i18n

Version:

A Gatsby theme for providing internationalization support to your Gatsby site by taking in a configuration file and creating prefixed, enriched pages for each language.

37 lines (33 loc) 718 B
import * as React from "react" import { LocaleContext } from "../context" import { graphql, useStaticQuery } from "gatsby" import { localizedPath } from "../helpers" const useLocalization = () => { const locale = React.useContext(LocaleContext) const { themeI18N: { defaultLang, prefixDefault, config }, } = useStaticQuery(graphql` query LocalizationConfigQuery { themeI18N { defaultLang prefixDefault config { code hrefLang dateFormat langDir localName name } } } `) return { locale, defaultLang, prefixDefault, config, localizedPath, } } export { useLocalization }