strapi-plugin-i18n
Version:
This plugin enables to create, to read and to update content in different languages, both from the Admin Panel and from the API
15 lines (10 loc) • 409 B
JavaScript
import getLocaleFromQuery from './getLocaleFromQuery';
const getInitialLocale = (query, locales = []) => {
const localeFromQuery = getLocaleFromQuery(query);
if (localeFromQuery) {
return locales.find(locale => locale.code === localeFromQuery);
}
// Returns the default locale when nothing is in the query
return locales.find(locale => locale.isDefault);
};
export default getInitialLocale;