mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-03 20:48:07 +00:00 
			
		
		
		
	fix: Update the translation for the text used in isTyping method (#10384)
				
					
				
			This fix consists of translating the message when another user is typing on the other side. --- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
		@@ -138,10 +138,9 @@ export default {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    typingUserNames() {
 | 
					    typingUserNames() {
 | 
				
			||||||
      const userList = this.typingUsersList;
 | 
					      const userList = this.typingUsersList;
 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (this.isAnyoneTyping) {
 | 
					      if (this.isAnyoneTyping) {
 | 
				
			||||||
        const userListAsName = getTypingUsersText(userList);
 | 
					        const [i18nKey, params] = getTypingUsersText(userList);
 | 
				
			||||||
        return userListAsName;
 | 
					        return this.$t(i18nKey, params);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return '';
 | 
					      return '';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,19 +27,20 @@ export const isJSONValid = value => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export const getTypingUsersText = (users = []) => {
 | 
					export const getTypingUsersText = (users = []) => {
 | 
				
			||||||
  const count = users.length;
 | 
					  const count = users.length;
 | 
				
			||||||
 | 
					  const [firstUser, secondUser] = users;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (count === 1) {
 | 
					  if (count === 1) {
 | 
				
			||||||
    const [user] = users;
 | 
					    return ['TYPING.ONE', { user: firstUser.name }];
 | 
				
			||||||
    return `${user.name} is typing`;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (count === 2) {
 | 
					  if (count === 2) {
 | 
				
			||||||
    const [first, second] = users;
 | 
					    return [
 | 
				
			||||||
    return `${first.name} and ${second.name} are typing`;
 | 
					      'TYPING.TWO',
 | 
				
			||||||
 | 
					      { user: firstUser.name, secondUser: secondUser.name },
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const [user] = users;
 | 
					  return ['TYPING.MULTIPLE', { user: firstUser.name, count: count - 1 }];
 | 
				
			||||||
  const rest = users.length - 1;
 | 
					 | 
				
			||||||
  return `${user.name} and ${rest} others are typing`;
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const createPendingMessage = data => {
 | 
					export const createPendingMessage = data => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,15 +8,16 @@ import {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
describe('#getTypingUsersText', () => {
 | 
					describe('#getTypingUsersText', () => {
 | 
				
			||||||
  it('returns the correct text is there is only one typing user', () => {
 | 
					  it('returns the correct text is there is only one typing user', () => {
 | 
				
			||||||
    expect(getTypingUsersText([{ name: 'Pranav' }])).toEqual(
 | 
					    expect(getTypingUsersText([{ name: 'Pranav' }])).toEqual([
 | 
				
			||||||
      'Pranav is typing'
 | 
					      'TYPING.ONE',
 | 
				
			||||||
    );
 | 
					      { user: 'Pranav' },
 | 
				
			||||||
 | 
					    ]);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('returns the correct text is there are two typing users', () => {
 | 
					  it('returns the correct text is there are two typing users', () => {
 | 
				
			||||||
    expect(
 | 
					    expect(
 | 
				
			||||||
      getTypingUsersText([{ name: 'Pranav' }, { name: 'Nithin' }])
 | 
					      getTypingUsersText([{ name: 'Pranav' }, { name: 'Nithin' }])
 | 
				
			||||||
    ).toEqual('Pranav and Nithin are typing');
 | 
					    ).toEqual(['TYPING.TWO', { user: 'Pranav', secondUser: 'Nithin' }]);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('returns the correct text is there are more than two users are typing', () => {
 | 
					  it('returns the correct text is there are more than two users are typing', () => {
 | 
				
			||||||
@@ -27,7 +28,7 @@ describe('#getTypingUsersText', () => {
 | 
				
			|||||||
        { name: 'Subin' },
 | 
					        { name: 'Subin' },
 | 
				
			||||||
        { name: 'Sojan' },
 | 
					        { name: 'Sojan' },
 | 
				
			||||||
      ])
 | 
					      ])
 | 
				
			||||||
    ).toEqual('Pranav and 3 others are typing');
 | 
					    ).toEqual(['TYPING.MULTIPLE', { user: 'Pranav', count: 3 }]);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -335,5 +335,10 @@
 | 
				
			|||||||
    "ORIGINAL_CONTENT": "Original Content",
 | 
					    "ORIGINAL_CONTENT": "Original Content",
 | 
				
			||||||
    "TRANSLATED_CONTENT": "Translated Content",
 | 
					    "TRANSLATED_CONTENT": "Translated Content",
 | 
				
			||||||
    "NO_TRANSLATIONS_AVAILABLE": "No translations are available for this content"
 | 
					    "NO_TRANSLATIONS_AVAILABLE": "No translations are available for this content"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "TYPING": {
 | 
				
			||||||
 | 
					    "ONE": "{user} is typing",
 | 
				
			||||||
 | 
					    "TWO": "{user} and {secondUser} are typing",
 | 
				
			||||||
 | 
					    "MULTIPLE": "{user} and {count} others are typing"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -335,5 +335,10 @@
 | 
				
			|||||||
    "ORIGINAL_CONTENT": "Conteúdo original",
 | 
					    "ORIGINAL_CONTENT": "Conteúdo original",
 | 
				
			||||||
    "TRANSLATED_CONTENT": "Conteúdo traduzido",
 | 
					    "TRANSLATED_CONTENT": "Conteúdo traduzido",
 | 
				
			||||||
    "NO_TRANSLATIONS_AVAILABLE": "Nenhuma tradução está disponível para este conteúdo"
 | 
					    "NO_TRANSLATIONS_AVAILABLE": "Nenhuma tradução está disponível para este conteúdo"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "TYPING": {
 | 
				
			||||||
 | 
					    "ONE": "{user} está digitando",
 | 
				
			||||||
 | 
					    "TWO": "{user} e {secondUser} estão digitando",
 | 
				
			||||||
 | 
					    "MULTIPLE": "{user} e {count} outros estão digitando"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user