Retrieve full language name

How to retrieve the entire name / label of the language?

I can’t get much further than retrieving the ISO locale codes.
It would be nice if there was a way to get the labels, just like we have in the datoCMS interface.

How to do this please?

Hello @ZeroEqualsZero , the APIs can only return the ISO locale codes, and there are no calls that return the full locale name. The best solution would probably to just sketch up a simple dictionary inside your project to map the ISO locales into the name you desire, so something like

  en: "English",
  it: "Italian",
  pt: "Portuguese"

Thank you, yet I am unsure how to implement this.
I am unsure how to map the ISO local to the suggestion you made.

Is there any particular reason why the full name is not returned? It feels a bit off to me?

Thank you

@ZeroEqualsZero it depends on the language you are using, as an example, to implement this on JavaScript you can use a simple object to do so:

const receivedLocale = "it";

const mapISOtoName = {
  en: "English",
  it: "Italian",
  pt: "Portuguese"

console.log(mapISOtoName[receivedLocale]); //will log the string "Italian"

Or, for a more strict approach, you can use an actual JS map to do the same: Map - JavaScript | MDN

As for why we don’t return the full name, is to follow the ISO standard, that is widely used for most applications that work around locale (like NextJS, Gatsby, Astro…). You can read more about it and see the equivalences here: ISO 639-2 Language Code List - Codes for the representation of names of languages (Library of Congress)