diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d78daa3ac..2eb61b0634 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Expand german locale by [@matmuenzel](https://github.com/matmuenzel) in PR [#1740](https://github.com/Microsoft/BotFramework-WebChat/pull/1740) - Update Russian and Japanese locale by [@corinagum](https://github.com/corinagum) in PR [#1747](https://github.com/Microsoft/BotFramework-WebChat/pull/1747) - Update Spanish by [@ckgrafico](https://github.com/ckgrafico) in PR [#1757](https://github.com/Microsoft/BotFramework-WebChat/pull/1757) +- Update Swedish by [@pekspro](https://github.com/pekspro) in PR [#1797](https://github.com/Microsoft/BotFramework-WebChat/pull/1797) ### Fixed - Fix [#1360](https://github.com/Microsoft/BotFramework-WebChat/issues/1360). Added `roles` to components of Web Chat, by [@corinagum](https://github.com/corinagum) in PR [#1462](https://github.com/Microsoft/BotFramework-WebChat/pull/1462) diff --git a/LOCALIZATION.md b/LOCALIZATION.md index b09b2e7d5a..063e6a7405 100644 --- a/LOCALIZATION.md +++ b/LOCALIZATION.md @@ -24,7 +24,7 @@ If you want to help to translate Web Chat to different language, please submit a | pt-br | @rcarubbi, @pedropacheco92| | pt-pt | | | ru-ru | @odysseus1973, @seaen | -| sv-se | | +| sv-se | @pekspro | | tr-tr | | | zh-hans | @Antimoney | | zh-hant | @compulim | diff --git a/packages/component/src/Localization/sv-SE.js b/packages/component/src/Localization/sv-SE.js index 3e536d6649..26341b9839 100644 --- a/packages/component/src/Localization/sv-SE.js +++ b/packages/component/src/Localization/sv-SE.js @@ -1,23 +1,82 @@ +function botSaidSomething(avatarInitials, text, timestamp) { + return `Bot ${avatarInitials} sa, ${text}, ${xMinutesAgo(timestamp)}`; +} + +function userSaidSomething(avatarInitials, text, timestamp) { + return `Användare ${avatarInitials} sa, ${text}, ${xMinutesAgo(timestamp)}`; +} + +function xMinutesAgo(dateStr) { + const date = new Date(dateStr); + const dateTime = date.getTime(); + + if (isNaN(dateTime)) { + return dateStr; + } + + const now = Date.now(); + const deltaInMs = now - dateTime; + const deltaInMinutes = Math.floor(deltaInMs / 60000); + const deltaInHours = Math.floor(deltaInMs / 3600000); + + if (deltaInMinutes < 1) { + return 'Alldeles nyss'; + } else if (deltaInMinutes === 1) { + return 'För en minut sen'; + } else if (deltaInHours < 1) { + return `${deltaInMinutes} minuter sedan`; + } else if (deltaInHours === 1) { + return `En timme sen`; + } else if (deltaInHours < 5) { + return `${deltaInHours} timmar sen`; + } else if (deltaInHours <= 24) { + return `Idag`; + } else if (deltaInHours <= 48) { + return `Igår`; + } else if (window.Intl) { + return new Intl.DateTimeFormat('sv-SE').format(date); + } else { + return date.toLocaleString('sv-SE', { + day: '2-digit', + hour: '2-digit', + hour12: false, + minute: '2-digit', + month: '2-digit', + year: 'numeric' + }); + } +} + export default { - // FAILED_CONNECTION_NOTIFICATION: '', + FAILED_CONNECTION_NOTIFICATION: 'Kunde inte ansluta.', // Do not localize {Retry}; it is a placeholder for "Retry". English translation should be, "Send failed. Retry." SEND_FAILED_KEY: 'kunde inte skicka, {Retry}.', - // SLOW_CONNECTION_NOTIFICATION: '', + SLOW_CONNECTION_NOTIFICATION: 'Det tar längre än vanligt att ansluta.', + 'Bot said something': botSaidSomething, + 'User said something': userSaidSomething, + 'X minutes ago': xMinutesAgo, + // '[File of type '%1']': '[File of type '%1']", + // '[Unknown Card '%1']': '[Unknown Card '%1']', + 'Adaptive Card parse error': 'Adaptive Card parse error', + 'Adaptive Card render error': 'Adaptive Card render error', 'Chat': 'Chatt', - // 'Microphone off': '', - // 'Microphone on': '', + 'Download file': 'Ladda ned fil', + 'Microphone off': 'Mikrofon av', + 'Microphone on': 'Mikrofon på', + 'Left': 'Vänster', 'Listening…': 'Lyssnar…', - // 'Download file': '', + 'New messages': 'Nya meddelanden', + 'Right': 'Höger', 'retry': 'försök igen', 'Retry': '{retry}', // Please alter this value if 'Retry' at the beginning of a sentence is written differently than at the end of a sentence. 'Send': 'Skicka', - 'Sending': 'skickar', - // 'Speak': '', - // 'Starting…': '', + 'Sending': 'Skickar', + 'Speak': 'Läs upp', + 'Starting…': 'Startar…', 'Tax': 'Skatt', 'Total': 'Totalt', - 'Type your message': 'Skriv ett meddelande', - // 'Upload file': '', + 'Type your message': 'Skriv ditt meddelande', + 'Upload file': 'Ladd upp fil', 'VAT': 'Moms' - // 'X minutes ago': -} +}; +