我已经vue-fb-customer-chat
在我的NuxtJS网站上成功安装了该插件,并且聊天正常。
这是一个多语言网站,我需要能够以正确的语言(该nuxt-i18n
模块的当前语言环境)加载聊天记录。可以的,如果在从网站内部切换语言后聊天不更改其语言,则可以,但是我希望至少在页面加载时使用正确的语言。
这是plugins/vue-fb-customer-chat.js
文件的内容:
import Vue from 'vue'
import VueFbCustomerChat from 'vue-fb-customer-chat'
Vue.use(VueFbCustomerChat, {
page_id: null, // change 'null' to your Facebook Page ID,
theme_color: '#845e5c', // theme color in HEX
locale: 'fr_FR', // default 'en_US'
})
没有下列作品:
context.app.i18n.locale
this.$i18n.locale
$i18n.locale
解决该问题的方法是什么?
预先感谢你的帮助。
我的同事回答了我的问题。
import Vue from 'vue'
import VueFbCustomerChat from 'vue-fb-customer-chat'
export default function (context) {
const locale = context.app.i18n.locale;
const iso = context.app.i18n.locales.find(l => l.code === locale).iso;
Vue.use(VueFbCustomerChat, {
page_id: null, // change 'null' to your Facebook Page ID,
theme_color: '#845e5c', // theme color in HEX
locale: iso.replace('-', '_'), // default 'en_US'
})
}