microapps / gatsby-plugin-react-i18next

Easily translate your Gatsby website into multiple languages
MIT License
122 stars 72 forks source link

On EN pages, languages display as in the configs. On all translated pages, all languages display. #164

Open broadsign-lekevoid opened 2 years ago

broadsign-lekevoid commented 2 years ago

From gatsby-config.js :

siteMetadata: {
    ...
},
trailingSlash: "never",
plugins: [
    ...
    {
        resolve: "gatsby-source-filesystem",
        options: {
            path: `${__dirname}/locales`,
            name: "locale",
        },
    },
    {
        resolve: "gatsby-plugin-react-i18next",
        options: {
            localeJsonSourceName: "locale",
            languages: ["en", "fr", "es"],
            defaultLanguage: "en",
            trailingSlash: "never",
            redirect: false,
            siteUrl: process.env.SITE_URL,
            i18nextOptions: {
                interpolation: {
                    escapeValue: false,
                },
            },
            pages: [
                {
                    matchPath: "/",
                    languages: ["en", "fr"],
                },
                {
                    matchPath: "/about",
                    languages: ["en", "fr"],
                },
            ],
        },
    },
    ...
],

An example of how it display : https://gatsby5i18ntest.gatsbyjs.io/

At the top of the homepage, only the link to FR appears ; that is the correct behavior. But if I go to /fr, then both EN and ES links appear whereas it should be EN only. Same thing happens on the /about page.

Am I missing something ?

I tried adding rules to the config like :

{
    matchPath: "/fr",
    languages: ["en", "fr"],
},
{
    matchPath: "fr",
    languages: ["en", "fr"],
},
{
    matchPath: "fr/",
    languages: ["en", "fr"],
},
{
    matchPath: "/fr/",
    languages: ["en", "fr"],
},

It doesn't change anything.

nabilk2 commented 1 year ago

I'm also experiencing the same exact issue, has there been any update on this?

0xGF commented 1 year ago

I'm experiencing this issue with my site as-well. It seems like the plugin hooks and lang are super inconsistent and return additional lang values that dont exists (lower case and duplicates) since my upgrade to gatsby 4.