@@ -1191,14 +1191,26 @@ export class ChatwootService {
11911191 await waInstance . connectToWhatsapp ( number ) ;
11921192 } else {
11931193 this . logger . verbose ( 'whatsapp already connected' ) ;
1194- await this . createBotMessage ( instance , `🚨 ${ body . inbox . name } instance is connected.` , 'incoming' ) ;
1194+ await this . createBotMessage (
1195+ instance ,
1196+ i18next . t ( 'cw.inbox.alreadyConnected' , {
1197+ inboxName : body . inbox . name ,
1198+ } ) ,
1199+ 'incoming' ,
1200+ ) ;
11951201 }
11961202 }
11971203
11981204 if ( command === 'clearcache' ) {
11991205 this . logger . verbose ( 'command clearcache found' ) ;
12001206 waInstance . clearCacheChatwoot ( ) ;
1201- await this . createBotMessage ( instance , `✅ ${ body . inbox . name } instance cache cleared.` , 'incoming' ) ;
1207+ await this . createBotMessage (
1208+ instance ,
1209+ i18next . t ( 'cw.inbox.clearCache' , {
1210+ inboxName : body . inbox . name ,
1211+ } ) ,
1212+ 'incoming' ,
1213+ ) ;
12021214 }
12031215
12041216 if ( command === 'status' ) {
@@ -1208,19 +1220,34 @@ export class ChatwootService {
12081220
12091221 if ( ! state ) {
12101222 this . logger . verbose ( 'state not found' ) ;
1211- await this . createBotMessage ( instance , `⚠️ ${ body . inbox . name } instance not found.` , 'incoming' ) ;
1223+ await this . createBotMessage (
1224+ instance ,
1225+ i18next . t ( 'cw.inbox.notFound' , {
1226+ inboxName : body . inbox . name ,
1227+ } ) ,
1228+ 'incoming' ,
1229+ ) ;
12121230 }
12131231
12141232 if ( state ) {
12151233 this . logger . verbose ( 'state: ' + state + ' found' ) ;
1216- await this . createBotMessage ( instance , `⚠️ ${ body . inbox . name } instance status: *${ state } *` , 'incoming' ) ;
1234+ await this . createBotMessage (
1235+ instance ,
1236+ i18next . t ( 'cw.inbox.status' , {
1237+ inboxName : body . inbox . name ,
1238+ state : state ,
1239+ } ) ,
1240+ 'incoming' ,
1241+ ) ;
12171242 }
12181243 }
12191244
12201245 if ( command === 'disconnect' || command === 'desconectar' ) {
12211246 this . logger . verbose ( 'command disconnect found' ) ;
12221247
1223- const msgLogout = `🚨 Disconnecting Whatsapp from inbox *${ body . inbox . name } *: ` ;
1248+ const msgLogout = i18next . t ( 'cw.inbox.disconnect' , {
1249+ inboxName : body . inbox . name ,
1250+ } ) ;
12241251
12251252 this . logger . verbose ( 'send message to chatwoot' ) ;
12261253 await this . createBotMessage ( instance , msgLogout , 'incoming' ) ;
@@ -1509,27 +1536,17 @@ export class ChatwootService {
15091536 const latitude = result . degreesLatitude ;
15101537 const longitude = result . degreesLongitude ;
15111538
1512- const locationName = result ?. name || 'Unknown' ;
1513- const locationAddress = result ?. address || 'Unknown' ;
1539+ const locationName = result ?. name ;
1540+ const locationAddress = result ?. address ;
15141541
15151542 const formattedLocation =
1516- '*Localização:*\n\n' +
1517- '_Latitude:_ ' +
1518- latitude +
1519- '\n' +
1520- '_Longitude:_ ' +
1521- longitude +
1522- '\n' +
1523- '_Nome:_ ' +
1524- locationName +
1525- '\n' +
1526- '_Endereço:_ ' +
1527- locationAddress +
1528- '\n' +
1529- '_Url:_ https://www.google.com/maps/search/?api=1&query=' +
1530- latitude +
1531- ',' +
1532- longitude ;
1543+ `*${ i18next . t ( 'cw.locationMessage.location' ) } :*\n\n` +
1544+ `_${ i18next . t ( 'cw.locationMessage.latitude' ) } :_ ${ latitude } \n` +
1545+ `_${ i18next . t ( 'cw.locationMessage.longitude' ) } :_ ${ longitude } \n` +
1546+ ( locationName ? `_${ i18next . t ( 'cw.locationMessage.locationName' ) } :_ ${ locationName } \n` : '' ) +
1547+ ( locationAddress ? `_${ i18next . t ( 'cw.locationMessage.locationAddress' ) } :_ ${ locationAddress } \n` : '' ) +
1548+ `_${ i18next . t ( 'cw.locationMessage.locationUrl' ) } :_ ` +
1549+ `https://www.google.com/maps/search/?api=1&query=${ latitude } ,${ longitude } ` ;
15331550
15341551 this . logger . verbose ( 'message content: ' + formattedLocation ) ;
15351552
@@ -1547,17 +1564,19 @@ export class ChatwootService {
15471564 }
15481565 } ) ;
15491566
1550- let formattedContact = '*Contact:*\n\n' + '_Name:_ ' + contactInfo [ 'FN' ] ;
1567+ let formattedContact =
1568+ `*${ i18next . t ( 'cw.contactMessage.contact' ) } :*\n\n` +
1569+ `_${ i18next . t ( 'cw.contactMessage.name' ) } :_ ${ contactInfo [ 'FN' ] } ` ;
15511570
15521571 let numberCount = 1 ;
15531572 Object . keys ( contactInfo ) . forEach ( ( key ) => {
15541573 if ( key . startsWith ( 'item' ) && key . includes ( 'TEL' ) ) {
15551574 const phoneNumber = contactInfo [ key ] ;
1556- formattedContact += '\n_Number (' + numberCount + ' ):_ ' + phoneNumber ;
1575+ formattedContact += `\n_ ${ i18next . t ( 'cw.contactMessage.number' ) } ( ${ numberCount } ):_ ${ phoneNumber } ` ;
15571576 numberCount ++ ;
15581577 } else if ( key . includes ( 'TEL' ) ) {
15591578 const phoneNumber = contactInfo [ key ] ;
1560- formattedContact += '\n_Number (' + numberCount + ' ):_ ' + phoneNumber ;
1579+ formattedContact += `\n_ ${ i18next . t ( 'cw.contactMessage.number' ) } ( ${ numberCount } ):_ ${ phoneNumber } ` ;
15611580 numberCount ++ ;
15621581 }
15631582 } ) ;
@@ -1578,17 +1597,19 @@ export class ChatwootService {
15781597 }
15791598 } ) ;
15801599
1581- let formattedContact = '*Contact:*\n\n' + '_Name:_ ' + contact . displayName ;
1600+ let formattedContact = `*${ i18next . t ( 'cw.contactMessage.contact' ) } :*\n\n_${ i18next . t (
1601+ 'cw.contactMessage.name' ,
1602+ ) } :_ ${ contact . displayName } `;
15821603
15831604 let numberCount = 1 ;
15841605 Object . keys ( contactInfo ) . forEach ( ( key ) => {
15851606 if ( key . startsWith ( 'item' ) && key . includes ( 'TEL' ) ) {
15861607 const phoneNumber = contactInfo [ key ] ;
1587- formattedContact += '\n_Number (' + numberCount + ' ):_ ' + phoneNumber ;
1608+ formattedContact += `\n_ ${ i18next . t ( 'cw.contactMessage.number' ) } ( ${ numberCount } ):_ ${ phoneNumber } ` ;
15881609 numberCount ++ ;
15891610 } else if ( key . includes ( 'TEL' ) ) {
15901611 const phoneNumber = contactInfo [ key ] ;
1591- formattedContact += '\n_Number (' + numberCount + ' ):_ ' + phoneNumber ;
1612+ formattedContact += `\n_ ${ i18next . t ( 'cw.contactMessage.number' ) } ( ${ numberCount } ):_ ${ phoneNumber } ` ;
15921613 numberCount ++ ;
15931614 }
15941615 } ) ;
@@ -2074,7 +2095,10 @@ export class ChatwootService {
20742095 return ;
20752096 }
20762097
2077- const msgStatus = `⚡️ Instance status ${ inbox . name } : ${ data . status } ` ;
2098+ const msgStatus = i18next . t ( 'cw.inbox.status' , {
2099+ inboxName : inbox . name ,
2100+ state : data . status ,
2101+ } ) ;
20782102
20792103 this . logger . verbose ( 'send message to chatwoot' ) ;
20802104 await this . createBotMessage ( instance , msgStatus , 'incoming' ) ;
@@ -2086,7 +2110,7 @@ export class ChatwootService {
20862110 if ( body . status === 'open' ) {
20872111 // if we have qrcode count then we understand that a new connection was established
20882112 if ( this . waMonitor . waInstances [ instance . instanceName ] . qrCode . count > 0 ) {
2089- const msgConnection = `🚀 Connection successfully established!` ;
2113+ const msgConnection = i18next . t ( 'cw.inbox.connected' ) ;
20902114 this . logger . verbose ( 'send message to chatwoot' ) ;
20912115 await this . createBotMessage ( instance , msgConnection , 'incoming' ) ;
20922116 this . waMonitor . waInstances [ instance . instanceName ] . qrCode . count = 0 ;
@@ -2147,7 +2171,7 @@ export class ChatwootService {
21472171 return ;
21482172 }
21492173
2150- this . createBotMessage ( instance , `💬 Starting to import messages. Please wait...` , 'incoming' ) ;
2174+ this . createBotMessage ( instance , i18next . t ( 'cw.import.startImport' ) , 'incoming' ) ;
21512175 }
21522176
21532177 public isImportHistoryAvailable ( ) {
@@ -2180,7 +2204,7 @@ export class ChatwootService {
21802204 return ;
21812205 }
21822206
2183- this . createBotMessage ( instance , '💬 Importing messages. More one moment...' , 'incoming' ) ;
2207+ this . createBotMessage ( instance , i18next . t ( 'cw.import.importingMessages' ) , 'incoming' ) ;
21842208
21852209 const totalMessagesImported = await chatwootImport . importHistoryMessages (
21862210 instance ,
@@ -2191,10 +2215,10 @@ export class ChatwootService {
21912215 this . updateContactAvatarInRecentConversations ( instance ) ;
21922216
21932217 const msg = Number . isInteger ( totalMessagesImported )
2194- ? ` ${ totalMessagesImported } messages imported. Refresh page to see the new messages`
2195- : `Something went wrong in importing messages` ;
2218+ ? i18next . t ( 'cw.import.messagesImported' , { totalMessagesImported } )
2219+ : i18next . t ( 'cw.import.messagesException' ) ;
21962220
2197- this . createBotMessage ( instance , `💬 ${ msg } ` , 'incoming' ) ;
2221+ this . createBotMessage ( instance , msg , 'incoming' ) ;
21982222
21992223 return totalMessagesImported ;
22002224 }
0 commit comments