Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Endpoint to get all languages

default discord avatar
rawnanoob2 years ago
4

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



No endpoint?

  • default discord avatar
    richadr2 years 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
    2 years 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
    rawnanoob2 years ago

    The actual available locales on my config

  • default discord avatar
    richadr2 years 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,
        },
      ],
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.