- π³π±Netherlands megachriz
Tagging issue with "multilanguage", so I can find this issue back as soon as I plan to focus on Feeds multilingual issues again.
- First commit to issue fork.
- π¨π¦Canada nikathone Ontario
I tried to reproduce the issue following the steps in the description but I couldn't. I ended up with two basic page content with two different languages. The two content are not connected as in being the same content with two different translation.
- Status changed to Needs review
5 months ago 8:35am 25 June 2024 - last update
5 months ago Patch Failed to Apply - π΅πΉPortugal tmiguelv
Hello!
I was having the same problem as #9 and I did a little patch for importing content in the existing translations that worked for my site.
I needed to make the feeds_item field translatable.
For the translations to work, you need to:- Copy the steps from the description
- Allow translations in the feed settings
- Add a mapping field for an unique target (it can be ID, title, or something that will be used to relate both translations)
- Enable translation for feeds_item field in the Content Type Settings
Please feel free to review it and upgrade it
- last update
5 months ago Patch Failed to Apply - π΅πΉPortugal tmiguelv
Added a validation to check if the language exists
- π«π·France Julien Tekrane
julien tekrane β made their first commit to this issueβs fork.
- Status changed to Needs work
2 months ago 12:04pm 17 September 2024 - π³π±Netherlands megachriz
@julien tekrane
Thanks for putting the code from the patch in a merge request.Unfortunately, this cannot be merged as is because:
- It is failing current tests.
- It fails coding standards, spelling and PHPStan.
- There is no test coverage for the bug it is trying to solve.
I think that adding an automated test that demonstrates the bug is the most important one to do first.
- Status changed to Needs review
2 months ago 8:53am 18 September 2024 - π«π·France Julien Tekrane
Dear @megachriz,
As maintainer can you please take a look into my Tests ?
- π³π±Netherlands megachriz
@julien tekrane
Thanks for your work! I gave some initial feedback on the tests alone, I hope to find time to execute your test as well to check if it can demonstrate the issue. - π³π±Netherlands megachriz
Review new test TranslationMultilineTest::testTranslationMultiline()
Without the code applied, I've tried to run an import manually by looking what the test is trying to do:
- Create a feed type, set to only create items, do not update existing.
- Map to guid, title, langcode. Set "guid" as unique.
- Import the following CSV:
"guid","title","langcode" 1,"HELLO WORLD",en 1,"HOLA MUNDO",es
And I see that the first item gets imported and the second item gets ignored.
More tests needed
It's a good thing to test, so we should definitely keep that one. But there should also be a test that results into the error message "A translation already exists for the specified language". It looks like this can happen when you try to update an existing translation. So I think that there should be a test where a node already exists in two languages. And then try to update the translation.
There is also an interesting issue in the following situation:
- A node exists in two languages (English and Spanish), but the Spanish version is set as original language. Assume that ID of the node is 1.
- Create a feed type to update existing nodes.
- Map to nid, title, langcode. Set "nid" as unique.
- Import the following CSV:
"nid","title","langcode" 1,"HELLO WORLD",en
You now get the message "The translation language cannot be changed (en).".
Might be useful to add a test for too.
Solution review
I only briefly glanced through the solution code and I wonder if importing translations should be optional. Shouldn't Feeds by default check for mapping to language? Or would there be a use case where you want Feeds to ignore translations, even when mapping to language?
In the solution I also see that there's overlap with the patch provided in π Setting a target for "langcode" field will sometimes throw "this field cannot hold more than 1 values" Needs work . So perhaps these two issues should be combined into one. The scope would become bigger in this case, but I'm not sure if it's possible to fix issues related to the langcode target in smaller steps.My approach would be to first add all the test cases, see if they demonstrate the issues that we face. And then work further on polishing the solution.