Hvis du har noen flere spørsmål. Vennligst ta kontakt med oss igjen.
`, 26 | MessageCanvasTrayButton: `Start en ny chat`, 27 | InputPlaceHolder: `Skriv melding`, 28 | Today: `I dag`, 29 | Yesterday: `I går`, 30 | WelcomeMessage: `Velkommen til kundesupport`, 31 | SendMessageTooltip: `Send melding`, 32 | AttachFileImageTooltip: `Legg til fil`, 33 | Read: `Lest`, 34 | FieldValidationRequiredField: `Ugyldig innhold`, 35 | Save: 'Lagre', 36 | AttachFileInvalidSize: 'Filen er for stor. Maks størrelse: 10MB', 37 | AttachFileInvalidType: `Ugyldig filtype`, 38 | Connecting: 'Kobler til', 39 | Disconnected: 'Kobler fra', 40 | TypingIndicator: '{{name}} skriver...' 41 | }; 42 | 43 | const notificationBlocked: MultiLangText = { 44 | en: 'Notifications are blocked by the browser', 45 | no: 'Varsler er blokkert i nettleseren', 46 | }; 47 | 48 | const notificationAllowed: MultiLangText = { 49 | en: 'Notifications are enabled', 50 | no: 'Varsler er skrudd på', 51 | }; 52 | 53 | const notificationToggle: MultiLangText = { 54 | en: 'Enable notifications', 55 | no: 'Skru på varsler', 56 | }; 57 | 58 | const notificationSettings: MultiLangText = { 59 | en: 'This can be reset by clicking the lock icon next to the URL.', 60 | no: 'Endre ved å trykke på hengelåsikonet i adresselinjefeltet.', 61 | }; 62 | 63 | export default { 64 | entryPointLabel, 65 | predefinedMessage, 66 | norwegianUiTranslation, 67 | notificationBlocked, 68 | notificationAllowed, 69 | notificationToggle, 70 | notificationSettings, 71 | preEngagementFormMessage, 72 | }; 73 | -------------------------------------------------------------------------------- /src/assets/translationLanguages.ts: -------------------------------------------------------------------------------- 1 | export const languageNameFromCode = (code: string): string => { 2 | switch (code) { 3 | case 'fr-FR': 4 | return 'French / Française'; 5 | case 'es-ES': 6 | return 'Spanish / Español'; 7 | case 'it-IT': 8 | return 'Italian / Italiano'; 9 | case 'ja-JP': 10 | return 'Japanese / 日本語'; 11 | case 'de-DE': 12 | return 'German / Deutsch'; 13 | case 'en-US': 14 | return 'English'; 15 | case 'nb-NO': 16 | return 'Norwegian / Norsk'; 17 | default: 18 | return `Unknown: ${code}`; 19 | } 20 | }; 21 | 22 | export const generateLanguages = (preferredLanguage: string) => { 23 | const allowedLanguages: string[] = [ 24 | 'en-US', 25 | 'es-ES', 26 | 'it-IT', 27 | 'nb-NO', 28 | ]; 29 | 30 | return allowedLanguages 31 | .sort((a, b) => languageNameFromCode(a).localeCompare(languageNameFromCode(b))) 32 | .map((code) => ({ 33 | value: code, 34 | label: languageNameFromCode(code), 35 | selected: allowedLanguages.includes(preferredLanguage) 36 | ? code === preferredLanguage 37 | : code === 'en-US', 38 | })); 39 | }; 40 | -------------------------------------------------------------------------------- /src/components/FlexChat.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import { 3 | Manager, 4 | EntryPoint, 5 | MainHeader, 6 | MessagingCanvas, 7 | ContextProvider, 8 | RootContainer, 9 | MessageBubble, 10 | Actions, 11 | MainContainer, 12 | } from '@twilio/flex-webchat-ui'; 13 | import chatConfigBase from '../config/chat/chatAppConfig'; 14 | import logo from '../assets/logo.png'; 15 | import FlexChatLoading from './FlexChatLoading'; 16 | import { ManagerState, FlexChatProps } from '../interfaces/FlexChat'; 17 | import { faExclamationCircle } from '@fortawesome/free-solid-svg-icons'; 18 | import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; 19 | import Loader from '../assets/loader.svg'; 20 | import { version } from '../../package.json'; 21 | 22 | import '../styles/FlexChatError.css'; 23 | import '../styles/header.css'; 24 | import MessageBubbleHeader from './MessageBubbleHeader'; 25 | import initActions from '../config/chat/customActions'; 26 | import useChatActions from '../hooks/useChatActions'; 27 | import NotificationButton from './NotificationButton'; 28 | import Texts, { translateText } from '../assets/texts'; 29 | import TranslationBubbleBody from './TranslationBubbleBody'; 30 | import TranslationInfoHeader from './TranslationInfoHeader'; 31 | import useTranslation from '../hooks/useTranslation'; 32 | import { v4 as uuidv4 } from 'uuid'; 33 | 34 | const defaultManagerState = { 35 | loading: false, 36 | manager: undefined, 37 | error: undefined, 38 | }; 39 | 40 | const FlexChat: React.FCError Initializing Chat
268 |Laster inn Chat
:Loading Chat
} 278 |{text}
56 |94 | {getTranslation()?.text || message?.source?.state?.body || message?.source?.body} 95 |
96 | {!message.isFromMe && (message?.source?.state || message?.source?.body) && ( 97 |17 | Automatic translation, errors may occur. 18 |
19 |