How can I disable/delete this option. I want users to select one of the website languages.

Thanks.

Comments

molino’s picture

Follow up - default language is English

-Anti-’s picture

Same question.
I can't even think of a good reason for have a 'language neutral' option.
It just makes filtering content harder.

EDIT:
Since this thread is still alive, I should mention that I don't have a problem with it any more.
I prefer 'neutral' to be the default than the default language or the current selected language.

Everything I say is opinion, even if interpreted as fact.
Sometimes I may be inaccurate or *GASP* wrong!
Sometimes I attack Drupal due to frustration. Get over it.

mariusooms’s picture

Also looking for a solution. Found nothing yet...I have no need for it and will confuse posters. They are required to choose a language as language neutral doesn't seem to offer translation options. Is there any way to unset this in my template.php?

Regards,

Marius

jwilson3’s picture

I'm also looking to get rid of Language Neutral, or more exactly, when creating nodes, have the language selector AUTOMATICALLY select the interface language.... so as not to trick people into having to specify something that **should** be self evident.

mariusooms’s picture

Exactly!

depaulmathew’s picture

I just got another reason to disable the language neutral. The translation interface doesn't show up if the language is neutral.

De Paul Matthew

De Paul Matthew

madslund’s picture

I went to the file i18n.module and commented out this line:

$languages = array('' => t('Language neutral')) + $languages;
(Line 356)

depaulmathew’s picture

thanks. it works.

De Paul Matthew

De Paul Matthew

depaulmathew’s picture

that option has gone off for admin. but for all other user types i can the language neutral option still.

can u help me on this?

De Paul Matthew

De Paul Matthew

e2thex’s picture

If one makes a module with the following code, I think it will talk away the option on all node forms

<?php
function MODULE_NAME_form_alter(&$form, $form_state, $form_id) {
  if(
strpos($form_id, '_node_form') !==false)  {
   
$form['language']['#options'] = array_diff_key($form['language']['#options'], array(''=>'Language neutral'));
  }       
}
?>
jwilson3’s picture

Thanks e2thex! Here's a slightly revised version that doesnt blow up when there isn't a list of multiple languages yet...

This version also goes a step further and fills the default value to the current user's language.

<?php
function MODULE_NAME_form_alter(&$form, $form_state, $form_id) {
  global
$user;
  if(
strpos($form_id, '_node_form') !==false)  {
    if (
is_array($form['language']['#options'])) {
     
$form['language']['#options'] = array_diff_key($form['language']['#options'], array(''=>'Language neutral'));
        if (empty(
$form['language']['#default_value'])) {
         
$form['language']['#default_value'] = $user->language;
        }
     }
  }
}
?>
blueblade’s picture

Hi, jrguitar21,
I added your code to template.php file but it doesnt seem to do anything...should that code added somewhere else? Thanks.

BB

nwe_44’s picture

blueblade
e2thex's code needs to go into a new module, not your theme's template.php file.

this http://drupal.org/node/206753 is a link to the drupal handbook on creating new modules.

nwe_44’s picture

This is a further revision that respects when the user is creating a translation

<?php
 
if (isset($form['#id']) && $form['#id'] == 'node-form') {

    if (isset(

$form['#node']->type) && variable_get('language_content_type_'. $form['#node']->type, 0)) {
   
$node = $form['#node'];
    if (!empty(
$node->translation_source)) {
     
// We are creating a translation. Add values and lock language field.
     
$form['translation_source'] = array('#type' => 'value', '#value' => $node->translation_source);
     
$form['language']['#disabled'] = TRUE;
    }else{
        global
$language;  
       
$form['language'] = array(
       
'#type' => 'select',
       
'#title' => t('Language'),
       
'#default_value' => (isset($form['#node']->language) ? $form['#node']->language : $language->language),
       
'#options' => locale_language_list('name'),
      );
    }
   
    }
  }
}
?>
jackalope’s picture

Is this supposed to be added to the module along with jrguitar21's code above? Also, what is this supposed to do? I tried out just jrguitar21's code and that seems to respect the language that the translation is being created in by itself; is this supposed to do that or something different?

yo-l’s picture

He missed to copy the function declaration... just copy the function header above.

