Merge pull request #125 from charliewang95/users/charlwan/locale
Update locale export
This commit is contained in:
Коммит
077d17c22a
|
@ -4,16 +4,16 @@ const locale = require('../../src/utils/locale');
|
|||
describe('Locales', () => {
|
||||
it('locale.getLocaleStringFromId() should return correctly', () => {
|
||||
expect(locale.getLocaleStringFromId("1033")).toBe("en-us");
|
||||
expect(locale.getLocaleStringFromId(1033)).toBe("");
|
||||
expect(locale.getLocaleStringFromId("1133")).toBe("");
|
||||
expect(locale.getLocaleStringFromId(1033)).toBe("en-us");
|
||||
expect(locale.getLocaleStringFromId("1133")).toBe("en-us");
|
||||
expect(locale.getLocaleStringFromId("1058")).toBe("uk-ua");
|
||||
expect(locale.getLocaleStringFromId("")).toBe("");
|
||||
expect(locale.getLocaleStringFromId("")).toBe("en-us");
|
||||
});
|
||||
|
||||
it('locale.getLocaleIdFromString() should return correctly', () => {
|
||||
expect(locale.getLocaleIdFromString("en-us")).toBe("1033");
|
||||
expect(locale.getLocaleIdFromString("en-uus")).toBe("");
|
||||
expect(locale.getLocaleIdFromString("")).toBe("");
|
||||
expect(locale.getLocaleIdFromString("en-uus")).toBe("1033");
|
||||
expect(locale.getLocaleIdFromString("")).toBe("1033");
|
||||
expect(locale.getLocaleIdFromString("zh-cn")).toBe("2052");
|
||||
});
|
||||
});
|
20
src/index.ts
20
src/index.ts
|
@ -1,14 +1,16 @@
|
|||
import {SDKProvider as OCSDKProvider, uuidv4 } from "@microsoft/ocsdk";
|
||||
import {SDKProvider as IC3SDKProvider} from '@microsoft/omnichannel-ic3core';
|
||||
import OmnichannelChatSDK from "./OmnichannelChatSDK";
|
||||
import {SDKProvider as OCSDKProvider, uuidv4} from "@microsoft/ocsdk";
|
||||
import { defaultLocaleId, defaultLocaleString, getLocaleIdFromString, getLocaleStringFromId } from "./utils/locale";
|
||||
import { isCustomerMessage, isSystemMessage } from "./utils/utilities";
|
||||
|
||||
import ChatSDKMessage from "./core/messaging/ChatSDKMessage";
|
||||
import DeliveryMode from "@microsoft/omnichannel-ic3core/lib/model/DeliveryMode";
|
||||
import {SDKProvider as IC3SDKProvider} from '@microsoft/omnichannel-ic3core';
|
||||
import IFileInfo from "@microsoft/omnichannel-ic3core/lib/interfaces/IFileInfo";
|
||||
import IRawMessage from "@microsoft/omnichannel-ic3core/lib/model/IRawMessage";
|
||||
import MessageContentType from "@microsoft/omnichannel-ic3core/lib/model/MessageContentType";
|
||||
import DeliveryMode from "@microsoft/omnichannel-ic3core/lib/model/DeliveryMode";
|
||||
import MessageType from "@microsoft/omnichannel-ic3core/lib/model/MessageType";
|
||||
import OmnichannelChatSDK from "./OmnichannelChatSDK";
|
||||
import PersonType from "@microsoft/omnichannel-ic3core/lib/model/PersonType";
|
||||
import IFileInfo from "@microsoft/omnichannel-ic3core/lib/interfaces/IFileInfo";
|
||||
import { isSystemMessage, isCustomerMessage } from "./utils/utilities";
|
||||
|
||||
export {
|
||||
OmnichannelChatSDK,
|
||||
|
@ -23,7 +25,11 @@ export {
|
|||
PersonType,
|
||||
IFileInfo,
|
||||
isSystemMessage,
|
||||
isCustomerMessage
|
||||
isCustomerMessage,
|
||||
getLocaleStringFromId,
|
||||
getLocaleIdFromString,
|
||||
defaultLocaleId,
|
||||
defaultLocaleString
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
|
@ -49,13 +49,14 @@ const localeList: any = { // eslint-disable-line @typescript-eslint/no-explicit-
|
|||
export const getLocaleStringFromId = (id: string): string => {
|
||||
const localeId = Object.keys(localeList).find(key => key === id);
|
||||
|
||||
return localeId ? localeList[localeId] : "";
|
||||
return localeId ? localeList[localeId] : defaultLocaleString;
|
||||
}
|
||||
|
||||
export const getLocaleIdFromString = (value: string): string => {
|
||||
const localeId = Object.keys(localeList).find(key => localeList[key] === value);
|
||||
|
||||
return localeId ?? "";
|
||||
return localeId ?? defaultLocaleId;
|
||||
}
|
||||
|
||||
export const defaultLocaleId = getLocaleIdFromString("en-us");
|
||||
export const defaultLocaleId = "1033";
|
||||
export const defaultLocaleString = "en-us";
|
Загрузка…
Ссылка в новой задаче