WordPress.org

Ready to get started?Download WordPress

Forums

Comment Rating Field Plugin
[resolved] Multi language site (5 posts)

  1. Marco Chiesi
    Member
    Posted 2 years ago #

    I wanted to use this plugin in a multi language site, but unfortunately it doesn't support localization (even if there are really few strings). So I made some hacks in the js file to let it be multi lingual, but it would be nice if it had supported natively. Thanks.

    http://wordpress.org/extend/plugins/comment-rating-field-plugin/

  2. n7 Studios
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Marco,

    If you'd like this to be included in the plugin, send through the changes you've made and I'll merge these into the next release.

    Thanks,

    Tim.

  3. Marco Chiesi
    Member
    Posted 2 years ago #

    Hello,
    There are two strings that needs localization (at least for the frontend side), both are set in file jquery.rating.settings.js:
    - "Rating"
    - "Cancel rating"
    The latter should be added as a parameter 'cancel' to the jquery rating plugin initialization.
    The recommended way for javascript localization is described here in the codex.

    Here's the JS code:

    jQuery(document).ready(function($) {
        if ($('form#commentform textarea[name=comment]').length > 0) {
            $('form#commentform textarea[name=comment]').after('<p><label for="rating-star">' + crfpL10n.rating + '</label><input name="rating-star" type="radio" class="star" value="1" /><input name="rating-star" type="radio" class="star" value="2" /><input name="rating-star" type="radio" class="star" value="3" /><input name="rating-star" type="radio" class="star" value="4" /><input name="rating-star" type="radio" class="star" value="5" /><input type="hidden" name="crfp-rating" value="0" /></p>');
        	$('input.star').rating({cancel: crfpL10n.cancel_rating}); // Invoke rating plugin
        	$('div.star-rating a').bind('click', function(e) { $('input[name=crfp-rating]').val($(this).html()); }); // Stores rating in hidden field ready for POST
        	$('div.rating-cancel a').bind('click', function(e) { $('input[name=crfp-rating]').val('0'); }); // Stores rating in hidden field ready for POST
    	}
    });

    and here's the PHP code:

    ...
    wp_enqueue_script('crfp-jquery-rating-settings');
    wp_localize_script( 'crfp-jquery-rating-settings', 'crfpL10n', array(
    	'rating' => __( 'Rating' ),
    	'cancel_rating' => __( 'Cancel Rating' )
    ) );

    Note: the above code is to be tested.

  4. n7 Studios
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Marco,

    Options have been added to 1.4 to allow the rating field to be defined.

    All strings within the Administration Panels have been set for localisation, although no translations are provided as yet.

    Hope that helps.

    Tim.

  5. Marco Chiesi
    Member
    Posted 2 years ago #

    Hi Tim,
    thank you very much for this update, I'll try it as soon as possible.
    I think I should be able to provide an italian translation for the plugin in the near future.
    Cheers,
    Marco

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic