feat: Add i18n on whatsapp list button (#10852)

Fixes #10862

---------

Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
João Gabriel Franco
2025-06-11 23:19:36 -03:00
committed by GitHub
parent 0d05a07aa7
commit d52f4267ba
5 changed files with 29 additions and 27 deletions

View File

@@ -100,7 +100,7 @@ class Whatsapp::Providers::BaseService
rows = create_rows(message.content_attributes['items'])
section1 = { 'rows' => rows }
sections = [section1]
json_hash = { :button => 'Choose an item', 'sections' => sections }
json_hash = { :button => I18n.t('conversations.messages.whatsapp.list_button_label'), 'sections' => sections }
create_payload('list', message.outgoing_content, JSON.generate(json_hash))
end
end

View File

@@ -152,6 +152,8 @@ en:
instagram_story_content: '%{story_sender} mentioned you in the story: '
instagram_deleted_story_content: This story is no longer available.
deleted: This message was deleted
whatsapp:
list_button_label: 'Choose an item'
delivery_status:
error_code: 'Error code: %{error_code}'
activity:

View File

@@ -138,6 +138,8 @@ pt_BR:
instagram_story_content: '%{story_sender} mencionou você na conversa: '
instagram_deleted_story_content: Este Story não está mais disponível.
deleted: Esta mensagem foi excluída
whatsapp:
list_button_label: 'Escolha um item'
delivery_status:
error_code: 'Código de erro: %{error_code}'
activity:
@@ -213,7 +215,7 @@ pt_BR:
slack:
name: 'Slack'
short_description: 'Receba notificações e responda as conversas diretamente no Slack.'
description: "Integre Chatwoot com Slack para manter seu time em sincronia. Essa integração permite que você receba notificações de novas conversas e as responda diretamente na interface do Slack."
description: 'Integre Chatwoot com Slack para manter seu time em sincronia. Essa integração permite que você receba notificações de novas conversas e as responda diretamente na interface do Slack.'
webhooks:
name: 'Webhooks'
description: 'Eventos webhook fornecem atualizações sobre atividades em tempo real na sua conta Chatwoot. Você pode se inscrever em seus eventos preferidos, e o Chatwoot enviará as chamadas HTTP com as atualizações.'
@@ -224,7 +226,7 @@ pt_BR:
google_translate:
name: 'Tradutor do Google'
short_description: 'Traduzir automaticamente mensagens de clientes para agentes.'
description: "Integre o Google Tradutor para ajudar os agentes a traduzir facilmente as mensagens dos clientes. Esta integração detecta automaticamente o idioma e o converte para o idioma preferido do agente ou do administrador."
description: 'Integre o Google Tradutor para ajudar os agentes a traduzir facilmente as mensagens dos clientes. Esta integração detecta automaticamente o idioma e o converte para o idioma preferido do agente ou do administrador.'
openai:
name: 'OpenAI'
short_description: 'Sugestões, resumos e aprimoramento de mensagem e resposta com IA.'

View File

@@ -51,16 +51,15 @@ describe Whatsapp::Providers::Whatsapp360DialogService do
end
it 'calls message endpoints with list payload when number of items is greater than 3' do
items = %w[Burito Pasta Sushi Salad].map { |i| { title: i, value: i } }
message = create(:message, message_type: :outgoing, content: 'test', inbox: whatsapp_channel.inbox,
content_type: 'input_select',
content_attributes: {
items: [
{ title: 'Burito', value: 'Burito' },
{ title: 'Pasta', value: 'Pasta' },
{ title: 'Sushi', value: 'Sushi' },
{ title: 'Salad', value: 'Salad' }
]
})
content_type: 'input_select', content_attributes: { items: items })
expected_action = {
button: I18n.t('conversations.messages.whatsapp.list_button_label'),
sections: [{ rows: %w[Burito Pasta Sushi Salad].map { |i| { id: i, title: i } } }]
}.to_json
stub_request(:post, 'https://waba.360dialog.io/v1/messages')
.with(
body: {
@@ -70,9 +69,9 @@ describe Whatsapp::Providers::Whatsapp360DialogService do
body: {
text: 'test'
},
action: '{"button":"Choose an item","sections":[{"rows":[{"id":"Burito","title":"Burito"},' \
'{"id":"Pasta","title":"Pasta"},{"id":"Sushi","title":"Sushi"},{"id":"Salad","title":"Salad"}]}]}'
}, type: 'interactive'
action: expected_action
},
type: 'interactive'
}.to_json
).to_return(status: 200, body: whatsapp_response.to_json, headers: response_headers)
expect(service.send_message('+123456789', message)).to eq 'message_id'

View File

@@ -124,16 +124,15 @@ describe Whatsapp::Providers::WhatsappCloudService do
end
it 'calls message endpoints with list payload when number of items is greater than 3' do
items = %w[Burito Pasta Sushi Salad].map { |i| { title: i, value: i } }
message = create(:message, message_type: :outgoing, content: 'test', inbox: whatsapp_channel.inbox,
content_type: 'input_select',
content_attributes: {
items: [
{ title: 'Burito', value: 'Burito' },
{ title: 'Pasta', value: 'Pasta' },
{ title: 'Sushi', value: 'Sushi' },
{ title: 'Salad', value: 'Salad' }
]
})
content_type: 'input_select', content_attributes: { items: items })
expected_action = {
button: I18n.t('conversations.messages.whatsapp.list_button_label'),
sections: [{ rows: %w[Burito Pasta Sushi Salad].map { |i| { id: i, title: i } } }]
}.to_json
stub_request(:post, 'https://graph.facebook.com/v13.0/123456789/messages')
.with(
body: {
@@ -143,9 +142,9 @@ describe Whatsapp::Providers::WhatsappCloudService do
body: {
text: 'test'
},
action: '{"button":"Choose an item","sections":[{"rows":[{"id":"Burito","title":"Burito"},' \
'{"id":"Pasta","title":"Pasta"},{"id":"Sushi","title":"Sushi"},{"id":"Salad","title":"Salad"}]}]}'
}, type: 'interactive'
action: expected_action
},
type: 'interactive'
}.to_json
).to_return(status: 200, body: whatsapp_response.to_json, headers: response_headers)
expect(service.send_message('+123456789', message)).to eq 'message_id'