Reputation: 1929
I've gone through the docs, but cannot find an API-endpoint where all the available locales is available. I.e. the locales that is setup under Internationalization.
I can get all translations for a specific content type with
baseAddress/{content-type}?_locale=all
But I would like to get a response with all available locales from the API. Is there a way?
Upvotes: 3
Views: 3419
Reputation: 3
A GET request on the url base_URL/api/i18n/locales
fetches the json of defined locales.
Works for strapi v4.15.4
Upvotes: 0
Reputation: 101
You can use baseAddress/i18n/locales
to get a JSON of all defined locales.
Tested on Strapi 3.6.8
Upvotes: 3
Reputation: 4506
You can expose an API and then return the values from the internationalization plugin service.
async function getLocales(){
const locales = await strapi.plugins.i18n.services.locales.find();
return locales;
}
Upvotes: 4