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.
Problem/Motivation
Sometimes, breadcrumbs does not have to use the same behavior in different languages.
For example, you can have a different menu by enabled language and some pages (probably from Views) could be in each of these menus. In this case the breadcrumb will always be in the main website language and never really translated.
Proposed resolution
Internationalization module offers the ability to translate Drupal variables using the Variable API. This would allow to change the Crumbs' components weights to be language dependant.
Remaining tasks
- Declare
crumbs_weights
in thehook_variable_info
from theVariable
module - Interface
crumbs_get_weights
with i18n_variable - Interface
crumbs_admin_form_submit
with i18n_variable - Adapt the Crumbs' UI to allow to switch language quickly
User interface changes
Add a language switcher like shown in the attached picture.
API changes
None
Comments
Comment #1
DuaelFrRemaining tasks
Declarecrumbs_weights
in thehook_variable_info
from theVariable
moduleInterface crumbs_get_weights with i18n_variableInterface crumbs_admin_form_submit with i18n_variableThis patch allow you to define language related settings by switching the backoffice language.
The remaining task would allow to make this easier.
Comment #2
DuaelFrFix a bug when i18n_variable is enabled but crumbs_weight is not set as a multilingual variable.
Comment #3
donquixote CreditAttribution: donquixote commentedHi,
I think that's a good idea, but I'd like to brainstorm a bit before we add this.
Probably the suggested solution is indeed the easiest one, while my ideas just suck, so please be nice :)
Does this only apply to menus, or do we have other examples?
If it is only for menus, I had some idea that already exists in menupoly:
If you name your menus like
primary-links-fr, primary-links-de, etc, then it can automatically pick the correct one.
Do we have another way to know which language a menu is in?
Can users still do their language-neutral default settings, and only override for some languages?
Would it make sense to have something like this instead?
menu.hierarchy.primary_links[lang=fr]
(Probably a bad idea, because it would make the entire thing even more cryptic, and a move to a graphic UI more difficult)
Comment #4
DuaelFrAll this is open to discussion but I had a major problem so I solved it the easiest way I found.
I don't think this is only usefull for menus but maybe for taxonomies too, it was just an example.
The fact is that the main (huge) i18n module has defined a way to handle localized settings so I think we should not reinvent the wheel and try to use what exists.
Here is a new patch working with the last versions of i18n and variable.
Comment #5
donquixote CreditAttribution: donquixote commentedOk, here is a plan:
1. We implement the solution you suggested, but make sure that people can still define a language-neutral setting as a fallback.
(or fallback to the default language?)
2. In the future we might add other solutions where they make sense. E.g. a technique to automatically pick the correct menu for a language. This needs further thinking, so we don't do this now.
Does your solution allow a default / language-neutral / fallback setting?
Comment #6
DuaelFrRemaining tasks
Declarecrumbs_weights
in thehook_variable_info
from theVariable
moduleInterface crumbs_get_weights with i18n_variableInterface crumbs_admin_form_submit with i18n_variableAdapt the Crumbs' UI to allow to switch language quicklyIt seems that the i18n module take the default language setting as the default so I would say "yes".
This last patch adds to the form the language selector as it is set on the other translatable settings forms. It is made in a dirty way because the crumbs module does not just use drupal_setting_form but it works well.
Comment #7
candelas CreditAttribution: candelas commentedthanks for making it translatable.
dont forget, please, views titles (i am having this problem).
Comment #8
donquixote CreditAttribution: donquixote commented@DualFr,
thanks for the patch!
I'm a bit afraid it will conflict with recent work over here,
#1404018: Better UI for hierarchical prioritization form
Might be a good idea to fix that other thing first?
It also means we move to drupal_settings_form(), which might make things a bit easier :)
Comment #9
donquixote CreditAttribution: donquixote commentedBtw, checking the module with your patch, I have a little issue.
When I visit the configuration form, it doesn't say in which language it will save the new config. I think we should be absolutely transparent about this. And maybe the drupal_settings_form() will give us some of this for free?
Comment #10
donquixote CreditAttribution: donquixote commentedConfiguration forms have changed a lot in 7.x-2.x
Re-roll? Or rethink?
Comment #11
donquixote CreditAttribution: donquixote commentedI'd like to put this question back on the table..
Both for menus and taxonomies, the usual use case I can think of is that some menus and vocabularies are for all languages, while some are for a specific language only.
For this kind of scenario I imagine it quite unpractical having to maintain completely independent priority settings for each language.
Comment #12
donquixote CreditAttribution: donquixote commented(The only) two issues I could find on drupal.stackexchange:
http://drupal.stackexchange.com/questions/62568/multilingual-breadcrumb-...
http://drupal.stackexchange.com/questions/59930/how-can-i-add-multilingu...
I would like to know a lot more about the use cases..
Comment #14
donquixote CreditAttribution: donquixote commentedThis could be one of the things to discuss on DrupalCon.
#2094933: Crumbs BoF/meeting on DrupalCon Prague 2013?
Comment #14.0
donquixote CreditAttribution: donquixote commentedCorrecting little mistakes
Comment #15
Bertjuh CreditAttribution: Bertjuh commentedAny update? Is there any way to have the following:
in: admin/structure/crumbs/entity-parent/user
For the "Crumbs parent path for users with role x"
Dutch: over-ons
English about-us