4

I have enabled entity translation and multi-language feature to an existing Drupal site. Currently all nodes in the site are set as Language Neutral, so the translation tab wont appear. If I edit a node and manually change the language to English the translation tab will appear and I can add the translated content for other languages.

I've tried the VBO - Modify entity values operator method mentioned at How can I set the language of nodes in bulk to existing content when making a site multilingual? but after changing the language from language neutral to English via VBO, the body content is not displaying when I edit the node later. The body content will appear if I change the value back to language neutral. It looks like the language of the field body is not change with the view bulk operations.

Is there any way I can can do a bulk operation and change the language of the nodes in bulk so that the nodes are translatable?

Thanks

3 Answers 3

2

Oh, yes, I remember this pitfall. Here's what happens: assuming the default language of your site is English, any Language Neutral node is assumed to be English. If you look at the node table in the database, you'll see that their language is 'und'. This is per content type, so let's say we have Language Neutral Basic pages. If you now add a Basic page with language English, its body won't be displayed, though if you check the database, you'll see that it's there (and the node's language is 'en').

The moral: all English-language nodes of the same content type must have language set to either 'und" or 'en', or the ones set to 'en' won't display. On our site, we set the critical content types to Require language (Don't allow Language Neutral). (Under Admin -> Structure -> Content types -> Edit -> Multilingual settings.)

2

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.

0

Here's one way to do this that doesn't involve writing any code.

  • Install the VBO module.
  • Create a new view showing Content of whatevercontent types you need to convert. Use the Fields display method.
  • Adda field Bulk operations: content.
  • Check Modify entity values and select Language.
  • Choose Apply.
  • Save the view (add any other filters

if necessary to limit the selection) and go to the created view page. From the view page, choose the option to select all items on all pages and execute the Modify entity values action.

Choose the language and click next. If you have an extremely large number of nodes, you may need to play around with the queuing settings so that not everything is executed at once, but I would try doing it in one pass first because hey, if it works, you're done (note: always test on a backup first!)

this post get from another post on stackexchange orginal post

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.