Hello,

I am using marinelli on a multilingual drupal7 website with internationalization module, including the nice marinelli rotating banner feature.

Is it possible to support multilingual title and description for the banner images?

Regards

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lioz’s picture

Assigned: Unassigned » Lioz

hi maryp!

use this code in banners.inc for marinelli_banner_markup function

function marinelli_banner_markup($banners) {
  $output = '';
  
  foreach($banners as $i => $banner) {
    $variables = array(
      'path'  => $banner['image_path'],
      'alt' => t('@image_desc', array('@image_desc'=>$banner['image_description'])),
      'title'   => t('@image_title', array('@image_title'=>$banner['image_title'])),
      'attributes' => array(
        'class' => 'slide' . ($i != 0 ? ' marinelli-hide-no-js' : ''), // hide all the slides except #1
        'id' => 'slide-number-' . $i,
        'longdesc' => t('@image_desc', array('@image_desc'=>$banner['image_description']))
      ),
    );
    // Draw image
    $image   = theme('image', $variables);

    // Remove link if is the same page
    $banner['image_url'] = ($banner['image_url'] == current_path()) ? FALSE  : $banner['image_url'];

    // Add link (if required)
    $output .= $banner['image_url'] ? l($image, $banner['image_url'], array('html' => TRUE)) : $image;
  }
  return $output;
}

let me know if this solves the problem!

cim’s picture

Hi Lioz, I've used the code above. But where can I set the translations?

mdshields’s picture

did you find out how this is to be translated?

I am making an assumption that the updated code included a t(...) wrapper around the text.

Once that is in place, the wrapped text then is included into the translation block. Which is pulled when striking the translation footer block that is provided with the translation module. This doesn't allow for node level translation. I am making these assumptions while I try it out. Will let you know if this is correct (this isn't documented anywhere on how to theme into translations whether supported by block, node or separately).

yamil’s picture

The code below worked for me. The strings are created automatically, you should only switch language. The strings can be translate in the translate interface. You don't worry for XSS. The variables aren't texts that a user entered.

http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/t/7

function marinelli_banner_markup($banners) {
  $output = '';
  
  foreach($banners as $i => $banner) {
    $variables = array(
      'path'  => $banner['image_path'],
      'alt' => t($banner['image_description']),
      'title'   => t($banner['image_title']),
      'attributes' => array(
        'class' => 'slide' . ($i != 0 ? ' marinelli-hide-no-js' : ''), // hide all the slides except #1
        'id' => 'slide-number-' . $i,
        'longdesc' => t($banner['image_description'])
      ),
    );
    // Draw image
    $image   = theme('image', $variables);

    // Remove link if is the same page
    $banner['image_url'] = ($banner['image_url'] == current_path()) ? FALSE  : $banner['image_url'];

    // Add link (if required)
    $output .= $banner['image_url'] ? l($image, $banner['image_url'], array('html' => TRUE)) : $image;
  }
  return $output;
}
Lioz’s picture

Status: Active » Fixed
dangelmut’s picture

I added some changes to make it possible to use a different image_url and image_path for each language too. So if the image shows some text it is possible to show it in different languages. And the user will be directed to the proper url for his language.

The code would be:

function marinelli_banner_markup($banners) {
  $output = '';
  
  foreach($banners as $i => $banner) {
    $variables = array(
      'path'  => t($banner['image_path']),
      'alt' => t($banner['image_description']),
      'title'   => t($banner['image_title']),
      'attributes' => array(
        'class' => 'slide' . ($i != 0 ? ' marinelli-hide-no-js' : ''), // hide all the slides except #1
        'id' => 'slide-number-' . $i,
        'longdesc' => t($banner['image_description'])
      ),
    );
    // Draw image
    $image   = theme('image', $variables);

    // Remove link if is the same page
    $banner['image_url'] = ($banner['image_url'] == current_path()) ? FALSE  : $banner['image_url'];

    // Add link (if required)
    $output .= $banner['image_url'] ? l($image, t($banner['image_url']), array('html' => TRUE)) : $image;
  }
  return $output;
}

I'm a newbie so I don't know how, but I think that it is possible to automatically traslate the URL of the link (image_url). For example, this is one of my spanish articles http://www.soslabview.com.ar/es/biblioteaca-aes-labview and this is the english version http://www.soslabview.com.ar/en/aes-library-labview

