Locales
This article provides an introduction to Prismic languages and locales.
Prismic supports localization, allowing you to set localized versions of each document.
A locale represents a language and a region. Each locale has a five-character locale code, formatted la-re
, where la
stands for a language and re
stands for a region.
You can use locales for:
- translating content (
en-ca
andfr-ca
for English and French Canadian content) - localizing content (
en-gb
anden-us
for British and American content) - both translating and localizing (
en-us
andes-mx
for English US and Spanish Mexican content). If you don’t find your desired locale, you can create your own custom locales, as described below.
Add a language
Here, you will learn how to set the master locale and add more locales to your Prismic repository.
Set the main locale
The master locale is the default locale of your repository.
To change the master locale, perform the following steps:
- In your repository, navigate to Settings > Translations & locales. You will find the list of locales available in your repo.
- Click on the ‘Set as master’ button.
The selected locale will now be the default locale of the repo and will be the first in the languages array in the API CDN response at https://your-repo-name.cdn.prismic.io/api/v2,
which includes an is_master
boolean:
"languages": [
{
"id": "en-us",
"name": "English - United States",
"is_master": true
},
{
"id": "ar-bh",
"name": "Arabic - Bahrain",
"is_master": false
},
{
"id": "ja-jp",
"name": "Japanese",
"is_master": false
}
],
Add more locales
To add a locale, perform the following steps:
- In your repository, navigate to Settings > Translations & locales. You will find the master locale along with the option to Select an existing locale from the list or create your own.
- Click on the dropdown icon. It will show a list of available languages. Select the required locale from the list. The selected locale code will appear.
The new locale will be available in the language dropdown of the document list and inside each document.
If you translate a document to the French locale, for example, fr-fr
will be available in the "alternate_languages"
property of the API response.
"alternate_languages" : [
{
"id": "XTb4mBAAACQAOfrg",
"type": "homepage",
"lang": "fr-fr"
}
Add custom locales
To create a locale that isn’t available in the list of options, follow these steps:
- Go to your repository and navigate to Settings > Translations & locales; click on Select an existing locale from the list or create your own. Then, Scroll down to the bottom of the existing locales and click on + Create a custom locale. It will open an overlay.
- Type a language in the Language and Region. _This will automatically generate a two-character _locale code.