microapps / gatsby-plugin-react-i18next

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

Fetch language specific data with namespaces and gatsby-transformer-json? #94

Open yujiahuang opened 2 years ago

yujiahuang commented 2 years ago

In the doc, there's a section "How to fetch language specific data" mentioning that this plugin can be used along side with gatsby-transformer-json.

export const query = graphql`
  query($language: String!) {
    dataJson(language: {eq: $language}) {
      ...DataFragment
    }
  }
`;

However when I tried to query, there is no language argument. My guess is that it requires a specific file structure, but couldn't figure it out. The structure I'm using is as follows:

|-- data
    |-- en
        |-- a.json
        |-- b.json
    |-- zh
        |-- a.json
        |-- b.json

Because I'm using namespaces, gatsby-transformer-json won't even parse dataJson. Instead it parses enJson and zhJson, and both of them don't have the language argument. Is it possible to fetch language specific data with namespaces?