All nodes created with the partial node form are created as "Language neutral" no matter what is configured in the system using multiple languages.

Using Entity translation, the module takes care of language settings on the full form.

Can a language selection been added to partial form or even better create the content in current language instead of Language neutral?

Comments

slowflyer’s picture

StatusFileSize
new1.17 KB

This patch works for me...

devin carlson’s picture

Version: 7.x-3.3 » 7.x-3.x-dev
Status: Active » Needs review
StatusFileSize
new1.27 KB

I think that we should probably follow the language standards used by the core Locale module, namely:

  • If the Locale module is installed and multilingual support is enabled for a node's content type, the node's language should be set to the current interface language.
  • If the Locale module is installed and multilingual support is disabled for a node's content type, the node's language should be set to the default language used on the site.
  • If the Locale module is not installed, the node's language should be set to "Undetermined".

I've attached a patch to implement the above.

@slowflyer The "Create a @bundle" text uses the translatable bundle label, so you should already be able to translate that. Have you tried using the Internationalization module to translate the names of your content types? Also, you should never run variables or user submitted text through the t() function. :)

ezra-g’s picture

This patch look good to me on initial review. Would be great to get a functional review. Adding the 3.4 radar tag.

slowflyer’s picture

The patch in #2 works fine.

@Devin Carlson: the bundle label has not been translatable for me with Internationalization installed.
The node-types were already translated and show up correct on node creation page.
Personally I would prefer to create the string in total first and than run it to t(). The current solution:
'Create a @bundle'
will create
'Create a document'
'Create a event' ... which should be 'Create an event'
running the complete string to t() will give us - at least in the other languages - the chance to display wording correct without constructs like 'Create a(n) document','Create a(n) event'.

slowflyer’s picture

Status: Needs review » Active

Next things need to be fixed...

In:
commons_posts.module
commons_polls.module
commons_q_a.module
commons_wikis.module

Creation of partial node form is hard coded to (f.e. posts)

function commons_posts_form_commons_bw_partial_node_form_alter(&$form, &$form_state) {
  if (empty($form['#entity']) || $form['#entity']->type != 'post') {
    return;
  }

  $form['body'][LANGUAGE_NONE][0]['#title_display'] = 'invisible';
  $form['body'][LANGUAGE_NONE][0]['#required'] = TRUE;
  $form['body'][LANGUAGE_NONE][0]['#placeholder'] = t("What's on your mind?");
  $form['body'][LANGUAGE_NONE][0]['#resizable'] = FALSE;
...
function commons_posts_form_commons_bw_partial_node_form_after_build($form) {
  $form['body'][LANGUAGE_NONE][0]['#pre_render'] = array();
  $form['body'][LANGUAGE_NONE][0]['format']['#access'] = FALSE;
  $form['body'][LANGUAGE_NONE][0]['value']['#rows'] = 3;

  return $form;
}

The result, all these nice things done here do not work.

Based on the suggestion in #2 to select a language or "LANGUAGE_NONE" I added a small function:

function community_box_language($type) {
  global $language;
  if (module_exists('locale')) {
    if (locale_multilingual_node_type($type)) {
      return $language->language;
    }
    else {
      return language_default();
    }
  }
  else {
    return LANGUAGE_NONE;
  }
}

And replaced all:

$form['body'][LANGUAGE_NONE]

with:

$form['body'][community_box_language($form['#entity']->type)]

in the files mentioned above.

After that, everything works like in a fresh installed 3.3.

ezra-g’s picture

Status: Active » Needs work

Correcting the status.

devin carlson’s picture

Component: User interface » Code
Issue tags: +Commons 7.x-3.4 radar

Adding tag.

devin carlson’s picture

Status: Needs work » Needs review
StatusFileSize
new11.1 KB

An updated patch to address #5.

ezra-g’s picture

Status: Needs review » Fixed

Automatically closed -- issue fixed for 2 weeks with no activity.