Languages & localization

This article helps collect all the resources you need to take advantage of Prismic's multi-language and localization feature when building a Gatsby website.


1. Add languages in your repo

The first step is to go to your Dashboard, select your Prismic repository, and add all the languages you need in your repo's Settings. Prismic offers a robust library of language codes, but you can create a custom locale if the one you need isn't on the list.

3. Plugin configuration

You'll need to add all the existing languages in your repo in the plugin configuration: options.lang in your gatsby-config.js file. In the following example plugin configuration, we set the lang value to be * which will fetch all languages.:

Copy
module.exports = {
 plugins: [
 {
      resolve: 'gatsby-source-prismic',
      options: {
        repositoryName: 'example-repository-name',
        lang: '*',
        schemas: {
          page: require('./custom_types/example_type.json'),
        },
      },
    },
  ] 
}

4. Query by Language

With the language configuration in place, you can learn how to Query your documents by metadata: lang and how to retrieve the alternate_languages from the metadata.

Full example project

Multi-languageMulti-language website example

Want to see a full, working project in action? Here you'll find an example multi-language website using Gatsby.js and Prismic.