Feature: Introduce locale in web-widget SDK (#871)

* Introduce setLocale in SDK

Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
Pranav Raj S
2020-05-17 16:15:53 +05:30
committed by GitHub
parent 2e8cd59a06
commit 59f4dd7ebe
10 changed files with 67 additions and 13 deletions

View File

@@ -1,13 +1,26 @@
const sendMessage = content => ({
url: `/api/v1/widget/messages${window.location.search}`,
params: {
message: {
content,
timestamp: new Date().toString(),
referer_url: window.refererURL || '',
import Vue from 'vue';
const sendMessage = content => {
const locale = Vue.config.lang;
const refererURL = window.refererURL || '';
let search = window.location.search;
if (search) {
search = `${search}&locale=${locale}`;
} else {
search = `?locale=${locale}`;
}
return {
url: `/api/v1/widget/messages${search}`,
params: {
message: {
content,
timestamp: new Date().toString(),
referer_url: refererURL,
},
},
},
});
};
};
const sendAttachment = ({ attachment }) => {
const { refererURL = '' } = window;