Force language on creating nodes

Events happening in the community are now at Drupal community events on www.drupal.org.
iztok's picture

I am looking for a solution to choose language before the node is being saved.

You can see that functionality when translating existing node. For example node/add/story?translation=5&language=de Where 5 is the source node ID and de is the language I would like this node to be in.

I tried to use this url to create new node without having source node in English: node/add/story?translation=NULL&language=de where I replaced node ID with NULL (it can anything I guess...).

This actually works but I don't know if it is safe to use, I guess it was not meant to use this like this. Onother thing is that the language select drop down is not disabled as when creating real translation.

Why do we need this functionality?

Sometimes clients have multilingual sites but the site editor don't speak all of the languages so they get translated texts form other party and they only publish the content. So the interface should always be the same.

Problem comes when adding e.g. German content on English interface, because menus entries, terms etc. is in English (when set "Only current language." in content selection - which is a good idea).

Also this patch here is a good idea:
http://drupal.org/node/201675#comment-2630498
This will redirect you to the right path after submitting the node. So for example when posting story in German after posting you will not get /node/5 but /de/deutche-url. Also good for SEO!

Comments

j0nathan's picture

Hi,
I would like something related to this and I posted a support request, but I have no solution yet:

force to manualy select a language in node creation form
http://drupal.org/node/847862

Good point on that too, I

iztok's picture

Good point on that too, I too think that nobody really checks what he posted :)

Well this concept would be great then. You said that this code does not work, but some developer could get it right I guess.

$language = $_GET["force_language];
function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'page_node_form' || $form_id == 'blog_node_form') {
    $form['language']['#default_value'] = $language;
  }
}

But this only selects the right language in select tag.

How to achieve the same effect as in i18n Translate functionality? So when creating node it already has language and all other fields response to that.

For example when building menu I can't choose a parent element when creating node, because only entries of interface language are available.

Internationalization

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: