Skip to main content

Locale settings

Project-level locale configuration lives in the /src/config-locales.js file. It is here that you can define your default locale, all of your supported locales, and various other locale-specific information you might need. While this config will be used for general localization setup, it will also be conveniently exposed to your components and pages via the useLocale React hook.

By default, corgi sets you up with "en" as your default locale, and "en", "es", and "fr" as your supported locales.

Edit this data per your project's needs. Ensure that the strings entered correspond with what you want your URLs to look like.

The following sections outline the most commonly-edited settings in the locale config.

defaultLocale

The default locale string for your project. Your default locale's homepage will live at the root of the site /, while its subpages will live at /<default locale>/<subpage-name>

module.exports = {
defaultLocale: "en",

// other properties omitted for brevity
};

localeMap

The localeMap is where you'll enter all of the supported locales for your project. This object contains a map of locale strings to various bits of relevant data you might need. For example, if your locale is "en", but you want your HTML's lang attribute to be "en-US", you could put that data here. language is the only required field here. All of this mapped data is conveniently available via the useLocale hook.

All pages of the project in these locales (with the exception of the defaultLocale, see above) will live at /<locale string>/<page name>.

module.exports = {
localeMap: {
en: {
language: "en-US",
someAPIEndpointLocale: "en_US",
},
es: {
language: "es-ES",
someAPIEndpointLocale: "es_ES",
},
fr: {
language: "fr-FR",
someAPIEndpointLocale: "fr_FR",
},
},

// other properties omitted for brevity
};