Skip to content

Instantly share code, notes, and snippets.

@jorinvo
Last active November 12, 2015 05:18

Revisions

  1. jorinvo revised this gist Nov 12, 2015. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  2. jorinvo created this gist Nov 12, 2015.
    33 changes: 33 additions & 0 deletions en.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    module.exports = {
    emptyDoc: 'Write …',
    search: 'Search …',
    footer: 'write lite, open source',
    share: 'share',
    open: 'open',
    modified: 'modified',
    welcome: require('./welcome.txt'),
    secondsAgo: function (x) {
    if (x === 1) return 'a second ago';
    return x + ' seconds ago';
    },
    minutesAgo: function (x) {
    if (x === 1) return 'a minute ago';
    return x + ' minutes ago';
    },
    hoursAgo: function (x) {
    if (x === 1) return 'an hour ago';
    return x + ' hours ago';
    },
    daysAgo: function (x) {
    if (x === 1) return 'a day ago';
    return x + ' days ago';
    },
    monthsAgo: function (x) {
    if (x === 1) return 'a month ago';
    return x + ' months ago';
    },
    yearsAgo: function (x) {
    if (x === 1) return 'a year ago';
    return x + ' years ago';
    }
    };
    30 changes: 30 additions & 0 deletions untitled
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    function plural(word, num) {
    var forms = word.split('_');
    return num === 1 ? forms[0] : forms[1];
    }

    module.exports = {
    emptyDoc: 'Write …',
    search: 'Search …',
    footer: 'write lite, open source',
    share: 'share',
    open: 'open',
    modified: 'modified',
    welcome: require('./welcome.txt'),
    timeAgo: function relativeTimeWithPlural(number, key) {
    var format = {
    'ss': 'second_seconds',
    'mm': 'minute_minutes',
    'hh': 'hour_hours',
    'dd': 'day_days',
    'MM': 'month_months',
    'yy': 'year_years'
    };
    if (number === 1) {
    return 'a ' + plural(format[key], +number) + ' ago';
    }
    else {
    return number + ' ' + plural(format[key], +number) + ' ago';
    }
    }
    };