|
| 1 | +function botSaidSomething(avatarInitials, text, timestamp) { |
| 2 | + return `Bot ${avatarInitials} zei; ${text}, ${xMinutesAgo(timestamp)}`; |
| 3 | +} |
| 4 | + |
| 5 | +function userSaidSomething(avatarInitials, text, timestamp) { |
| 6 | + return `Gebruiker ${avatarInitials} zei; ${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 'Zojuist'; |
| 24 | + } else if (deltaInMinutes === 1) { |
| 25 | + return 'Een minuut geleden'; |
| 26 | + } else if (deltaInHours < 1) { |
| 27 | + return `${deltaInMinutes} minuten geleden`; |
| 28 | + } else if (deltaInHours === 1) { |
| 29 | + return `Een uur geleden`; |
| 30 | + } else if (deltaInHours < 5) { |
| 31 | + return `${deltaInHours} uur geleden`; |
| 32 | + } else if (deltaInHours <= 24) { |
| 33 | + return `Vandaag`; |
| 34 | + } else if (deltaInHours <= 48) { |
| 35 | + return `Gisteren`; |
| 36 | + } else if (window.Intl) { |
| 37 | + return new Intl.DateTimeFormat('nl-NL').format(date); |
| 38 | + } else { |
| 39 | + return date.toLocaleString('nl-NL', { |
| 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: '', |
3 | | - // Do not localize {Retry}; it is a placeholder for "Retry". English translation should be, "Send failed. Retry." |
4 | | - SEND_FAILED_KEY: 'versturen mislukt, {Retry}.', |
5 | | - // SLOW_CONNECTION_NOTIFICATION: '', |
| 51 | + FAILED_CONNECTION_NOTIFICATION: 'Verbinding maken niet mogelijk.', |
| 52 | + SEND_FAILED_KEY: 'Versturen mislukt, {retry}.', |
| 53 | + SLOW_CONNECTION_NOTIFICATION: 'Verbinding maken duurt langer dan normaal…', |
6 | 54 | 'Chat': 'Chat', |
7 | | - // 'Download file': '', |
8 | | - // 'Microphone off': '', |
9 | | - // 'Microphone on': '', |
| 55 | + 'Download file': 'Bestand downloaden', |
| 56 | + 'Microphone off': 'Microfoon uit', |
| 57 | + 'Microphone on': 'Microfoon aan', |
10 | 58 | 'Listening…': 'Aan het luisteren…', |
11 | | - 'retry': 'opnieuw', |
12 | | - 'Retry': '{retry}', // Please alter this value if 'Retry' at the beginning of a sentence is written differently than at the end of a sentence. |
| 59 | + 'retry': 'probeer opnieuw', |
| 60 | + 'Retry': 'Opnieuw proberen', |
13 | 61 | 'Send': 'Verstuur', |
14 | 62 | 'Sending': 'versturen', |
15 | 63 | 'Speak': 'Spreek', |
16 | | - // 'Starting…': '', |
| 64 | + 'Starting…': 'Starten…', |
17 | 65 | 'Tax': 'BTW', |
18 | 66 | 'Total': 'Totaal', |
19 | 67 | 'Type your message': 'Typ je bericht', |
20 | 68 | 'Upload file': 'Bestand uploaden', |
21 | | - 'VAT': 'VAT' |
22 | | - // 'X minutes ago': |
| 69 | + 'VAT': 'VAT', |
| 70 | + 'X minutes ago': xMinutesAgo |
23 | 71 | } |
0 commit comments