Multilingual Imports (3.x)

Running into two issues when running a bulk import from (many) xlsx files (on the command line using Maatwebsite Excel) . I'm porting over a tonne of content from two (very shaky) WordPress websites built by a third party which were essentially duplicates running alongside each other, one in DE and one in EN (not a great architecture). The goal is to combine the two into a consolidated site on Twill. There are thousands of different posts of various types coming over so manually adding them would obviously be a very bad option). I have one stack of import files for, (eg) blog posts from the english site and one stack from the German site. These aren't translations of each other (although some are to add some extra complexity). Both are then to be imported to Twill into one module, some with DE as the primary language, some with EN as the primary language. I am also trying to preserve the original slugs so they are being populated too, and a custom block is being populated and added for good measure πŸ™‚ The first screenshot is the rough and ready generic class I'm using to manage the imports across a bunch of different modules. This works perfectly when used on the EN posts (the state of the class in the screenshot is where I'm trying to import the DE correctly). The posts and slugs populate and the DE version is inactive when imported, which is what I want (screenshot 2). The problem is, when I import the DE only content the empty EN version is always live too. And the UI looks like the third screenshot (blank titles). I've tried many combinations of active/disabled but ultimately end up with the same result. Issue 1 (most pressing) is that EN is always live and issue 2 is the UI not showing a title for the DE only posts (which makes sense as the title is a translated field but is something I need to work around) We're at the point in a massive project where I am very likely to be making basic mistakes that hopefully fresh eyes might spot πŸ™‚
No description
No description
No description
6 Replies
dan__devine
dan__devineOPβ€’8mo ago
to clarify - this is obviously not intended Twill functionality or a bug, just a use case where I've run into problems - apologies if this is in the wrong place.
ifox
ifoxβ€’8mo ago
ha, been there! Hi @dan__devine for the empty title you can use an accessor to implement a fallback in English for DE only records for the English always being active, that's interesting. From the UI, are you able to create a DE only record?
dan__devine
dan__devineOPβ€’8mo ago
Hi @ifox - ha, yes of course that makes perfect sense, thank you. When created in the UI the DE posts behave correctly, its just when imported. I'm currently picking through handleTranslations to see why this would be but haven't spotted any reason so far. Might need to look at HandleSlugs next.
ifox
ifoxβ€’8mo ago
which version of Twill are you on? Check the network request payload when you create a DE only record. If you pass the same structure to the repository, it should do the same thing. but create and update calls may have different behaviors, so it might be that you'd need a create followed by an update call to make it work. Or you could directly use the model or DB, tbh, as I'm assuming you won't need to run this anymore after the launch of the Twill based sites.
dan__devine
dan__devineOPβ€’8mo ago
I'm on 3.2.1, and I'm very much hoping not to have to do this again although someone has mentioned that a third Japanese site may exist 😨 . Will move to the direct approach if I can't figure this out, but I'm hopeful that if I can clear this hurdle I might be able to make a Twill specific wrapper for the Maatwebsite package to help others (and myself) in the future as more people migrating from multilingual CMS seems likely. Following create() with update() made it all work, thank you so much for the help and nudge in the right direction @ifox
ifox
ifoxβ€’8mo ago
awesome!
Want results from more Discord servers?
Add your server