Support » Plugin: Polylang » Translation works in NextGen albums, but not in galleries

  • Resolved grgbyny



    I’m using Polylang and NextGen Gallery. On the album page the gallery titles get translated all right, but on the gallery pages they won’t, although I’m using the exact same code.

    <?php echo $gallery->title ?>

    I just can’t wrap my head around it, I’ve tried everything to no avail and it’s driving me nuts. I have a deadline tomorrow and I’m completely stuck now. Please, help!

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Chouby


    Why do you want to write php code? It should work out of the box.

    But… The way Nextgen gallery works with Polylang, the string is registered for translation only when it is displayed the first time on frontend. This is not very convenient but you have to:
    * define your gallery title in Nextgen gallery admin
    * view your gallery title on frontend (this step is mandatory because Nextgen gallery registers the string only here).
    * translate your gallery title in the string translations list table

    The exact code used by Nextgen gallery to internationalize the gallery title is:

    $galleries[$key]->title = html_entity_decode ( nggGallery::i18n( stripslashes($galleries[$key]->title), 'gal_' . $galleries[$key]->gid . '_title') ) ;

    found at line 577 of nggfunctions.php
    But this code should be executed before loading the template so your code should work.

    Thank you for your reply! But I’m still not sure what to do.

    The gallery title is already translated in the string translations list and it shows up fine in all languages on the album page, so I guess I did the process right. It just don’t get translated when I click through to the gallery page.

    I had to put that php code in there because that’s the only way I know of to make NextGen display the gallery title on a gallery page.

    Plugin Author Chouby


    I am not familiar with Nextgen Gallery enough. Could you provide a link to demonstrate the issue?

    Surprisingly, I stumbled upon a solution in the meantime though I can’t explain why it works.

    I tried to use the function pll__ in the gallery template file with the problematic strings, and it solved the problem. This is how it looks in the gallery.php file:

    <?php echo pll__($gallery->title) ?>

    So, it seems that some variables need this, some don’t, and they vary from page to page. Maybe you can tell me why this is the case.

    Anyway, many thanks for the help, and for the great plugin you created!

    Plugin Author Chouby


    Normally, all the translations are done by Nextgen Gallery using WPML API. And Polylang just provides the same functions as WPML :). Maybe this one has been forgotten.
    It should also work by doing:

    <?php echo html_entity_decode ( nggGallery::i18n( stripslashes($gallery->title), 'gal_' . $gallery->gid . '_title') ) ; ?>

    This is the standard way Nextgen gallery uses to translate strings. If it works, maybe you can propose the patch to the authors as it should work with other multilingual plugins too. The solution with ‘pll__’ does work only with Polylang.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Translation works in NextGen albums, but not in galleries’ is closed to new replies.