Hi,

My setup: I have a site with four languages. Language negotiation set to current language only. Each menu item has it's own language.

My problem: I needed a condition based on menu items that work in all languages (that is, show a block on "About" pages across all four languages). In Context module Menu condition form displays menu items that lead to nodes only in current language as query was altered by i18n module.

Solution: I had to disable rewriting of query by i18n module so I did this. i18n_db_rewrite_sql() function in i18n.module asks i18n_selection_mode() function whether to rewrite the queries. If called with an argument "off", i18n_selection_mode() function remembers the setting in a static variable and disables node query rewriting on Context admin pages.

This brings down to this function you can use in a custom module:

/**
 * Implementation hook_init
 */
function mymodule_init() {
  // Allow multilanguage menu display in Context module
  if (arg(0) == 'admin' && arg(1) == 'build' && arg(2) == 'context') {
    i18n_selection_mode('off');
  }
}

I'm not sure if this is a feature that Context should enable. It's more like a scratch for a particular itch.

Hope this helps someone. Cheers

Comments

yhahn’s picture

Title: How to display menu in all languages in Menu condition form » i18n integration and other workarounds
Version: 6.x-3.0-beta4 » 6.x-3.x-dev
Status: Active » Needs work

Anyone else using context with i18n and collecting other adjustments needed to make the two play nice?

jmseigneur’s picture

+1

xalexas’s picture

This is exactly what I need also. Subscribing.

BarisW’s picture

Priority: Normal » Major

Hi Young,

we are in the migration of moving all blocks to Context to make our deployments easier using Features. As our site is multilingual (Dutch/English), getting Context to respect i18n_block settings is top prio for us. For now, we have to create a Context for every language, which are 99% identical. This currently is a burden for all sites that are multilingual, so I'm changing the priority to major, if you agree.

If we can test anything, please let me know.

BarisW’s picture

Status: Needs work » Needs review
StatusFileSize
new1.46 KB

I hacked the context_reaction_block.inc to make blocks localization settings work with i18n. Not sure if this is the best solution, but it works for us. Comments welcome ;)

hedac’s picture

#5 applied your patch.. but still my blocks don't respect language context.

hedac’s picture

sorry...
I've just upgraded to 3.x dev version
and now it works.. but I was also missing that I had to create a context with "Require all conditions" for the language to be "logical AND" with other conditions.

sreynen’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
StatusFileSize
new1.56 KB

Attached is a D7 version of patch in #5. I'm changing version, assuming D7 work is coming first now.

steinmb’s picture

Priority: Major » Critical

Version 6.x-3.0. My menu-blocks items show up for default language, but if I change language are they are all gone, even the context is "always show". The even more strange thing is that, this only happen on the site front-page, if a navigate any other page the translated menu items get rendered.

steinmb’s picture

Category: feature » bug

And it is prob. not a feature req. this a critical bug, then it brakes context on multilanguage sites. Pls. correct me if I'm wrong and this is secretly fixed somehow.

Cheers
steinmb

tekante’s picture

Adding tag for tracking

pbz1912’s picture

StatusFileSize
new1.62 KB

rerolled patch. Not sure its working.

tekante’s picture

Status: Needs review » Postponed (maintainer needs more info)

After looking at this issue and the comments I need more information to determine what the requests are, how to duplicate the issues and validate the patches for committing.

It appears the original request has to do with being unable to see menu items that aren't in the current language for selection in the context menu condition. I have set up a site with two languages, a basic page node that is in the primary language and translated into the secondary language, both of which are in the menu. When I view the context menu condition I see both menu items so I am unsure what the provided code snippet is intended to accomplish. I believe a key piece that I am missing revolves around "Language negotiation set to current language only" as I see no way to set that in my Languages Detection and Selection interface (admin/config/regional/language/configure).

Most of the comments appear to be concerned with translated blocks. I have also enabled the i18n_block module and created a block in the primary language that is translated into the secondary language. I place the primary language block using the context block reaction and depending on what language I request my site in the correct version of the block displays.

My testing was done with the latest 7.x-3.x-dev version of the context module.

In order to proceed with applying the suggested patches, this issue needs a clear description of what is trying to be accomplished and a description of how to setup a site to demonstrate the problem such that a maintainer not overly familiar with all of the internationalization modules can replicate. At that point I'll be able to verify that the patches resolve the issues and commit. At the moment I am unable to configure a site such that I can validate the necessity of the patches and their functionality.

Thank you.