If I didn't change the image_url every visitor would go to the first link, but as his language would be different than the url's language, he would get a 404. I mean, try for example http://www.soslabview.com.ar/en/biblioteaca-aes-labview

and you will see.

Take a look at my rotating banners and see what happens if you change language to see what I'm talking about (see how the language of the text in the picture of the AES banner changes, because image is different).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

leventdal’s picture

Version: 7.x-3.0-beta9 » 7.x-3.0-beta11
Category: feature » bug
Priority: Normal » Critical
Status: Closed (fixed) » Active

Hi,

I am using 3.0 beta11 and as far as I've seen the code implemantation mentioned above is implemented already.

My problem is even if I switch languages when i change the banner title from "Apperance" it effects all languages. I don't see a translation possibility in the banner description page when I switch language.

I've tried refreshing strings, clearing cache but didn't help.

In the translation interface I see the text that I've entered. I've translated it and it still doesn't work.

And when i change the text, the altered string isn't added to the strings to be translated area despite the fact that I refresh strings and clear the cache.

Regards,

Note: my site is not live right now. So I won't be able to show an example.
Info: English is not source language in my site.
I'm using "session" to determine the language of the site.

paweld’s picture

Hi,

I'm afraid it doesn't work. Every change of title, etc. in one language changes it in the same way in other languages.

adwordvietnam’s picture

Hi Lioz,

I am using 3.0 beta11 or update banners.inc, but cannot translate banners and description (both languages are same content, not translate)

Best regards,

sd2k9’s picture

The fix currently implemented in beta11 is unfortunately wrong.
You need to implement the code in #1094284-6: Multilingual support for banner title and description by yourself.

How to do the translation afterwards
- Write in English when uploading the banner images.
- Change the language once to generate the strings to be translated
- Translate the text in the "Translate interface"
URL: admin/config/regional/translate/translate

With the implementation in beta11 you can only translate the verbatim strings
"@image_desc" and "@image_title". This is not what you want :-)

With the manual change from #1094284-6: Multilingual support for banner title and description I was able to translate my banner titles.

Beside this small issue (which tought me a lot about Drupal translation internals) - thanks for the great
theme! I really enjoy it.

webmaster-eddie’s picture

Well the link in # 11 takes me to # 6, above, and it does not work. When you look at that guy's pages, the banner text is always in english, whether the page is in spanish or english.

This issue is NOT fixed, even if it were to work, the issue isn't fixed, as the modification is not in the latest beta release - and with the next marinelli upgrade, any changes made to the file will be written over...

Would someone answer clearly - is multilingual support for the 2 different strings of text for each marinelli 7 banner planned (without having to modify a file by hand) or not, please?

sd2k9’s picture

Hi webmaster-eddie,

I am attaching the patch I am using, which applies versus 7.x-3.0-beta11

Usage instructions are already given in #11
If you have trouble to get it running just let me know and I try to help.
For myself it's fine.
Maybe not the most elegant solution, but working as expected.

Cheers!

JeniferTucker’s picture

#13 worked for me, thanks sd2k9 :-)

[drupalroot]

// Add patch file to Marinelli theme directory.
// (sites/all/themes/marinelli)

// Copy over banner.inc (just in case).
pushd sites/all/themes/marinelli/logics

    cp banner.inc banner.inc.original

popd

// Run patch.
pushd sites/all/themes/marinelli

    patch -p1 < filename.patch 

popd

You can now add tranlations to Marinelli banners.

Select theme settings.
www.example.com/admin/appearance/settings/[sub-theme]

Banner management.
Upload a new banner with title/description (if no banners images in place).
Save configuration.

Switch language to generate the strings to be translated.

Translate the text in the "Translate interface".
www.example.com/admin/config/regional/translate/translate

Use the 'Filter translatable strings' to find the text you want to translate.

Click on 'edit' under 'operations'.
Add translated text.
Click on 'Save translations'.

Fiable.biz’s picture

Hello. Thank you for your useful contributions. It used to work: I added the translation into Mongolian a while ago. Now I added the French language, but the strings don't appear in admin/config/regional/translate/translate any more. In what group are they supposed to appear?

  • Lioz committed 3cf070a on 7.x-4.x
    Issue #1094284: added multilingual support for banner text
    
    

  • Lioz committed 3cf070a on 7.x-4.x
    Issue #1094284: added multilingual support for banner text