Skip to content

Commit

Permalink
fix: replace var ~> const || let
Browse files Browse the repository at this point in the history
  • Loading branch information
TiagoDanin committed Apr 23, 2019
1 parent f583c62 commit 72a7efa
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const gettextParser = require('gettext-parser')
const fs = require('fs')
const path = require('path')

var defaultLang, translations, prefix, suffix, regex
let defaultLang, translations, prefix, suffix, regex

class Resources {
constructor (options) {
Expand All @@ -28,8 +28,8 @@ class Resources {
}

load (lang, resourceFile) {
var fileRaw = fs.readFileSync(path.resolve(resourceFile))
var po = gettextParser.po.parse(fileRaw)
const fileRaw = fs.readFileSync(path.resolve(resourceFile))
const po = gettextParser.po.parse(fileRaw)
translations[lang] = po.translations['']
translations[lang][''][''] = {
msgid: '',
Expand All @@ -55,7 +55,7 @@ class Translation {

getTranslation (msgid) {
msgid = msgid.toString()
var translation = translations[this.lang][msgid] || {
const translation = translations[this.lang][msgid] || {
msgid: msgid,
comments: {},
msgstr: [msgid]
Expand All @@ -67,10 +67,10 @@ class Translation {
}

getMsgid (str, exp) {
var n = 0
let n = 0
if (str.reduce && exp) {
return str.reduce((total, current, index) => {
var select = `${prefix}${n}${suffix}`
let select = `${prefix}${n}${suffix}`
n++
if (exp[index] === undefined) {
select = ''
Expand All @@ -82,8 +82,8 @@ class Translation {
}

_ (str, ...exp) {
var msgid = this.getMsgid(str, exp)
var msgstr = this.getTranslation(msgid).msgstr
const msgid = this.getMsgid(str, exp)
const msgstr = this.getTranslation(msgid).msgstr
if (str.reduce && exp) {
return msgstr.toString().replace(regex, (match, key) => {
return exp[Number(key)]
Expand All @@ -93,17 +93,17 @@ class Translation {
}

msgid (str, ...exp) {
var msgid = this.getMsgid(str, exp)
const msgid = this.getMsgid(str, exp)
return this.getTranslation(msgid)
}

msgstr (str, ...exp) {
var msgid = this.getMsgid(str, exp)
const msgid = this.getMsgid(str, exp)
return this.getTranslation(msgid).msgstr
}

comments (str, ...exp) {
var msgid = this.getMsgid(str, exp)
const msgid = this.getMsgid(str, exp)
return this.getTranslation(msgid).comments
}
}
Expand Down

0 comments on commit 72a7efa

Please sign in to comment.