Node Translations - Losing your translated page URL's
Recently, I used XLIFF Tools to import a bunch of translated nodes. It went through perfectly, with the URL's being updated from the source language; mine being English. Only problem is, every language, apart from the one I was importing - lost all their URL aliases. I fixed it though.
With a bit of MySQL magic, I fixed all my URL's with the SQL I constructed below. Please note this was only tested on Drupal 6 with pathauto and i8n. You will need access to the MySQL shell, whether through command-line or GUI.
When executing this script; for each node that has a translation, it will create an alias for my 'download' content-type. Since I lost all aliases for this content type, I do not needto check if one existed before assigning the new alias. This can be added in though.
Simply substitute YOUR_PREFIX with the language prefix, e.g. de
Also substitute the 'download' with the name of your content type.
INSERT INTO url_alias (src, dst, LANGUAGE)
SELECT DISTINCT CONCAT("node/",node.nid), url_alias.dst, "YOUR_PREFIX"
FROM node
JOIN url_alias
ON node.tnid = SUBSTRING(url_alias.src, 6)
WHERE node.tnid != 0
AND node.LANGUAGE = 'YOUR_PREFIX'
AND node.TYPE = 'download'Remember to always backup your database first! Or atleast backup the 'url_alias' table.
