If a site supports multiple languages it is not clear if galleria module will still work properly. That's because there are array keys that are language dependent. Those are now read from the language property of the node.


miro_dietiker’s picture

kroimon’s picture

As I never used multi-language installations, could anyone with more insight try to do a patch for this one? :-)

jm1’s picture

I'm also having multilingual problems, but I also have some answers. I am using configuration 2c described in the Galleria module README (this uses View to display a list of imagenodes (one image per node)). I need translation of the ALT and TITLE tags which belong to the images.

When I change the language of one of the imagenodes from "Language Neutral" to "English", I get the following error on the webpage:

Notice: Undefined index: en in theme_views_view_galleria() (line 87 of /sites/all/modules/galleria/theme/theme.inc)

This is line 87 of theme.inc:
$item = $row->_field_data[$view->base_field]['entity']->{$img_field_name}[$lang][0];

When I change it to this, the error goes away and it works:
$item = $row->_field_data[$view->base_field]['entity']->{$img_field_name}['und'][0];

The problem is the variable $lang. When the language is "Language Neutral", then $lang=='und'. However changing it to English, then $lang=='en', and the array index fails.

It fails because the only valid index to the element {$img_field_name} is 'und', there is no 'en' index (as the error message states).

The reason it fails is due to how the translation is done. Before I changed language, the node was set to "Language Neutral" (und) - and all the fields in the node were set to "Language Neutral" too.

After I changed the language, the node was set to "English" (en), but importantly all the fields in the node remained set to "Language Neutral" as before. This is normal when translating nodes - a new copy of the node is made for each language, and only the node has the language attribute changed.

Now, having made this change, I then found I was getting double images - Galleria was showing all the translations at once. This was fixed by adding the code (shown by '+' at beginning of line):

function theme_views_view_galleria($vars) {
  $items = array();

  $view = $vars['view'];
  $img_field_name = $vars['img_field_name'];

+ global $language;
+ $current_lang = $language->{'language'};

  foreach ($vars['rows'] as $row) {
    $lang = $row->_field_data[$view->base_field]['entity']->language;
    // omit rows without image field.
    if (!isset($row->_field_data[$view->base_field]['entity']->{$img_field_name})) {

+  if ($current_lang != $lang) {
+     continue;
+  }

    $item = $row->_field_data[$view->base_field]['entity']->{$img_field_name}[<strong>'und'</strong>][0];
    $items[] = $item;

Basically, we need to ignore nodes which have a different language from the current language (which the user selected on the webpage). So if the language is set to English, only 'en' nodes will be shown (and other languages and 'und' nodes will be ignored).

kroimon’s picture

I guess we can somehow use the field_language() for that, but I couldn't investigate that yet.

q11q11’s picture

Here is patch for #3 - http://drupal.org/node/1904070#comment-7049890
But combined with issue described in that thread.
Hope someone will find it useful.