Skip to content

Commit b5379ce

Browse files
committed
Do not use 'this' in translate.js
'this' is not defined when not installing the plugin on Vue. Fix Polyconseil#113 (comment)
1 parent 5df121e commit b5379ce

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/translate.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let _config = {
1111
}
1212
let _translations = {}
1313

14-
export default {
14+
const translate = {
1515

1616
/*
1717
* Get the translated string from the translation.json file generated by easygettext.
@@ -118,7 +118,7 @@ export default {
118118
* @return {String} The translated string
119119
*/
120120
'gettext': function (msgid) {
121-
return this.getTranslation(msgid)
121+
return translate.getTranslation(msgid)
122122
},
123123

124124
/*
@@ -131,7 +131,7 @@ export default {
131131
* @return {String} The translated string
132132
*/
133133
'pgettext': function (context, msgid) {
134-
return this.getTranslation(msgid, 1, context)
134+
return translate.getTranslation(msgid, 1, context)
135135
},
136136

137137
/*
@@ -146,7 +146,7 @@ export default {
146146
* @return {String} The translated string
147147
*/
148148
'ngettext': function (msgid, plural, n) {
149-
return this.getTranslation(msgid, n, null, plural)
149+
return translate.getTranslation(msgid, n, null, plural)
150150
},
151151

152152
/*
@@ -162,7 +162,7 @@ export default {
162162
* @return {String} The translated string
163163
*/
164164
'npgettext': function (context, msgid, plural, n) {
165-
return this.getTranslation(msgid, n, context, plural)
165+
return translate.getTranslation(msgid, n, context, plural)
166166
},
167167

168168
/*
@@ -183,3 +183,5 @@ export default {
183183
},
184184

185185
}
186+
187+
export default translate

0 commit comments

Comments
 (0)