|
| 1 | +function botSaidSomething(avatarInitials, text, timestamp) { |
| 2 | + return `Bot ${avatarInitials} sa, ${text}, ${xMinutesAgo(timestamp)}`; |
| 3 | +} |
| 4 | + |
| 5 | +function userSaidSomething(avatarInitials, text, timestamp) { |
| 6 | + return `Användare ${avatarInitials} sa, ${text}, ${xMinutesAgo(timestamp)}`; |
| 7 | +} |
| 8 | + |
| 9 | +function xMinutesAgo(dateStr) { |
| 10 | + const date = new Date(dateStr); |
| 11 | + const dateTime = date.getTime(); |
| 12 | + |
| 13 | + if (isNaN(dateTime)) { |
| 14 | + return dateStr; |
| 15 | + } |
| 16 | + |
| 17 | + const now = Date.now(); |
| 18 | + const deltaInMs = now - dateTime; |
| 19 | + const deltaInMinutes = Math.floor(deltaInMs / 60000); |
| 20 | + const deltaInHours = Math.floor(deltaInMs / 3600000); |
| 21 | + |
| 22 | + if (deltaInMinutes < 1) { |
| 23 | + return 'Alldeles nyss'; |
| 24 | + } else if (deltaInMinutes === 1) { |
| 25 | + return 'För en minut sen'; |
| 26 | + } else if (deltaInHours < 1) { |
| 27 | + return `${deltaInMinutes} minuter sedan`; |
| 28 | + } else if (deltaInHours === 1) { |
| 29 | + return `En timme sen`; |
| 30 | + } else if (deltaInHours < 5) { |
| 31 | + return `${deltaInHours} timmar sen`; |
| 32 | + } else if (deltaInHours <= 24) { |
| 33 | + return `Idag`; |
| 34 | + } else if (deltaInHours <= 48) { |
| 35 | + return `Igår`; |
| 36 | + } else if (window.Intl) { |
| 37 | + return new Intl.DateTimeFormat('sv-SE').format(date); |
| 38 | + } else { |
| 39 | + return date.toLocaleString('sv-SE', { |
| 40 | + day: '2-digit', |
| 41 | + hour: '2-digit', |
| 42 | + hour12: false, |
| 43 | + minute: '2-digit', |
| 44 | + month: '2-digit', |
| 45 | + year: 'numeric' |
| 46 | + }); |
| 47 | + } |
| 48 | +} |
| 49 | + |
1 | 50 | export default { |
2 | | - // FAILED_CONNECTION_NOTIFICATION: '', |
| 51 | + FAILED_CONNECTION_NOTIFICATION: 'Kunde inte ansluta.', |
3 | 52 | // Do not localize {Retry}; it is a placeholder for "Retry". English translation should be, "Send failed. Retry." |
4 | 53 | SEND_FAILED_KEY: 'kunde inte skicka, {Retry}.', |
5 | | - // SLOW_CONNECTION_NOTIFICATION: '', |
| 54 | + SLOW_CONNECTION_NOTIFICATION: 'Det tar längre än vanligt att ansluta.', |
| 55 | + 'Bot said something': botSaidSomething, |
| 56 | + 'User said something': userSaidSomething, |
| 57 | + 'X minutes ago': xMinutesAgo, |
| 58 | + // '[File of type '%1']': '[File of type '%1']", |
| 59 | + // '[Unknown Card '%1']': '[Unknown Card '%1']', |
| 60 | + 'Adaptive Card parse error': 'Adaptive Card parse error', |
| 61 | + 'Adaptive Card render error': 'Adaptive Card render error', |
6 | 62 | 'Chat': 'Chatt', |
7 | | - // 'Microphone off': '', |
8 | | - // 'Microphone on': '', |
| 63 | + 'Download file': 'Ladda ned fil', |
| 64 | + 'Microphone off': 'Mikrofon av', |
| 65 | + 'Microphone on': 'Mikrofon på', |
| 66 | + 'Left': 'Vänster', |
9 | 67 | 'Listening…': 'Lyssnar…', |
10 | | - // 'Download file': '', |
| 68 | + 'New messages': 'Nya meddelanden', |
| 69 | + 'Right': 'Höger', |
11 | 70 | 'retry': 'försök igen', |
12 | 71 | 'Retry': '{retry}', // Please alter this value if 'Retry' at the beginning of a sentence is written differently than at the end of a sentence. |
13 | 72 | 'Send': 'Skicka', |
14 | | - 'Sending': 'skickar', |
15 | | - // 'Speak': '', |
16 | | - // 'Starting…': '', |
| 73 | + 'Sending': 'Skickar', |
| 74 | + 'Speak': 'Läs upp', |
| 75 | + 'Starting…': 'Startar…', |
17 | 76 | 'Tax': 'Skatt', |
18 | 77 | 'Total': 'Totalt', |
19 | | - 'Type your message': 'Skriv ett meddelande', |
20 | | - // 'Upload file': '', |
| 78 | + 'Type your message': 'Skriv ditt meddelande', |
| 79 | + 'Upload file': 'Ladd upp fil', |
21 | 80 | 'VAT': 'Moms' |
22 | | - // 'X minutes ago': |
23 | | -} |
| 81 | +}; |
| 82 | + |
0 commit comments