I have my site set to English as its default language. When I change the translation to English (users do weird things) it translates the page into another language (Dutch I believe, which would be the language before it alphabetically). If I change the language to something else and back to English it works fine.

So if the first thing you do is tell it to translate to default language it doesn't do nothing it translates it to something else.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jinghan Wang’s picture

Issue summary: View changes

Same problem here. Is there any solution? The module translates content to Afrikaans instead of English in my case.

ejrasmus’s picture

How I fixed this was disabling the default language in the dropdown if it was already in the default language. The default language is then enabled again once a different language is selected.

Jinghan Wang’s picture

Thanks for the path. @ejrasmus. I did it by same method through a js file with some other custom feature.

sumithb’s picture

I updated the script as follows and I didn't updated the contributed module. I added following js code in a separate js file and included it from the custom theme.

Now initially the default language will be disabled and also user will not be able to select the active language.

Also

/**
 * @file
 * Javascript file for gtranslate
 */
(function($) {
    Drupal.behaviors.gtranslate = {
        attach: function(context) {
            var main_language = Drupal.settings.gtranslate_main_lang;
            var ml_value = main_language + '|' + main_language;
            
            if (Drupal.settings.googtrans == 'undefined') {
              $('.google-translate option[value="' + ml_value + '"]').attr('disabled','disabled');
              
            }
            $('.google-translate select').change(function(){
              $(".google-translate option").removeAttr('disabled');
              $(".google-translate option:selected").attr('disabled','disabled');
              
            });
        }
    };
})(jQuery);

Also I added following code to the custom module.

drupal_add_js(array('gtranslate_main_lang' => variable_get('gtranslate_main_lang', 'en'), 'googtrans' => isset($_COOKIE['googtrans']) ? 'googtrans': 'undefined'), 'setting'); 
gruda’s picture

I am having the same problem using 7.x-1.10. It seems the block html structure has changed a bit and the fix in #4 is no longer working. Modifying the javascript slightly seems to work for me. I am using the 'On the fly' option and have also include the php from #4.

/**
 * Javascript behavior for gtranslate
 *
 * This initially disables the default language 
 * This also prevents the active language from being selected.
 */
  Drupal.behaviors.gtranslate = {
        attach: function(context) {
            var main_language = Drupal.settings.gtranslate_main_lang;
            var ml_value = main_language + '|' + main_language;
            
            if (Drupal.settings.googtrans == 'undefined') {
              $('#google_translate_element2').nextAll('select').find('option[value="' + ml_value + '"]').attr('disabled','disabled');
              
            }
            $('#google_translate_element2').nextAll('select').change(function(){
              $('#google_translate_element2').nextAll('select').find('option').removeAttr('disabled');
              $('#google_translate_element2').nextAll('select').find('option:selected').attr('disabled','disabled');
              
            });
        }
    };
})(jQuery);
dieppon’s picture

I can confirm that the issue still not addressed on 7.x-1.10 and the patch works.

attheshow’s picture

I just added a patch for this issue in D8 here: https://www.drupal.org/project/gtranslate/issues/2820025

apaderno’s picture

Title: on the fly to defalut langauge changes to a differnt langauge. » On the fly to default language changes to a different language
Version: 7.x-1.9 » 7.x-1.x-dev
edo888’s picture

edo888’s picture

Status: Fixed » Closed (fixed)
the_g_bomb’s picture

Needs backport to D7

i-trokhanenko’s picture

Patch #2 is still compatible with the 7.x-1.15 version of the module.