How to translate Graddit rating widget to any language
Graddit rating widget supports two languages: english and russian. That is defined by sending "eng" or "rus" parameter to server (read more). Of course, it doesn't look very good when your website is on any different language. Let's see how we can solve this issue using the most popular widget (yellow stars) code as an example. Here's the initial code:
<b:if cond='data:blog.pageType != "static_page"'>
<div expr:id='"labels_" + data:post.id' style='display: none; visibility: hidden;'>
<b:if cond='data:post.labels'>
<b:loop values='data:post.labels' var='label'><data:label.name/>,</b:loop>
</b:if>
</div> Rate this posting:
<div expr:id='data:post.id' style='padding-left: 3px; padding-right: 3px; display: inline; visibility: hidden;'>{[['<img src="http://img.graddit.com/img/star.png"/>']]}</div>
<script expr:src='"http://graddit.com/rate/eng/5/" + data:post.id + "?stats=" + data:post.id + "&info=info-" + data:post.id + "&info_delay=2&class_star=ffbs_star_img&class_star_set=ffbs_star_img_set&class_star_vote=ffbs_star_img_vote&views=yes&id=" + data:post.id + "&url=" + data:post.url + "&labels=labels_" + data:post.id + ""' type='text/javascript'/>
</b:if>
Bold text is the div element we are going to change. In addition to what you see there now it can contain the following data attributes:
See how it differs from the default one below.
<b:if cond='data:blog.pageType != "static_page"'>
<div expr:id='"labels_" + data:post.id' style='display: none; visibility: hidden;'>
<b:if cond='data:post.labels'>
<b:loop values='data:post.labels' var='label'><data:label.name/>,</b:loop>
</b:if>
</div> Rate this posting:
<div expr:id='data:post.id' style='padding-left: 3px; padding-right: 3px; display: inline; visibility: hidden;'>{[['<img src="http://img.graddit.com/img/star.png"/>']]}</div>
<script expr:src='"http://graddit.com/rate/eng/5/" + data:post.id + "?stats=" + data:post.id + "&info=info-" + data:post.id + "&info_delay=2&class_star=ffbs_star_img&class_star_set=ffbs_star_img_set&class_star_vote=ffbs_star_img_vote&views=yes&id=" + data:post.id + "&url=" + data:post.url + "&labels=labels_" + data:post.id + ""' type='text/javascript'/>
</b:if>
Bold text is the div element we are going to change. In addition to what you see there now it can contain the following data attributes:
- data-label-votes - text for "votes";
- data-label-views - text for "views";
- data-label-rating - text for "rating"'
- data-label-info-rating - text for ratings in popup with detailed votes information.
Check this example to understand it better. The following code (with average=yes parameter added to display rating number):
<b:if cond='data:blog.pageType != "static_page"'>
<div expr:id='"labels_" + data:post.id' style='display: none; visibility: hidden;'>
<b:if cond='data:post.labels'>
<b:loop values='data:post.labels' var='label'><data:label.name/>,</b:loop>
</b:if>
</div> Rate this posting:
<div data-label-votes='voted: ' data-label-views='viewed: ' data-label-rating='rated at: ' data-label-info-rating='Details' expr:id='data:post.id' style='padding-left: 3px; padding-right: 3px; display: inline; visibility: hidden;'>{[['<img src="http://img.graddit.com/img/star.png"/>']]}</div>
<script expr:src='"http://graddit.com/rate/eng/5/" + data:post.id + "?stats=" + data:post.id + "&info=info-" + data:post.id + "&info_delay=2&class_star=ffbs_star_img&class_star_set=ffbs_star_img_set&class_star_vote=ffbs_star_img_vote&views=yes&average=yes&id=" + data:post.id + "&url=" + data:post.url + "&labels=labels_" + data:post.id + ""' type='text/javascript'/>
</b:if>
Will display rating with custom labels:
<div expr:id='"labels_" + data:post.id' style='display: none; visibility: hidden;'>
<b:if cond='data:post.labels'>
<b:loop values='data:post.labels' var='label'><data:label.name/>,</b:loop>
</b:if>
</div> Rate this posting:
<div data-label-votes='voted: ' data-label-views='viewed: ' data-label-rating='rated at: ' data-label-info-rating='Details' expr:id='data:post.id' style='padding-left: 3px; padding-right: 3px; display: inline; visibility: hidden;'>{[['<img src="http://img.graddit.com/img/star.png"/>']]}</div>
<script expr:src='"http://graddit.com/rate/eng/5/" + data:post.id + "?stats=" + data:post.id + "&info=info-" + data:post.id + "&info_delay=2&class_star=ffbs_star_img&class_star_set=ffbs_star_img_set&class_star_vote=ffbs_star_img_vote&views=yes&average=yes&id=" + data:post.id + "&url=" + data:post.url + "&labels=labels_" + data:post.id + ""' type='text/javascript'/>
</b:if>
Will display rating with custom labels:
{[['']]}
See how it differs from the default one below.
0 komentar:
Posting Komentar