Is possible to get all available locales which was setup in the builder space configuration?

Hello Team!

I have a question about locales in the Builder.io. Please tell me is possible to get list of available locales which was setup in the Builder.io space configuration?

I have a case, where I need have to list of available locales to use them in the data model.
I have a data model which names: surveyConfiguration with fields:

  • surveyType - which is reference to another dataModel which names surveyType, (surveyName and surveyCode fields),
  • availableForLocales - this fields should be a list with available locales, which the content editor can choose.

There is one way how to resolve this issue - creating a new data model with list of locales,
but this is content duplication and I would like to use the list that is defined in the configuration.

Do you have an idea how to obtain a list of locales so that the content editor can select the locales for which the survey is to be available?

Hello @wojciech.kusmierczyk,

To get all the available locales, you can use our Admin API. By querying space settings with the admin API, you can find customTargetingAttributes which contains all the available locales.

Ok, so without writing own plugin it will not be possible to use such a list in the data model?

Hello @wojciech.kusmierczyk,

Yes, there isn’t a direct way of doing so, therefore, either you will be required to create your own plugin or create a simple script that would use admin API to query all the available locales from customTargetingAttributes and then use write API to create a list type field with those data values for the respective model.