Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation for Single Types are not saved. #19901

Open
Ada-Bardho opened this issue Mar 22, 2024 · 15 comments
Open

Translation for Single Types are not saved. #19901

Ada-Bardho opened this issue Mar 22, 2024 · 15 comments
Assignees
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: plugin:i18n Source is plugin/i18n package status: confirmed Confirmed by a Strapi Team member or multiple community members version: 4 Issue related to v4

Comments

@Ada-Bardho
Copy link

Ada-Bardho commented Mar 22, 2024

Bug report

Required System information

Strapi version: 4.21.0
Strapi plugin-i18n: 4.21.0

Describe the bug

When we creating a simple single type (with internationalization enabled) with simple text field (also with enabled localization for this field) and save it - it is saved for default locale only. When we switch to another locale and save it - it is not saved, as after page reload we cannot see the saved value.

  1. Request made to save not default locale, looks like 200
    curl 'http://localhost:1337/content-manager/single-types/api::test-single-type-page.test-single-type-page/?locale=de'
    -X 'PUT'
    -H 'Accept: application/json'
    -H 'Accept-Language: uk-UA,uk;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6,sq;q=0.5'
    -H 'Authorization: Bearer {secret}'
    -H 'Cache-Control: no-cache'
    -H 'Connection: keep-alive'
    -H 'Content-Type: application/json'
    -H 'Origin: http://localhost:1337'
    -H 'Pragma: no-cache'
    -H 'Referer: http://localhost:1337/admin/content-manager/single-types/api::test-single-type-page.test-single-type-page?plugins[i18n][locale]=de'
    -H 'Sec-Fetch-Dest: empty'
    -H 'Sec-Fetch-Mode: cors'
    -H 'Sec-Fetch-Site: same-origin'
    -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
    -H 'sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"'
    -H 'sec-ch-ua-mobile: ?0'
    -H 'sec-ch-ua-platform: "macOS"'
    --data-raw '{"localizations":[13,12,11,10,9,8,7,6,5,4,3,2,1],"Title":"qwe"}'
    --compressed
  2. After reloading - it tries to get the data for the selected locale and have 404 status with NotFoundError
    curl 'http://localhost:1337/content-manager/single-types/api::test-single-type-page.test-single-type-page/?locale=de'
    -H 'Accept: application/json'
    -H 'Accept-Language: uk-UA,uk;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6,sq;q=0.5'
    -H 'Authorization: Bearer {secret}'
    -H 'Cache-Control: no-cache'
    -H 'Connection: keep-alive'
    -H 'Pragma: no-cache'
    -H 'Referer: http://localhost:1337/admin/content-manager/single-types/api::test-single-type-page.test-single-type-page?plugins[i18n][locale]=de'
    -H 'Sec-Fetch-Dest: empty'
    -H 'Sec-Fetch-Mode: cors'
    -H 'Sec-Fetch-Site: same-origin'
    -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
    -H 'sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"'
    -H 'sec-ch-ua-mobile: ?0'
    -H 'sec-ch-ua-platform: "macOS"'
    --compressed
    P.S. Single Type schema:
    {
    "kind": "singleType",
    "collectionName": "test_single_type_pages",
    "info": {
    "singularName": "test-single-type-page",
    "pluralName": "test-single-type-pages",
    "displayName": "TestSingleTypePage",
    "description": ""
    },
    "options": {
    "draftAndPublish": true
    },
    "pluginOptions": {
    "i18n": {
    "localized": true
    }
    },
    "attributes": {
    "Title": {
    "pluginOptions": {
    "i18n": {
    "localized": true
    }
    },
    "type": "string"
    }
    }
    }

Steps to reproduce the behavior

  1. Go to a Strapi instance and create a simple single type (with internationalization enabled) with simple text field.
    image

  2. Click on the other language to translate, german for us add data and try to save. For the first time it saves but when I add text again and try to save I get this error:

image

  1. See error in console:
    image

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Code snippets

If applicable, add code samples to help explain your problem.

Additional context

Add any other context about the problem here.

@raudinm
Copy link

raudinm commented Mar 23, 2024

I've been facing the same issue.

@thomsa
Copy link

thomsa commented Mar 24, 2024

Same here.

As I am saving any other local than the default, it constantly just overrides the default and does not save the other locale.

When trying to publish the secondary local, the admin says "Not Found".

I'll add my suspicion here:

Saving a Localization creates a new row:

image

I suppose something goes havoc here:

image

EDIT:

Found the issue, just looking for one more minute...

SELECT * FROM public.your_entity;

For some reason the locale info is not saved correctly, everything defaults.

image

Change the local here to your locale and it'll work.

@Ada-Bardho
Copy link
Author

@Eventyret I have edit the post

@Eventyret Eventyret added issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around status: pending reproduction Waiting for free time to reproduce the issue, or more information source: plugin:i18n Source is plugin/i18n package version: 4 Issue related to v4 labels Mar 25, 2024
@Eventyret Eventyret self-assigned this Mar 25, 2024
@Eventyret Eventyret added status: confirmed Confirmed by a Strapi Team member or multiple community members and removed status: pending reproduction Waiting for free time to reproduce the issue, or more information labels Mar 25, 2024
@antoine-bielawski
Copy link

I've tested multiple versions, Strapi 4.20.2 is the last one without this issue. The bug was probably introduced by this commit.

@Driez

This comment was marked as spam.

@leoboyerbx

This comment was marked as spam.

@Ada-Bardho

This comment was marked as spam.

@Th1nhNg0

This comment was marked as spam.

@nevosol

This comment was marked as spam.

@nevosol
Copy link

nevosol commented Apr 4, 2024

Can confirm that issue is fixed in yesterday's release https://github.com/strapi/strapi/releases/tag/v4.22.0

@Ada-Bardho

This comment was marked as spam.

@leoboyerbx

This comment was marked as spam.

@jangir-ritik

This comment was marked as spam.

@Ada-Bardho

This comment was marked as spam.

@khelil
Copy link

khelil commented May 17, 2024

FYI still having the issue on 4.24 but only when strapi is runned on dev mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: plugin:i18n Source is plugin/i18n package status: confirmed Confirmed by a Strapi Team member or multiple community members version: 4 Issue related to v4
Projects
Status: To be reviewed (Open)
Status: Reproducible on v4
Development

No branches or pull requests