Endpoint to get all languages

default discord avatar
rawnanoob
4 months ago
6

Hi is there a endpoint to get all the languages (locales) configured?



No endpoint?

  • default discord avatar
    richadr
    3 months ago

    I am not sure, but you could always create a custom endpoint, read it from the config, and return it in the response

  • discord user avatar
    jmikrut
    Payload Team
    3 months ago

    you mean all locales of a specific doc?



    or do you mean just to fetch the actual available locales on your config?

  • default discord avatar
    rawnanoob
    3 months ago

    The actual available locales on my config

  • default discord avatar
    richadr
    3 months ago
      endpoints: [
        {
          path: '/api/locales',
          method: 'get',
          handler: (req, res) => {
            const { config } = req.payload;
            const locales = config.localization ? config.localization.locales : [];
            return res.json(locales);
          },
          root: true,
        },
      ],
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.