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.
How to add a language
Open your language settings
Navigate to your Prismic repository and go to Settings > Translations & Locales.
You must be the repository owner or have admin rights to access the Translations & Locales page.
Add a locale
In the Add new locales to this repository section, select a locale from the dropdown.
If your locale is not in the list, add a custom locale by selecting Add custom locale in the dropdown.
Click Add locale after selecting a locale.
How to set the main language
Open your language settings
Navigate to your Prismic repository and go to Settings > Translations & Locales.
You must be the repository owner or have admin rights to access the Translations & Locales page.
Select a master locale
In the Manage your locales section, click the Set as master button for your new master locale.
Your selected locale will be the new default locale in the Page Builder and the Document API.
How to delete a language
Delete all documents in the locale
All documents in a locale must be deleted before deleting the locale.
Open your language settings
Navigate to your Prismic repository and go to Settings > Translations & Locales.
You must be the repository owner or have admin rights to access the Translations & Locales page.
Delete a locale
In the Manage your locales section, click the trash can button for the locale to be deleted.
Locales in the API
The Document API provides a document’s locale in its lang
property:
{
"id": "YCiUyRUAACQAxfZK",
"uid": "my-first-post",
"url": "/blog/my-first-post",
"type": "blog_post",
"href": "https://example-prismic-repo.cdn.prismic.io/api/v2/...",
"tags": ["Tag 1", "Tag 2"],
"first_publication_date": "2021-02-14T03:22:26+0000",
"last_publication_date": "2022-07-09T00:36:18+0000",
"slugs": ["my-first-post"],
"linked_documents": [],
"lang": "fr-fr",
"alternate_languages": [],
"data": {
// ...
}
}
A document’s translated versions are listed in the document’s alternate_languages
property.
{
"id": "YCiUyRUAACQAxfZK",
"uid": "my-first-post",
// ...
"alternate_languages": [
{
"id": "XTb4mBAAACQAOfrg",
"type": "homepage",
"lang": "fr-fr"
}
],
"data": {
// ...
}
}