Skip to content

Commit db7e3ea

Browse files
committed
Fix runtime error
1 parent df5580c commit db7e3ea

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

nuxt-2/plugins/fluent-vue.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,29 @@ Vue.mixin({
2828
})
2929

3030
let currentLocale = 'en'
31-
Object.defineProperty(Vue.prototype, 'currentLocale', {
32-
get () {
33-
return currentLocale
34-
},
35-
36-
set (locale) {
37-
if (locale === 'en') {
38-
currentLocale = locale
39-
fluent.bundles = [enBundle]
40-
}
31+
if (!Object.hasOwnProperty.call(Vue.prototype, 'currentLocale')) {
32+
Object.defineProperty(Vue.prototype, 'currentLocale', {
33+
get () {
34+
return currentLocale
35+
},
36+
37+
set (locale) {
38+
if (locale === 'en') {
39+
currentLocale = locale
40+
fluent.bundles = [enBundle]
41+
}
42+
43+
if (locale === 'uk') {
44+
currentLocale = locale
45+
fluent.bundles = [ukBundle]
46+
}
4147

42-
if (locale === 'uk') {
43-
currentLocale = locale
44-
fluent.bundles = [ukBundle]
48+
// Not sure why this is needed with nuxt 2
49+
for (const component of components.keys()) {
50+
component.$forceUpdate()
51+
}
4552
}
46-
47-
// Not sure why this is needed with nuxt 2
48-
for (const component of components.keys()) {
49-
component.$forceUpdate()
50-
}
51-
}
52-
})
53+
})
54+
}
5355

5456
export const supportedLocales = [ 'en', 'uk' ]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy