• Resolved Aurovrata Venet

    (@aurovrata)


    Dear David

    simply love the plugin. It’s so useful for manage so many photos.

    I run multi-language blog where we have a lot of photos from. We use the PolyLang plugin, a great tool to manage content in the different languages. Polylang is also compatible with WPML, a very robust plugin used by commercial wordpress sites.

    One of the functionality of Polylang is to allow translation of media content (allowing multiple language titles/captions/alt text… for each attachment post). This is managed using a taxonomy for languages.

    Question: how to integrate Polylang support in the MLA Assistant page?
    The MLA Assistant page (the best feature of MLA by far) allows Bulk edit of media meta data. I would really love to have the ability to set bulk translation facility into the Assistant dashboard. Basically allow the selection of the language in the Quick Edit section and define all the usual media attributes.

    As you can see from this discussion, this is a feature which has been request within PolyLang, but has not been solved as of today.

    I personally feel it would be a much more appropriate functionality to be integrate into MLA.

    Happy to contribute…

    I am happy to code this up, but I would appreciate some guidance as to which part of the plugin to look at.

    kind regards

    Vrata

    https://ww.wp.xz.cn/plugins/media-library-assistant/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for the positive MLA feedback and for your question. I appreciate the time you took to post links to the relevant support topics and discussions.

    I have done a bit of research, and I will try to set up a test Polylang site to try it out. In the interim, I was interested in your comment that “Polylang is also compatible with WPML“; can you say a bit more about that?

    I have done all the work required to make MLA compatible with WPML, but full support depends on some code they have added to “WPML Media”; I am told their code will be in the next update.

    Are you using WPML Media, or some media support in Polylang?

    You also wrote: “I am happy to code this up, but I would appreciate some guidance as to which part of the plugin to look at.” The Quick Edit and Bulk Edit support are contained in /includes/class-mla-list-table.php on the server side and in /js/mla-inline-edit-scripts.js. You are welcome to have a look if you are feeling ambitious.

    Thanks for your interest in the plugin. I will leave this topic unresolved while I look into Polylang support.

    Thread Starter Aurovrata Venet

    (@aurovrata)

    Hi David

    great to read you. Quick answer to your question:

    “Polylang is also compatible with WPML”; can you say a bit more about that?

    PolyLang implements a number of WPML API functions for Theme developers. We use a lot of themes from ElegantThemes.com for our work, and I noticed that they make use of WPML API calls to ensure compatibility for multi-language sites. Polylang is able to respond to those those calls too.

    Are you using WPML Media, or some media support in Polylang?

    No, currently I am not. PolyLang comes with Media support, but has an option in the Settings to switch off. By default it is on, and if you do not translate your media (and att.Category/Tag) then you see no media in your library when you switch language. A pain when you have 100s if not 1000s of photos.

    When you deploy PolyLang, you can set all the current content to a default language, including the media.

    Each translation creates a new post (for media post-type=attachment), but photos are not duplicated on disk.

    Contributing….
    I am a little short of time this week as I have some urgent work to finish this month. But I should have a little spare time next month and will be happy to start looking at the Quick Edit/Bulk Edit code part then. Do let me know if by then you have already got some beta code going, then I can start looking at too.

    Do you use GitHub for your plugin?

    PS:

    …I will try to set up a test Polylang site to try it out.

    I have written a post on our technical blog about usage of PolyLang plugin, you might want to take a look.

    Plugin Author David Lingren

    (@dglingren)

    I have set up a test site and populated it with a few posts and images. I have done a bit of experimentation with posts and images in two languages and am starting to think about your original question:

    The MLA Assistant page (the best feature of MLA by far) allows Bulk edit of media meta data. I would really love to have the ability to set bulk translation facility into the Assistant dashboard. Basically allow the selection of the language in the Quick Edit section and define all the usual media attributes.

    I think the best way to continue our dialog would be by e-mail; I will summarize our progress here when we have a solution. I have unblocked India from the FTJ site and you should be able to access it. If you can go to the Contact Us page and give me your contact information I will send you my e-mail address:

    Fair Trade Judaica/Contact Us

    I look forward to working with you on this effort. Thanks for you interest in the plugin.

    Thread Starter Aurovrata Venet

    (@aurovrata)

    Dear David

    Some observations about PolyLang wrt MLA:

    Is translation enabled for media?
    PolyLang allows the user to switch off the translation for media (a checkbox in the plugin settings page).
    – you can verify if this is the case with the polylang function,
    pll_is_translated_post_type(‘attachment’)

    – if media is not translated, then MLA needs to do nothing further.

    What happens when PolyLang translates media?

    – When a media file is translated in PolyLang, it duplicates the existing attachment post, allowing for the attachment title/alt text/caption/description to be translated. However, both are pointing to exactly the same media file.

    – the duplicate post is now associated with the original attachment post by inserting a new unique term to the post_translations taxonomy in the wordpress table,
    wp_insert_term($uniqueID_as_term, 'post_translations', array('description' => serialize(array( 'en'=>'<postID_en_trans>','jp'=>'postID_jp_trans' )) )
    Note how it makes use of the description field of the new term to store the serialised array containing the translation mapping.

    – it also register the above 2 post with the corresponding unique term,

    wp_set_object_terms(<postID_en_trans>, $uniqueID_as_term,'post_translations');

    The MLA plugin can reproduce all of the above by simply making a call on the API function pll_save_post_translations($arr) (see doc) to save the twined ‘attachment’ posts, by building the following array $arr:

    //let's say $def_post_id is the media attachment post ID we want to translate
    // first we check if there is already a translation
    $trans_post_id = pll_get_post($def_post_id, $trans_lang);
    // if $trans_post_id=null MLA duplicates the original post for user selected language $trans_lang slug (eg 'jp')
    $trans_post_id =... //duplicate attachment post id.
    $def_lang = pll_get_post_language($def_post_id,'slug');
    $arr = array( $def_lang => $def_post_id,
                  $trans_lang => $trans_post_id);
    pll_save_post_translations($arr);
    //polylang plugin will merge the new translated key with existing translations, so we don't need to worry about passing the previous translations)

    So MLA can pretty much do what it does so far, with the exception of adding a dropdown ‘language’ menu in the Quick-Edit box, and saving bulk media meta data set for selected language in the $trans_post_id attachment post, where each one is twined with its original language using the above piece of code.
    If for a given language there is already a post for that media, then the post needs to be updated rather than created.

    A list of languages can be obtained for the menu by calling the PolyLand function pll_languages_list(array('slug','name'));.

    Translating MLA Att.Category
    PolyLang allows for plugins to register strings to translate using the API function pll_register_string($pluginName, $string), so we could also look at allowing for the translation of media taxonomies. This would require the additional association of translated taxonomies with their default language (like the media post above), but it would also necessitate the association of translated media attachment post with its corresponding translated taxonomy.

    I would suggest that we leave this for another day, and set if we can get the MLA to manage translated media post for now.

    Your thoughts?

    kind regards

    Vrata

    Plugin Author David Lingren

    (@dglingren)

    Thank you for your update and all the additional information.

    Polylang support gives me a good “case study” for a project I’ve wanted to work on for some time. I have added 26 new hooks to the Media/Assistant submenu table code in MLA and developing Polylang support as a separate plugin that uses the hooks. When the work is complete I will include it in the /media-library-assistant/examples directory so anyone who needs the support can find it there.

    In the interim, I have your contact information and will work with you by e-mail to make sure the solution I develop satisfies the requirements you have outlined. Thanks for an interesting project opportunity!

    Plugin Author David Lingren

    (@dglingren)

    Thank you for working with me to develop and refine an example plugin that adds Polylang support to MLA. Although some refinements remain to be added, the version we have worked out so far is useful enough to be added to the MLA /examples directory.

    I have just uploaded an MLA Development Version (dated 20150426) that contains the current “PolyMLA” plugin /examples/mla-polylang-support.zip. Thanks for the good words and for your willingness to try the Development Version. To get the Development Version and add the PolyMLA plugin, follow these steps:

    1. Go to the Developers tab of the Media Library Assistant entry in the Repository.
    2. Scroll down to the “Other Versions” section and click “Development Version”.
    3. Download the ZIP archive to your computer, somewhere you can find it.
    4. Login to your site’s Admin area and navigate to Plugins/Installed Plugins.
    5. Find Media Library Assistant and deactivate it.
    6. Find Media Library Assistant and delete it. You will not lose any settings.
    7. Go to Plugins/Add New.
    8. Click “Upload Plugin”, to the right of the Add Plugins title.
    9. “Browse…” to the location of the ZIP Archive and click on it.
    10. Click “Install Now”, to the right of “Browse…”
    11. When the install completes, click “Activate Plugin” at the bottom of the screen.
    12. When the activation completes, scroll down to “Media Library Assistant” and look for a date like “20150426” at the start of the Description. That’s how you know you have a Development Version. You can also see the date in the heading of the Settings/Media Library Assistant submenu.

    To add the Polylang example plugin:

    1. Extract the mla-polylang-support.zip archive from the /examples/ directory within the Development Version archive file on your local system.
    2. Go to Plugins/Add New.
    3. Click “Upload Plugin”, to the right of the Add Plugins title.
    4. “Browse…” to the location of the mla-polylang-support.zip archive and click on it.
    5. Click “Install Now”, to the right of “Browse…”
    6. When the install completes, click “Activate Plugin” at the bottom of the screen.

    That’s it. I don’t change the version number of the Development Version, so you will be notified when the next official version comes out and the normal update process will continue to work.

    Let me know how the Development Version and the PolyMLA example plugin work for you.

    I will leave this topic unresolved until the example plugin goes out in the next MLA version. Thank you again for all your help with this project, which will be of use to other MLA users.

    Plugin Author David Lingren

    (@dglingren)

    Thank you for working with me offline to develop and test several Polylang fixes and enhancements.

    I have just uploaded a new Development Version dated 20150531 which has my “release candidate” version of the new Polylang support.

    This version integrates Polylang support into the MLA core plugin; the separate “PolyMLA” plugin is no longer required (or allowed).

    You can find step-by-step instructions for using the Development Version in this earlier topic:

    MLA errors when using plugin

    If you get a chance to try the latest Development Version, let me know if there are any problems or further work required. Thanks for your help on these important new features.

    Plugin Author David Lingren

    (@dglingren)

    I have released MLA version 2.11. It contains full Polylang support and does not need a separate plugin to provide the features you need.

    I am marking this topic resolved, but please update it if you have problems or further questions about Polylang support in MLA. Thanks for your interest in the plugin.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Multi-language WPML/Polyland plugin support’ is closed to new replies.