Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Eslint #169

Merged
2 commits merged into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
9 changes: 9 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@darkskyapp",
"rules": {
"global-require": "off",
"max-len": "off",
"multiline-comment-style": ["error", "separate-lines"],
"no-unused-vars": ["error", {"args": "none"}]
}
}
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*.swp
.idea/
*.lock
*.log
node_modules
*.swp
.DS_Store
.idea/
/package-lock.json
build
.DS_Store
node_modules
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ const path = require("path");
const Translation = require("./lib/translation");

for(const pathname of fs.readdirSync(path.join(__dirname, "lib/lang"))) {
const match = /^([^\.].*)\.js$/.exec(pathname);
const match = /^([^.].*)\.js$/.exec(pathname);

if(match) {
exports[match[1]] = new Translation(Object.freeze(require("./lib/lang/" + pathname)));
const template = require("./lib/lang/" + pathname);
Object.freeze(template);
exports[match[1]] = new Translation(template);
}
}
14 changes: 7 additions & 7 deletions lib/lang/ar.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"use strict";

function join(a, b, joiner) {
return (a.slice(0, 4) === "يوم " && b.slice(0, 4) === "يوم " && joiner === " و ")
? "يومي " + a.slice(4) + joiner + b.slice(4)
: a + joiner + b;
return (a.slice(0, 4) === "يوم " && b.slice(0, 4) === "يوم " && joiner === " و ")
? "يومي " + a.slice(4) + joiner + b.slice(4)
: a + joiner + b;
}

function strip_prefix(period) {
return period.slice(0, 10) === "خلال الليل" ? period.slice(5) :
period.slice(0, 3) === "في " ? period.slice(3) :
period;
return period.slice(0, 10) === "خلال الليل" ? period.slice(5) :
period.slice(0, 3) === "في " ? period.slice(3) :
period;
}

