Closed (fixed)
Project:
Language Switcher Dropdown
Version:
8.x-2.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 Oct 2017 at 23:26 UTC
Updated:
8 Mar 2022 at 10:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
stephenrodrigo@yahoo.com commentedI just found out that there is a checkbox called 'Show all enabled languages'.
I have created a patch to select all languages if that box is ticked and select an available language if it's not ticked.
Comment #3
stephenrodrigo@yahoo.com commentedComment #4
stephenrodrigo@yahoo.com commentedComment #6
bserem commentedThe patch does not apply against latest dev.
Comment #7
bserem commentedRerolling patch against latest dev
Comment #8
bserem commentedComment #10
kala4ekPatch needs to be updated. At least direct using of
\Drupal::routeMatch()should be replaced by DI of necessary container.Comment #11
prashant.cChanged
\Drupal::routeMatch()with Dependency Injection.Comment #12
kala4ek@Prashant.c you did not run and check your code, right? ;)
At least the number of arguments received in
__constractand arguments passed increatedoes not match.Comment #13
prashant.c@kala4ek
Sorry i could not test it.
Submitting again with changes please review is it good now ?
Comment #14
prashant.cAny updates on this , any reviews?
Comment #15
kala4ekComment #16
_dcre_ commentedThere is an issue with the patches. Its more of an issue of ContentEntityBase::getTranslationStatus
Im not sure if this an actual bug of getTranslationStatus or just a misconception from my side.
The fact of the matter is that getTranslationStatus returns 1 if a translation exists but is unpublished.
In this case, you get to see that language in your lang switcher although the actual translation cannot be accessed.
The attached patch tries to correct this behaviour.
Comment #18
_dcre_ commentedFixed patch is attached
Comment #20
_dcre_ commentedhopefully this time i will get it right
Comment #21
scotwith1tWhy target just nodes? What about other translatable entity types (e.g., Group entities from Group module)?
Comment #22
t_d_d commentedSince i needed this and Dropdown Language module has this built in already, i just used relevant piece of code. So far its working.
Im noob when it gets to posting patches to issues and all that stuff with git (https://www.drupal.org/node/707484 - my head will explode, its to complicated). I just created patch, will attach it to this issue, hope i will help someone and hope that i wont break something badly...
Comment #23
johnpicozziThe last patch seems to work well at limiting the list of languages. However, It doesn't hide the block if only one language is present.
Comment #24
pianomansam commented@johnpicozzi here is a new patch that adds a configuration option to hide if only one language is available.
Comment #25
pianomansam commentedThe previous patch doesn't apply to 2.x-dev anymore plus it had a bug that didn't correctly set the cache context. Here's a new patch that applies to dev and fixes the cache context issue.
Comment #26
pianomansam commentedLet's try that patch again.
Comment #28
pianomansam commentedHere's yet another iteration on this patch. Because the cache context was only being applied to the route, adding or changing the translations for a node didn't clear the block cache for the node so the block wouldn't show up without a full cache clear. Additionally, the code from earlier patches only considered the first entity in the current Drupal route. I rewrote that section to consider all entities.
Oh, and I added this missing schema so hopefully the tests will fire.
Comment #30
pianomansam commentedTests still assumed the default was to show all languages. Hopefully this update fixes them.
Comment #31
pianomansam commentedCache wasn't always clearing when adding translations, probably due to not properly using
$entity->getCacheTags()Comment #32
pianomansam commentedI'm still getting reports that the cache is not correctly clearing.
Comment #33
pianomansam commentedHere's another pass at this, hopefully with caching fixed.
Comment #35
kala4ekComment #37
google01 commentedIn configurations with visibility management by roles, version 4.0 that includes this patch does not work correctly.
Unfortunately it hides the languages of the translations in the dropdown.
This issue is not repeated in version 2.0-beta4.