Closed vntw closed 4 months ago
I'm also facing this exact issue. It does seem to be a problem with the plugin.
Hi! I am having the same problem. I've been having this for some time and ignoring, but now that is time to deliver the project, while bug hunting I found this thread.
This is the schema:
export default defineType({
name: "pages",
type: "document",
title: "Pages",
fields: [
defineField({
name: "title",
type: "internationalizedArrayString",
title: "Title",
}),
defineField({
name: "slug",
type: "slug",
title: "Slug",
description: "This is used to generate the URL for this category",
validation: (Rule) => Rule.required(),
options: {
source: "name",
maxLength: 44,
},
}),
],
preview: {
select: {
title: "title",
},
prepare(selection) {
const { title } = selection;
return {
...selection,
title: title[1].value || "Untitled",
};
},
},
});
And this is my config:
internationalizedArray({
languages: [
{ id: "el", title: "Greek" },
{ id: "en", title: "English" },
],
defaultLanguages: ["en"],
fieldTypes: ["string"],
}), ```
I tried adding a _key to the schema fields but it was not recognized. Perhaps I was doing it wrong but I couldn't find a way to add it manually.
Any help would be appreciated
any one found the solution for this?
Issue is still present to this day
any one found the solution for this?
Could this be somehow related to having two language-files in the setup, e.g. languages.js and languages.json?
edit; unfortunately not the solution; issue still present this day
Didn't find a solution. I just ended up removing the defaultLanguages
from the config and moved on with the project in other ways.
Didn't find a solution. I just ended up removing the
defaultLanguages
from the config and moved on with the project in other ways.
Yes, seems to be the only option left on the table. Thanks for letting us know.
Hey there,
thanks for the plugin, it worked nicely while not using the
defaultLanguages
config option. 😅Issues
When using it, I encountered some problems:
Issue 1 - Duplicate keys
Creating a new document via the UI and with the option configured, this is the result for all translated fields:![image](https://github.com/sanity-io/sanity-plugin-internationalized-array/assets/502368/683ce160-757c-4207-8317-be300e8ed12a)
Looking at the data (
*[_type == "project"] { translatedString1, translatedString2, translatedStringText }
- same for every field):When creating a document, there are two POST requests
containing sth. like the snippet below, so makes sense that keys are duplicated (I also observed the same field being patched twice in the same request, e.g.
translatedString2[-1]
):I can generate unique keys and fix the "deduped" key to be of a valid language via the UI, but… for now I'll go without the config option and having to click the languages every time
Issue 2 - Document deletion not possible
Deleting a document in this state is not possible, the delete request gets aborted and a POST request with
createIfNotExists
for every translated field follows. Removing thedefaultLanguages
option will delete it successfully. I know there were issues before that covered this, but it's still happening for me (in this state)Reproduction
I created a reproduction repo based on this template with a few added fields in the
project
document where this behaviour should be observable (it is for me every time, using Firefox). You should only have to enter valid API credentials.Using the latest version of the plugin (1.10.3). If you have any further questions, let me know!
Thanks for your input!