module.exports = {
Expand Down Expand Up @@ -98,7 +98,7 @@ module.exports = {
"with": "$1 مع $2",
"range": "$1\u2013$2",
"parenthetical": function(a, b) {
return a + " (" + b + (a === "هطول أمطار وثلوج" ? " من الثلج)" : ")" );//a + " (" + b + ")";
return a + " (" + b + (a === "هطول أمطار وثلوج" ? " من الثلج)" : ")" );// a + " (" + b + ")";
},
"for-hour": "$1 لهذه الساعة",
"starting-in": "$1 تبدأ خلال $2",
Expand Down
10 changes: 5 additions & 5 deletions lib/lang/az.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ module.exports = {
"temperatures-rising": "$2 temperatur $1-yə qalxacaq",
"temperatures-valleying": "$2 hava kəskin soyuyacaq və temperatur $1-yə düşəcək",
"temperatures-falling": "$2 temperatur $1-yə düşəcək",
/* Capitalize the first letter of every word, except if that word is
* "and". (This is a very crude bastardization of proper English titling
* rules, but it is adequate for the purposes of this module.) */

// Capitalize the first letter of every word, except if that word is
// "and". (This is a very crude bastardization of proper English titling
// rules, but it is adequate for the purposes of this module.)
"title": str => str.replace(
/([a-zA-ZÇ窺IıƏəÖöĞğÜü.]+)/g,
/([a-zA-ZÇ窺IıƏəÖöĞğÜü.]+)/g,
txt => (txt === "və" || txt === "düym" || txt === "sm.")?
txt:
txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
Expand Down
16 changes: 7 additions & 9 deletions lib/lang/be.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
"use strict";

function join_with_shared_prefix(a, b, joiner) {
var m = a,
i = 0,
j;
let i = 0;

while(i !== m.length &&
while(i !== a.length &&
i !== b.length &&
m.charCodeAt(i) === b.charCodeAt(i))
a.charCodeAt(i) === b.charCodeAt(i))
++i;

while(i && m.charCodeAt(i - 1) !== 32)
while(i && a.charCodeAt(i - 1) !== 32)
--i;

return a + joiner + b.slice(i);
Expand Down Expand Up @@ -172,14 +170,14 @@ module.exports = {
word.charAt(0).toUpperCase() + word.slice(1);
});
},
/* Replace u with short u after vowels in the begnning of the words,
* capitalize the first word of the sentence and end with a period. */
// Replace u with short u after vowels in the begnning of the words,
// capitalize the first word of the sentence and end with a period.
"sentence": function(str) {
/* Replace u with short u after vowels in the begnning of the words */
str = str.replace(/[аеёіоуыэюя]\sу/gi, function(word) {
return word.slice(0, -1) + "ў";
});

/* Capitalize. */
str = str.charAt(0).toUpperCase() + str.slice(1);

Expand Down
20 changes: 9 additions & 11 deletions lib/lang/bg.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
"use strict";

function join_with_shared_prefix(a, b, joiner) {
var m = a,
i = 0,
j;
let i = 0;

while(i !== m.length &&
while(i !== a.length &&
i !== b.length &&
m.charCodeAt(i) === b.charCodeAt(i))
a.charCodeAt(i) === b.charCodeAt(i))
++i;

while(i && m.charCodeAt(i - 1) !== 32)
while(i && a.charCodeAt(i - 1) !== 32)
--i;

return a + joiner + b.slice(i);
Expand Down Expand Up @@ -114,7 +112,7 @@ module.exports = {
);
},
"through": function(a, b) {
//return join_with_shared_prefix(a, time2(b), " до ");
// return join_with_shared_prefix(a, time2(b), " до ");
return "от " + a + " до " + time2(b);
},
"with": "$1, с $2",
Expand All @@ -128,16 +126,16 @@ module.exports = {
"for-day": "$1 през целият ден",
"starting": "$1 започва $2",
"until": function(condition, time) {
//return condition + " до " + time2(time);
// return condition + " до " + time2(time);
return condition + " " + time;
},
"until-starting-again": function(condition, timeUntil, timeAgain){
//timeUntil = time2(timeUntil);
// timeUntil = time2(timeUntil);
return condition + " до " + timeUntil + ", започва отново " + timeAgain;
},
"starting-continuing-until": function(condition, timeFrom, timeTo) {
//timeFrom = time2(timeFrom);
//timeTo = time2(timeTo);
// timeFrom = time2(timeFrom);
// timeTo = time2(timeTo);
return condition + ", започва от " + timeFrom + ", до " + timeTo;
},
"during": function(condition, time) {
Expand Down
16 changes: 7 additions & 9 deletions lib/lang/bs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
"use strict";

function join_with_shared_prefix(a, b, joiner) {
var m = a,
i = 0,
j;
let i = 0;

while(i !== m.length &&
while(i !== a.length &&
i !== b.length &&
m.charCodeAt(i) === b.charCodeAt(i))
a.charCodeAt(i) === b.charCodeAt(i))
++i;

while(i && m.charCodeAt(i - 1) !== 32)
while(i && a.charCodeAt(i - 1) !== 32)
--i;

return a + joiner + b.slice(i);
Expand Down Expand Up @@ -121,9 +119,9 @@ module.exports = {
"temperatures-rising": "temperaturom raste do $1 $2",
"temperatures-valleying": "temperaturom najniže do $1 $2",
"temperatures-falling": "temperaturom pada do $1 $2",
/* Capitalize the first letter of every word, except if that word is
* "and". (This is a very crude bastardization of proper English titling
* rules, but it is adequate for the purposes of this module.) */
// Capitalize the first letter of every word, except if that word is
// "and". (This is a very crude bastardization of proper English titling
// rules, but it is adequate for the purposes of this module.)
"title": function(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
},
Expand Down
10 changes: 4 additions & 6 deletions lib/lang/ca.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
"use strict";

function join_with_shared_prefix(a, b, joiner) {
var m = a,
i = 0,
j;
let i = 0;

while(i !== m.length &&
while(i !== a.length &&
i !== b.length &&
m.charCodeAt(i) === b.charCodeAt(i))
a.charCodeAt(i) === b.charCodeAt(i))
++i;

while(i && m.charCodeAt(i - 1) !== 32)
while(i && a.charCodeAt(i - 1) !== 32)
--i;

return a + joiner + b.slice(i);
Expand Down
Loading