Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Select language while select from select box first time English language change to African language(Engles). After that change again then works fine. Anyone please look into that.
Comment | File | Size | Author |
---|---|---|---|
#34 | gtranslate-2820025-3297355-disable_switch_current_language-with-D9-support-34.diff | 3.06 KB | codebymikey |
#29 | ipad_not_working_screenshot.png | 305.3 KB | Sseto |
#24 | after_english.png | 95.52 KB | Munavijayalakshmi |
#24 | after_african.png | 103.11 KB | Munavijayalakshmi |
#24 | before.png | 100.9 KB | Munavijayalakshmi |
Issue fork gtranslate-2820025
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
samgao CreditAttribution: samgao at DPCI commentedWe run into the same issue. Can anyone please help?
Comment #3
afschThis issue was happening on D7 as well, here the links:
https://www.drupal.org/project/gtranslate/issues/2822393
https://www.drupal.org/project/gtranslate/issues/1982656#comment-10261903 (Has a partial solution)
Based on the solution in the second link I implemented a similar script in my custom theme.
Note: gtranslate module uses a cookie (googtrans) to know the selected language. I'm using https://github.com/js-cookie/js-cookie to get the cookie value.
Comment #4
HiMyNameIsSeb CreditAttribution: HiMyNameIsSeb at Investis Digital commentedI have found the the same. When clicking on English, the page language is translated to Afrikaans.
In my case however hiding "English" is not an option. This is because the site has no concept of languages, and people all around the world can post to it. This means that some pages are in English, some in Spanish, and some even in Chinese. When English users arrive at a Spanish page, they may want to translate it to English... we even have some cases where part of the pages are in English, and part in Spanish (feeds etc).
Therefore in my case, I want no default language to be set. I want Google to automatically work out the language, and translate it to the best of its ability. For mixed pages this will mean it will translate some paragraphs, and not others.
My fix involves adding the ability to select no default language. This results in the Google translate Javascript having no default language set. I am not sure of the bigger picture consequences of this, so please use my fix understanding that there may be consequences I am un-sure of. It is also worth noting that in my case, the site is a closed community, and therefore is not indexed by search engines. I can't imaging this to have any SEO impact as the language is just related to the translate javascript and not any other meta information (as far as I am aware). But please do check this won't affect your SEO. Happy to discuss if this fix has repercussions I am unaware of.
It appears to me that Google does a remarkable job of working out the language and translating the content even with no default language set. This may be to my untrained eye, so again do your own testing... if anything comes back from our testing, I'll post an update here.
Comment #5
HiMyNameIsSeb CreditAttribution: HiMyNameIsSeb at Investis Digital commentedComment #6
HiMyNameIsSeb CreditAttribution: HiMyNameIsSeb at Investis Digital commentedForgot to add the new language to the block class.
Comment #7
Tom M Fallon CreditAttribution: Tom M Fallon at Concentric.cx Ltd commentedHey
I applied patch #6 and found I ended up with the flags mismatched against their language.
Dutch has the Finnish flag against it.
Think this needs work.
Thanks
Comment #8
Tom M Fallon CreditAttribution: Tom M Fallon at Concentric.cx Ltd commentedComment #9
apadernoBugs are fixed in the development snapshots (the releases created from branches).
Comment #10
attheshow CreditAttribution: attheshow at Richland Library commentedI took a look at all of the issues I could find here in the issue queue related to this (#1982656, #2820025, and #3127553). Thanks to everyone who submitted code suggestions. I've consolidated all of that into a patch that appears to be working for Drupal 8 here.
Comment #11
apadernoThe IS needs to be updated; reading it, it's not clear what the issue is, and what the patch is trying to resolve.
Comment #12
attheshow CreditAttribution: attheshow at Richland Library commentedAdding an updated patch to work with version 1.14 of the module.
Comment #13
attheshow CreditAttribution: attheshow at Richland Library commentedRemoves unnecessary console.log.
Comment #14
apadernoComment #15
dbroll CreditAttribution: dbroll commented+1 for #13 x 1.14
Comment #16
sbasile CreditAttribution: sbasile commentedI think #13 puts the JS folder in the wrong location. It doesn't seem to add it to the JS folder of the module but instead creates a new folder. Am I applying the patch incorrectly?
Comment #17
jez500 CreditAttribution: jez500 at Doghouse Agency commented+1 for #13 x 1.14
Comment #18
apadernoComment #19
avitus80 CreditAttribution: avitus80 commented+1 for #13 x 1.14
Comment #20
nord102Re-rolled #13 just to clean it up a little bit and remove the commented out console log
Comment #21
trevjs CreditAttribution: trevjs at Taoti Creative commentedThe previous patches didn't seem to mark the current language as disabled when moving to a new page. This patch addresses that problem by taking the value from the cookie and disabling the appropriate option.
Comment #22
raviranjan007 CreditAttribution: raviranjan007 as a volunteer and commented#21 Patches are working fine for me.
Thanks
Comment #23
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound for Valuebound commentedComment #24
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound for Valuebound commentedPatch #21 working fine.
Comment #25
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound for Valuebound commentedComment #27
pr1859 CreditAttribution: pr1859 commentedMy case:
When I select English with nothing else selected, it turns to another language (perhaps Afrikaans).
When I re-select English, it turns back to English.
I am still having this issue, patches above does not seem to work, using 8.x - 1.14
Comment #28
Sseto CreditAttribution: Sseto commentedI applied patch#21 and it worked on D9.5.2.
@pr1859. I had to refresh the cache in order for it to take effect. To confirm that it's working, your "Main language" should be greyed out in the dropdown.
Good luck!
Comment #29
Sseto CreditAttribution: Sseto commentedHello,
Turns out Ipads/tablets do not work correctly. When you select another language, your "Main" language remains greyed out and unselectable.
Comment #30
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedComment #31
edo888 CreditAttribution: edo888 commentedPlease test: https://www.drupal.org/project/gtranslate/releases/8.x-2.x-dev
Comment #32
Sseto CreditAttribution: Sseto commentedHi edo888,
Tested dev and now I'm getting WSOD. I reverted back to stable and reapplied the patch for now.
Here's the dblog:
Undefined array key 1 in Drupal\gtranslate\Plugin\Block\GTranslateBlock->build()(line 385 of /var/www/sseto.ca/web/modules/contrib/gtranslate/src/Plugin/Block/GTranslateBlock.php)
#0 /var/www/sseto.ca/web/modules/contrib/gtranslate/src/Plugin/Block/GTranslateBlock.php(385): array_values()
#1 /var/www/sseto.ca/web/core/modules/block/src/BlockViewBuilder.php(171): Drupal\gtranslate\Plugin\Block\GTranslateBlock->build()
#2 [internal function]: Drupal\block\BlockViewBuilder::preRender()
#3 /var/www/sseto.ca/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array()
#4 /var/www/sseto.ca/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback()
#5 /var/www/sseto.ca/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback()
#6 /var/www/sseto.ca/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
#7 /var/www/sseto.ca/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
Comment #33
Sseto CreditAttribution: Sseto commentedComment #34
codebymikey CreditAttribution: codebymikey at Zodiac Media commentedAdded a variation of the patch which attempt to support D9/D10. May be used in tandem with #3297355-8: Automated Drupal 10 compatibility fixes
Comment #35
RandalVThe last patch does not apply for me.
However, if I understand the issue correctly, it's similar or equal to the issue I'm having.
Our default language is English, sometimes (I don't know what the trigger is) when changing to a different language, you can't change back to English.
You have to click on the current language again, and then you can click English again and it'll work.
When this happens, English is the selected language in the language selector, but the page is still in the translated language.
No console errors or other measures to know what's going on.
If what I described matches/corresponds to what the original poster experiences, maybe we can update the issue as such if it's clear enough.
Comment #36
RandalVBumping again...
Can the maintainer please take a look at this??
Is there even still an active maintainer?