WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] [closed] Translation works in NextGen albums, but not in galleries (6 posts)

  1. grgbyny
    Member
    Posted 11 months ago #

    Hello,

    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!

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 11 months ago #

    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

    EDIT:
    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.

  3. grgbyny
    Member
    Posted 11 months ago #

    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.

  4. Chouby
    Member
    Plugin Author

    Posted 11 months ago #

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

  5. grgbyny
    Member
    Posted 11 months ago #

    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!

  6. Chouby
    Member
    Plugin Author

    Posted 11 months ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic