kalinchernev / using-i18n

Using https://github.com/gatsbyjs/gatsby/tree/master/examples/using-i18n
MIT License
24 stars 4 forks source link

Always change language where necessary if path changes #3

Closed deanc closed 4 years ago

deanc commented 4 years ago

A fix for this issue: https://github.com/kalinchernev/using-i18n/issues/1

kalinchernev commented 4 years ago

It's no worries, for the example here it's good. In actual project some checks whether its necessary to make the change of language will be easy to make

On Fri, 13 Dec 2019, 12:58 Dean Clatworthy, notifications@github.com wrote:

@deanc commented on this pull request.

In src/layouts/index.js https://github.com/kalinchernev/using-i18n/pull/3#discussion_r357613450:

import withI18next from "../i18n/withI18next";

-const Layout = ({ children }) => { +const Layout = ({ children, location, pageContext: { locale }}) => { +

  • const { i18n } = useTranslation()
  • useEffect(() => {
  • i18n.changeLanguage(locale)
  • }, [location, i18n, locale])

Sure, but think of it this way. It's used inside the hook, so it is a dependency.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/kalinchernev/using-i18n/pull/3?email_source=notifications&email_token=AAOVTFCRFRTIH22EUBDTNHTQYN2IBA5CNFSM4J2DC4IKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCPDURAY#discussion_r357613450, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOVTFCCCR2JNGTT6DCZJN3QYN2IBANCNFSM4J2DC4IA .