4
votes

I have a site in drupal which is in spanish by default. Now I want to add the english translation. It has a lot of entities "producto" with undefined ('und') language. I want to mass assign the 'es' language to them. Before posting this question I have checked this other question How to change node languages in batches? but I'm unable to accomplish what I want. Let me explain:

a) I have tried Language Assignement but it last commit was 1 year ago and it has a critical bug that can lead to data loss (I reproduced the error too) I also tried with the patch from user barami but the data loss persists.

b) View Bulk Operations: I've tried it, but it does only update the field in database table "node". Not the other ones.

c) So I checked out how the drupal database works and created a sql script which also leads to data loss:

-- Step 1 Node lang
update node set language='es' where type='producto';

-- Step 2 body field
update field_data_body set language='es' where bundle='producto';

-- Step 3 Field comment vody
update field_data_comment_body set language='es' where bundle='comment_node_producto';

-- Step 4 For each field of producto, update language
update field_data_field_precio set language='es' where bundle='producto';
update field_revision_field_precio set language='es' where bundle='producto';

(...)

I have the following translation modules activated: Internationalization, Block languages, Field translation, Menu translation, Multilingual content, Multilingual select, Synchronize translations, Taxonomy translation, Translation redirect, Translation sets

What Am I doing wrong with my sql script? Are there other plugins to accomplish what I want to do? Any suggestion will be appreciated Thanks!

3

3 Answers

2
votes

Here's how I bulk set the language on my site:

  1. Using Views Bulk Optimization, select all nodes you want to change, use the 'Change value' option and then change the value to language you want.

  2. After you've done this, the field values will not appear when editing the nodes, so you need to run a script, e.g. UPDATE database.field_data_body SET language='en' WHERE bundle='page' (use your db name, field name, and bundle as appropriate).

IMPORTANT: If you have any custom url aliases, they will be overwritten with this approach, due to a problem with pathauto, but there's a work-around: first go to /admin/config/search/path/settings, and change the 'Update action' option to 'Do nothing. Leave the old alias intact.', then change this value back once you've run your Views Bulk Operations action.

1
votes

Assuming you can make a view listing your entities, you can use the Views Bulk Operations module to do this. I just explained how to do this the other day for nodes on Drupal Answers.

0
votes

Another solution would be to just execute the first SQL because I have discovered that the fields language must remain 'und'.

update node set language='es' where type='producto';