Skip to content

ttag-org/gatsby-starter-ttag

Repository files navigation

Gatsby Starter with ttag for Internationalization

This is just a bare-bones demo gatsby starter with the minimum required to demonstrate using ttag for precompiled internationalization with gatsby.

Scripts

Developing or building in either English or Spanish is accomplished by passing the environment variable LOCALE to the respective gatsby commands. These are added as scripts in the packages.json for convenience:

{
  "scripts": {
    "build:en": "LOCALE=en gatsby build",
    "develop:en": "LOCALE=en gatsby develop",
    "build:es": "LOCALE=es gatsby build",
    "develop:es": "LOCALE=es gatsby develop"
  }
}

Babel Config

Precompiling is then handeled by the babel-plugin-ttag babel plugin, using process.env.LOCALE to pass build-time information to the babel configuration. The babel.config.js is shown here:

module.exports = {
  "presets": [
    [
      "babel-preset-gatsby",
    ],
  ],
  "plugins": [
    [
      "babel-plugin-ttag",
      {
        "resolve": {
          "translations": process.env.LOCALE === "es" ? "es.po" : "default",
        },
      },
    ],
  ],
}

About

Gatsby Starter with ttag for internationalization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published