Closed (fixed)
Project:
Node import
Version:
6.x-1.0-rc4
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 Jun 2008 at 15:47 UTC
Updated:
2 Jan 2014 at 23:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Robin Millette commentedFirst patch was empty, sorry.
Move the uncompressed file (upload didn't like the ".inc" extension, so I gzipped it) to node_import/supported/i18n.inc and you should now see a "I18N: Language code" field taking "en", "fr" and other supported language codes.
Comment #2
samireez commentedI've tried the patch with 5.x-1.2 and 5.x-1.6 of node_import, but did not get the "I18N: Language code" field shown in any of the steps of the import process. Any ideas what might be missing, or what version would you recommend this with?
Comment #3
Ozeuss commentedI added a few stuff:
Comment #4
asak commentedCode in comment #3 works like a charm - thank you!
Comment #5
shushu commentedWanting to make this patch work for Drupal 6 I had to "get dirty" and fix the patch.
I wanted it to be even stronger, to have the ability to set the tnid, so the translation will really work.
My hack for now (I hope to get some ideas and think more about it myself) is to get the tnid from the CSV and use hook_node_import_postprocess to set it properly.
It seems to work, but I hope to make it smarter...
Comments are welcome,
Shushu
Comment #6
shushu commentedAttached a separated module i18nnodeimport, which adds the language/translation into node import.
Comment #7
kensae commentedNice patch !
However would it be possible to set a temporary tnid in the csv file, and update it when the nodes are being saved?
So you don't have to know the actual nid when you are importing content.
Maybe I should make it more clear with an example :
in a csv-file i have
language;tnid;title;body
EN;1;Some title;Some text
NL;1;Some title;Some text
But the in the table 'nodes' I already have 10 nodes (5 original nodes with translation), so tnid '1' is already in use. So in this case, when importing the nodes, the tnid '1' should be replaced by the actual tnid '11' (assuming the nid of the first row would be '11').
I'm not that much of a php-guru myself, so I don't know if it's easy to implement such a solution.
Comment #8
AmrEllafy commentedin which step you get this ? I can't find it after uploading the patch D6
Comment #9
feuillet commentedQue0x, its in Step: 4 of 8, where you can define the Language for the imported items and the column for the corresponding nid, as far as i understand it right.
shushu, do you have a solution for the case mentioned by kinsai, if the nid of the original source is not defined?
Best Regards
Sandro
Comment #10
hepabolu commentedNot sure if this is an acceptable solution, but I've modified the i18nnodeimport.module here to handle this situation as follows:
the import CVS file has lines like:
language;TNID-IMPORT;text;
EN;0;some English text;
NL;-1;Dutch text goes here;
FR;-2;French text goes here;
the code then calculates the tnid as follows:
if TNID-IMPORT = 0 then node->tnid = node->nid
if TNID-IMPORT < 0 then node->tnid = node->nid + TNID-IMPORT
if TNID-IMPORT > 0 then node->tnid = TNID-IMPORT (so you can set it to a specific node)
The caveat here is that it assumes nodes are created in order with no node creation in between due to another process. It would be nice to have a more robust mechanism, but that's beyond my Drupal skills.
Comment #11
catchI needed this for Drupal 5, so converted #3 into a proper patch file.
Comment #12
AlessMascherpa commentedHello,
I think that the right way to do this is by:
And not all nodes with their translations at the same time. This way the module can be used in a more general way.
I´m using the module posted by shushu in comment #6 with a little change inspired by the previous post #10 by hepabolu, because I was experimenting problems with the language switcher:
Now is working fine for me. Thank you all for this work and for sharing it.
Comment #13
mvcI needed a slightly different version of this than some other posters on this issue: I wanted to preserve the node language field for a content type which is not translatable, and I wanted users to be able to specify language by ISO code, name in English, native name, or name in the current language (for example, "de", "German", "Deutsch", "alemán", or "allemand"). I also preferred to use only the core locale module.
Ultimately it would be nice to import translations of a node as part of a translation workflow, which I think would best be done by allowing the module to update existing nodes (cf. #422282: Update existing nodes on import) because of course there can be only one translation into a given language for a given node, but that's well beyond the needs of my current site so I can't contribute to that effort right now. However, I hope someone finds this patch helpful.
Comment #14
EmanueleQuinto commentedIndeed I found the above patch very useful so I backported to rc4.
Although the #13 patch works even for rc4 it has some small hitches:
Solved with the attached patch.
Comment #15
arpieb commented+1 vote for the #13 suggestion. Along the lines of the update concept and dealing with nid/tnid unknowns, it'd be nice to specify a key field to use for the translation import so you don't have to know the nid or tnid for the original node.
For instance, be able to specify a node by SKU for an Ubercart product translation import as suggested in #422282: Update existing nodes on import for update imports. Doing the same thing to reference a node to be translated would be key for non-technical staff who might be trying to import data...
Comment #16
mvcEmanueleQuinto, arpieb: I'm glad this patch worked for you. Would you consider marking this RTBC?
As for dealing with importing a set of translations, I think it makes sense to wait until node_import supports updating existing nodes. Also, keep in mind that in D7 translations will not be separate nodes, thanks to getting fields in core, so those will become entirely separate issues.
Comment #17
EmanueleQuinto commentedNo issues so far with the patch. I tested in various site and it works. So +1 to RTBC
Comment #18
cyberwolf commentedSubscribing.
Comment #19
mvcI know I'm not supposed to mark my own patch RTBC but it seems EmanueleQuinto considers it ready so I'm going to flag it.
Comment #20
cyberwolf commentedOne remark I have so far regarding the patch: the language chosen from the drop down does not seem to be remembered when switching between the different steps in the wizard with the "Previous" and "Next" buttons.
Comment #21
dandaman commentedI agree that the patch in #13 it is RTBC. #20 may have a good point, but I'm not sure if other portions of Node Import do that very well either, in my experience.
Comment #22
Andrew Gorokhovets commentedsubscribe
Comment #23
enkara commentedsubscribe
Comment #24
bartezz commentedTried patch in #14 and it works like a charm against rc-4.
Thanx for sharing!
The remark in #13 to be able to import nodes as a translations sounds brilliant. I have a store with over a 1000 products and can import the products in the default language but then have to add translations (in 8 languages) by hand.... what a b&%#h!
Also thought of creating a custom module to link imported nodes as eachother's translations based on a cck field like SKU in uc_product for instance. But importing translations as mention in #13 might be a way cleaner method.
Is there a feature request for this already?!
Cheers
Comment #25
zahidansari commentedHi can anyone tell me how to apply this patch #14??
Comment #26
zahidansari commentedpatch #14 giving error
patching file node.inc
Hunk #1 FAILED at 158.
Hunk #2 FAILED at 199.
Hunk #3 FAILED at 209.
Hunk #4 FAILED at 293.
4 out of 4 hunks FAILED -- saving rejects to file node.inc.rej
Comment #27
Robrecht Jacques commentedCommitted patch of #13 with following changes:
Fixed in 6.x-1.x-dev. Will be included in 6.x-1.1 release. Thanks mvc!