Get localised values through REST API

Hi all,

I’m new to Cockpit and the question might be simply to solve for you, but I didn’t manage to be sucessful so far.

I’ve installed Cockpit v2.13.4 with sqlite DB.
Our use case is quite simple, we just need some collections with a few localized fields.
So I’ve create a collection with two fields, one of them localised and I’ve created three locales (de, de_CH, en).

I’m trying to query the items via GET /api/content/items/{model} in the playground which is working with the response:

[
  {
    "code": "1",
    "Text": "Default Text",
    "_modified": 1769696542,
    "_mby": "697b241ff57d03bab5a732c5",
    "_created": 1769679183,
    "_state": 1,
    "_cby": "697b241ff57d03bab5a732c5",
    "_id": "697b294ff57d03d8076da169"
  }
]

When I’m doing the same with GET /api/content/items/{model}?locale=en or any other locale, the response is the same and doesn’t contain the localised value even though I’ve entered localised values for all three configured locales.

What am I doing wrong? Please adivse.

Sorry if I’m just stupid or broke any rules.

Thanks in advance!

Hello,

If it keeps returning the default text, there’s two possibilities that comes to mind.

  1. Maybe : You call the API with locale=en is it the right code you created ? If ever you created a localization with en_GB you have to make to API code with en_GB.
  2. Or maybe : You simply did not created the translated version of your “Text” input. Make sure to follow the documentation guide about Localization.

I never use localization, but I tried out of curiosity and it did works.

Thanks for the response.

I’ve created the localisations with the correct code:

And the field is configured as translateable, according to the documentation.

I can also see the translated “Text_en” field in the content.sqlite.

So everything looks correct, it just doesn’t work…