Skip to content

Commit

Permalink
Adding English language
Browse files Browse the repository at this point in the history
  • Loading branch information
koval01 committed Dec 1, 2023
1 parent 9f135cc commit 2d53ac5
Show file tree
Hide file tree
Showing 6 changed files with 526 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/app/res/language/en/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import library from "./library"
import strings from "./strings"

export {
library,
strings,
}
5 changes: 5 additions & 0 deletions src/app/res/language/en/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"code": "en",
"name": "English",
"author": "Yaroslav Koval"
}
22 changes: 22 additions & 0 deletions src/app/res/language/en/library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default class LanguageLibrary {
// [number, numbers, numbers] [minute, minutes, minutes]
static plural(data, { number = 1 } = {}) {
number = Math.abs(number)
if (Math.floor(number) !== number) return data[1]
return data[
// eslint-disable-next-line no-nested-ternary
(number % 10 === 1 && number % 100 !== 11) ? 0
: number % 10 >= 2
&& number % 10 <= 4
&& (number % 100 < 10 || number % 100 >= 20) ? 1 : 2
]
}

static replace(data, { replace = {} } = {}) {
Object.keys(replace).forEach((key) => {
data = data.replace(RegExp(`{%${key}}`, "gi"), replace[key].toString())
})

return data
}
}
Loading

0 comments on commit 2d53ac5

Please sign in to comment.