WordPress.org

Ready to get started?Download WordPress

Forums

WP Resume
[resolved] How to make WP Resume plugin multilingual with WPML (9 posts)

  1. Richard Vencu
    Member
    Posted 3 years ago #

    WPML takes care of all admin aspects. For the shortcode to properly work in the current language it is needed to filter out the non-current language sections. This can be done with this hack added to wp_resume.php

    // WPML doesn't filter get_terms directly (version WPML: 2.0.3 ; WP: 3.0.3)
    // This function will help exclude the non-current language terms when get_terms is called - therefore the resume sections.
    // Only works on pages specified within the function if enabled.
    add_filter( 'list_terms_exclusions', 'exclude_the_terms' );
    function exclude_the_terms($exclusions) {
     if (class_exists('SitePress')) {
       //if ( is_page( array ( 2017, 3000 ) ) ) {
           global $sitepress;
    
           $exclusions .= $sitepress->exclude_other_terms( '', array( 'taxonomy' => 'wp_resume_section' ) );
    
           return $exclusions;
       //}
     }
    }

    http://wordpress.org/extend/plugins/wp-resume/

  2. Ben Balter
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks for the heads up -- had no idea.
    I'll be sure this makes it into the next release.

  3. Ben Balter
    Member
    Plugin Author

    Posted 3 years ago #

    rvencu, I am looking over this post and your other post on WPML, I am not too familiar with the plugin, but do you have any suggestions on how to implement these changes without breaking the code for users who do not have that specific plugin enabled?

    Is this related?

  4. Richard Vencu
    Member
    Posted 3 years ago #

    Hi Benjamin,

    testing for WPML is done by this line

    if (class_exists('SitePress'))

    so to protect non-WPML users the above code should look like:

    add_filter( 'list_terms_exclusions', 'exclude_the_terms' );
    function exclude_the_terms($exclusions) {
     if (class_exists('SitePress')) { //if WPML we change the $exclusions
           global $sitepress;
           $exclusions .= $sitepress->exclude_other_terms( '', array( 'taxonomy' => 'wp_resume_section' ) );
     }
           return $exclusions;
    }
  5. Richard Vencu
    Member
    Posted 3 years ago #

    The i18n is related, of course. If you plan to make your plugin translatable you need to take care of your hardcoded strings by including them in gettext calls.

    The code in the other post on WPML should not break non-WPML users. WPML introduces a lot of filters on almost every aspect of WordPress so most of the queries return only current language results. The above get_terms() function is an exception this is why we need to filter it. However it is most probable if a new version of WPML will include this filter then we need to revert and delete this custom code.

    When integrating with other plugins (of whom WPML might not be aware) we need to take care and add such filters for the non-standard queries.

    Please take a look at wpml.org, I know they give free license of the commercial version for plugin developers so you can get your copy and your support access and play with it. In my opinion cooperating with such a plugin can only open the interest to non-English based WordPress users.

  6. Ben Balter
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks for all your help. I added the above function to the development version (1.6b). If you have a moment to grab the zip and try it out, any feedback would be greatly appreciated.

  7. Ben Balter
    Member
    Plugin Author

    Posted 3 years ago #

    I also added internationalization support if you would like to translate the backend as well. You can grab the POT file from the plugin itself, and WordPress has some instructions on the process

  8. Richard Vencu
    Member
    Posted 3 years ago #

    Hi,

    I might be slow in checking the beta. I need to re-setup my dev site first.

    I know how to localize, I will check this too,

    Thanks,
    Richard

  9. Richard Vencu
    Member
    Posted 3 years ago #

    I setup another test site I got and all seems fine so far. On the localization job please review this kind of translations

    //Custom post type labels array
    	$labels = array(
        'name' => _x('Positions', 'post type general name'),
        'singular_name' => _x('Resume Position', 'post type singular name'),
        'add_new' => __('Add New Position'),
        'add_new_item' => __('Add New Position'),
        'edit_item' => __('Edit Position'),
        'new_item' => __('New Position'),
        'view_item' => __('View Position'),
        'search_items' => __('Search Positions'),
        'not_found' =>  __('No Positions Found'),
        'not_found_in_trash' => __('No Positions Found in Trash'),
        'parent_item_colon' => '',
        'menu_name' => 'Resume',
      );

    I think they need to be translated against your textdomain as well.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic