Hi,
I want to be able to get the supported locales on the site that my plugin is installed on.
I had a look around in the CTX and Client but I couldnāt find the right thing, I assumed it would be:
const client = buildClient({
apiToken,
});
client.site.locales
As I know for my website I can run this query:
const localesQuery = `query {
_site {
locales # -> ["en", "it", "fr"]
}
}`
Essentially I am looking for the equivalent of this call (that I can do on my website that uses Dato) within the plugin I am writing:
let supportedLanguages:string[] = [];
export const getSupportedLocales = (): string[] => {
if (supportedLanguages.length === 0) {
fetchDataDato<QueryResult>(localesQuery).then((root: QueryResult) => {
supportedLanguages = root.data._site.locales;
});
}
return supportedLanguages;
};
Would I just have to run a real GQL query? using the apiToken?