0

I'm using the latest Strapi version (4.5.2) and have two locales configured:

https://my-api-url.com/api/i18n/locales ->
    
0   
    id          2
    name        "German (de)"
    code        "de"
    createdAt   "2022-11-23T17:15:52.629Z"
    updatedAt   "2022-11-23T19:58:50.165Z"
    isDefault   false
1   
    id          1
    name        "English (en)"
    code        "en"
    createdAt   "2022-11-22T14:31:35.679Z"
    updatedAt   "2022-11-23T19:59:05.421Z"
    isDefault   true

When I query my Strapi API without specifying a locale parameter, it should return the content in the default language (here, as shown above, "English"), but it doesn't:

https://my-api-url.com/api/mycollection ->

data    []
meta    
pagination  
page    1
pageSize    25
pageCount   0
total   0

Querying with locale set to "German", I get the expected contents:

https://razor-server-tim.herokuapp.com/api/themes?locale=de ->

data    
    0   
        id  2
        attributes  
            Title   "Das ist mein Titel"
            Summary "Das ist die Zusammenfassung"
            SomeOtherField "Deutsche Übersetzung"
            createdAt   "2022-11-23T19:41:11.527Z"
            updatedAt   "2022-11-23T19:41:21.162Z"
            publishedAt "2022-11-23T19:41:21.156Z"
            ImageUrl    "https://res.cloudinary.com/hnraymasy/image/upload/v1669146049/car_vxhq7h.png"
            locale  "de"
meta    
    pagination  
        page    1
        pageSize    25
        pageCount   1
        total   1

Querying the API with locale=all results in only the German translations being returned.

(From the docs: "Use all as a value for the locale code, as in http://localhost:1337/api/restaurants?locale=all, to fetch entries for all locales that have been configured in the admin panel.)

In the Global Settings, the i18n plugin is configured as shown:

Strapi i18n Global Settings

The collection type page shows that both locales have content available:

Strapi collection type locales

The entry itself also shows that English content is available:

Strapi item with locales

Why does the API not return my English content?

1 Answer 1

1

Well, the time was late... Turns out that I mixed up the locally and remotely deployed versions and edited the unpublished draft for the English locale.

(-‸ლ)

So make sure that you actually publish the version that you're requesting via the API!

Publish, save, draft version

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.