when a multilingual support is disabled for given node type, then a saved node should not have language set in {node} nor in {url_alias} table, it should be saved with language = NULL

the problem is that some links will not show the url alias but shows the internal link, because the url alias does not exists for the actual language.. so I have to change the language manually for these nodes..

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pasqualle’s picture

the problem is in locale_form_alter() function with this code snippet

        // Node type without language selector: assign the default for new nodes
        elseif (!isset($form['#node']->nid)) {
          $default = language_default();
          $form['language'] = array(
            '#type' => 'value',
            '#value' => $default->language
          );
        }
Pasqualle’s picture

Version: 6.x-dev » 7.x-dev
Status: Active » Needs review
FileSize
1.48 KB

also changed the default language for multilingual nodes, because that should not default to Language neutral.

brucepearson’s picture

Status: Needs review » Needs work

The patch doesn't work for me, it still sets the language selector to "Language neutral".
When the locale_form_alter is called $form['#node']->language is set to an empty string.

Maybe change:

'#default_value' => (isset($form['#node']->language) ? $form['#node']->language : $default->language),

to

'#default_value' => (isset($form['#node']->language) && $form['#node']->language != '' ? $form['#node']->language : $default->language),
Pasqualle’s picture

When the locale_form_alter is called $form['#node']->language is set to an empty string.

I see, that is a problem.

But I think your modification changes the node language even when you edit it, not only at node creation. Can you confirm that when you open a node for edit which is "Language neutral", it changes to default language automatically? That should be wrong also..

brucepearson’s picture

you are right - my modification wont work when you edit a node that is "Language neutral".

Maybe it would be better to just see if we are editing a node then and set the default language only if it is a new node.

We can check for the nid:

'#default_value' => (isset($form['#node']->nid) ? $form['#node']->language : $default->language),
Pasqualle’s picture

that smells like a little hack to me :) The code should be easily readable. You are mixing two things here, at least it should be changed to an if statement with an explanation written in the code comment.

note: the isset($form['#node']->language) is used to avoid php notices, and possible problems. (although I do not know now, how could that isset() return false)

Pasqualle’s picture

but the good solution would be to not set the node language outside the locale module. I do not understand why it is set to an empty string.

Pasqualle’s picture

Title: language is set for non multilingual node » default node language
Component: path.module » locale.module
brucepearson’s picture

It looks like it is being set in the node module, node.pages.inc, function node_add

    $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => '');
plach’s picture

Issue tags: +i18n sprint

subscribe

Pasqualle’s picture

the node.module uses the node language property, and it would be hard to remove. So I am fine with the isset($form['#node']->nid) check, just the code needs to be more readable..

Pasqualle’s picture

mrbuom’s picture

mrbuom’s picture

FileSize
870 bytes
cronix’s picture

I am looking for something similar. I have made a vocabulary with language specific terms. This vocabulary is used in my forum. That way I have have a multi lingual forum because the forum page will only show the terms in the current site language. That is working perfectly. My issue is that the forum posts are posted language neutral and not in the current site language. Has anyone found a solution for that? I am using D6.12

smartmark’s picture

Mrbuom's patch (#14) works perfectly, thanks!

alienzed’s picture

#14: awesome, thanx

boran’s picture

#14 worked fine for me on D6.14 too.
A pity core has to be hacked and this fixed has not been included in core over the last few months..

There is also a thread on removing "Language neutral", that was also needed for my multi-language form site, perhaps it interests other readers: http://drupal.org/node/250891