But i found a problem... if it dont work you will need to set weight to your module. i set my module to 10 in weight and it works
Some info.
http://drupal.org/node/110238

<?php
function MODULE_NAME_form_alter(&$form, $form_state, $form_id) {
  if (isset(
$form['#id']) && $form['#id'] == 'node-form') {
    if (isset(
$form['#node']->type) && variable_get('language_content_type_'. $form['#node']->type, 0)) {
     
$node = $form['#node'];
      if (!empty(
$node->translation_source)) {
       
// We are creating a translation. Add values and lock language field.
       
$form['translation_source'] = array('#type' => 'value', '#value' => $node->translation_source);
       
$form['language']['#disabled'] = TRUE;
      }
      else{
        global
$language
       
$form['language'] = array(
       
'#type' => 'select',
       
'#title' => t('Language'),
       
'#default_value' => (isset($form['#node']->language) ? $form['#node']->language : $language->language),
       
'#options' => locale_language_list('name'),
        );
      }
    }
  }
}
?>
jackalope’s picture

Thanks to e2thex and jrguitar21 for providing this code. I created a module and it seems to be working just fine.

Ideally, though, this would either become a properly contributed and maintained module OR be integrated into the i18n module, right? I'm not really sure which is best; what do other folks think?

kenjil’s picture

This code is fine but it's not working for me.
It's taken in consideration but it seems to be overwritten.
Even though i set my module weight to be the heaviest on the site:((

I wonder why it doesn't work and be glad if you guys had an idea...
I've been already searching for quite a while...

Thanks in advance.

yo-l’s picture

ops wrong place.

quiptime’s picture

I have developed the module "Remove language neutral". The language neutral option can be defined for each nodetype. Please read the module README.txt.
The module can be downloaded here: Remove language neutral

quiptime’s picture

I have developed the module "Remove language neutral". The language neutral option can be defined for each nodetype. Please read the module README.txt.
The module can be downloaded here: Remove language neutral

boran’s picture

Thanks for the module - it looks good: I installed it, and set the option for Forum content type and the language list is reduced.

However, when I create a new forum topic, the Default language is English, and not the current active language (e.g. German). Could it be improved to do that please, for example by integrating/adapting this D7 patch: http://drupal.org/node/311158.

boran’s picture

FYI, the following patch for Drupal 6.14 ensures that new forum posts have the current language:

diff -r1.1 /var/www/modules/locale/locale.module

273a274
>           global $language;
277c278,280
<             '#default_value' => (isset($form['#node']->language) ? $form['#node']->language : ''),
---
>             # SB: use current language for new posts
>             # http://drupal.org/node/311158
>             '#default_value' => (!empty($form['#node']->language) ? $form['#node']->language : $language->language),

Could you please move the module "Remove language neutral" to drupal.org too?

zuza’s picture

Thank you! It works for all content types I work with (also for these created with CCK).

To change the order of languages in the language option list appearing when creating new content, just change the weight of languages here: admin/settings/language

alduya’s picture

I worked on a module that provides this functionality and adds the functionality to select a dynamic or fixed default language for nodetypes.
You can download and review it here http://drupal.org/node/625128.
Please provide feedback on that issue queue.

sillygwailo’s picture

Adding for those, like me, who also had this issue, the official project on Drupal.org for Language Select is at http://drupal.org/project/language_select

(Username formerly my full name, Richard Eriksson.)

rysmax’s picture

deweweb’s picture

seems like it deleted whole language options from the create new node mode -then i go to content types publishing mode and deselected "Neutral language" - but it shows again Neutral language i options of create new node mode on the first position.
I dont see work of the module?

everything that is natural - true

deweweb’s picture

Fixed - need to check Require language (Do not allow Language Neutral) in Content types
Thanks

everything that is natural - true

qqboy’s picture

there is a node add form
then i found the $form['language']
then i delete some value
it is deleted
but in view page
it is NOT showing the expected result
can some one tell me what s going on
and why it s like this
thank a lot to all of you.

finally i set the

<?php
 $form
['language']['#default_value'] = 'zh-hans';
unset(
$form['language']['#options']['und']);
?>

then use css

#edit-language > option:nth-child(1) {
    display: none;
}

it working
but i know it s not the way
can some one tell me why why why ?
thanks.

thank you.