Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions jquery.readingTime.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
;(function ($, window, document, undefined) {

var pluginName = "readingTime";


var available_lang = new Array('en', 'fr');

var text_lang = {
'en' :
{'min_left': ' minutes left',
'thanks': 'Thanks for reading',
'end_reading': 'Less than a minute'},
'fr' :
{'min_left': ' minutes restantes',
'thanks': 'Merci d\'avoir lu mon article',
'end_reading': 'Moins d\'une minute'}
};

var defaults = {
bubble: '#scrollbubble'
bubble: '#scrollbubble',
lang: 'en'
};

function Plugin(element, options) {
Expand All @@ -24,6 +38,7 @@
updateTime: function () {
var total_reading_time = 0,
bubble = $(this.options.bubble),
lang = ( -1 != $.inArray(this.options.lang, available_lang)) ? this.options.lang : available_lang[0],
post_content = $(this.element);
var viewportHeight = $(window).height(),
scrollbarHeight = viewportHeight / $(document).height() * viewportHeight,
Expand All @@ -34,11 +49,11 @@
var text = '';

if(total_reading_time_remaining > 1) {
text = total_reading_time_remaining + ' minutes left';
text = total_reading_time_remaining + text_lang[lang].min_left;
} else if(progress >= 1) {
text = 'Thanks for reading';
text = text_lang[lang].thanks;
} else if (total_reading_time_remaining <= 1) {
text = 'Less than a minute';
text = text_lang[lang].end_reading;
}

bubble
Expand Down