Fix missing translations, enable dutch language (#878)
* Fix missing translations, enable dutch language
This commit is contained in:
@@ -13,11 +13,12 @@
|
||||
|
||||
<script>
|
||||
import GroupedAvatars from 'widget/components/GroupedAvatars.vue';
|
||||
import { getAvailableAgentsText } from 'widget/helpers/utils';
|
||||
import agentMixin from '../mixins/agentMixin';
|
||||
|
||||
export default {
|
||||
name: 'AvailableAgents',
|
||||
components: { GroupedAvatars },
|
||||
mixins: [agentMixin],
|
||||
props: {
|
||||
agents: {
|
||||
type: Array,
|
||||
@@ -37,7 +38,7 @@ export default {
|
||||
}));
|
||||
},
|
||||
title() {
|
||||
return getAvailableAgentsText(this.agents);
|
||||
return this.getAvailableAgentsText(this.agents);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { getAvailableAgentsText } from '../utils';
|
||||
|
||||
describe('#getAvailableAgentsText', () => {
|
||||
it('returns the correct text is there is only one online agent', () => {
|
||||
expect(getAvailableAgentsText([{ name: 'Pranav' }])).toEqual(
|
||||
'Pranav is available'
|
||||
);
|
||||
});
|
||||
|
||||
it('returns the correct text is there are two online agents', () => {
|
||||
expect(
|
||||
getAvailableAgentsText([{ name: 'Pranav' }, { name: 'Nithin' }])
|
||||
).toEqual('Pranav and Nithin are available');
|
||||
});
|
||||
|
||||
it('returns the correct text is there are more than two online agents', () => {
|
||||
expect(
|
||||
getAvailableAgentsText([
|
||||
{ name: 'Pranav' },
|
||||
{ name: 'Nithin' },
|
||||
{ name: 'Subin' },
|
||||
{ name: 'Sojan' },
|
||||
])
|
||||
).toEqual('Pranav and 3 others are available');
|
||||
});
|
||||
});
|
||||
@@ -17,20 +17,3 @@ export const IFrameHelper = {
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const getAvailableAgentsText = (agents = []) => {
|
||||
const count = agents.length;
|
||||
if (count === 1) {
|
||||
const [agent] = agents;
|
||||
return `${agent.name} is available`;
|
||||
}
|
||||
|
||||
if (count === 2) {
|
||||
const [first, second] = agents;
|
||||
return `${first.name} and ${second.name} are available`;
|
||||
}
|
||||
|
||||
const [agent] = agents;
|
||||
const rest = agents.length - 1;
|
||||
return `${agent.name} and ${rest} others are available`;
|
||||
};
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
"SUBMIT": "إرسال"
|
||||
}
|
||||
},
|
||||
"AGENT_AVAILABILITY": {
|
||||
"IS_AVAILABLE": "is available",
|
||||
"ARE_AVAILABLE": "are available",
|
||||
"OTHERS_ARE_AVAILABLE": "others are available",
|
||||
"AND": "and"
|
||||
},
|
||||
"POWERED_BY": "مدعوم بواسطة Chatwoot",
|
||||
"EMAIL_PLACEHOLDER": "الرجاء إدخال بريدك الإلكتروني",
|
||||
"CHAT_PLACEHOLDER": "أكتب رسالتك"
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
"SUBMIT": "sotmetre's"
|
||||
}
|
||||
},
|
||||
"AGENT_AVAILABILITY": {
|
||||
"IS_AVAILABLE": "està disponible",
|
||||
"ARE_AVAILABLE": "estan disponibles",
|
||||
"OTHERS_ARE_AVAILABLE": "altres estan disponibles",
|
||||
"AND": "i"
|
||||
},
|
||||
"POWERED_BY": "Desenvolupat per Chatwoot",
|
||||
"EMAIL_PLACEHOLDER": "Introduïu el vostre correu electrònic",
|
||||
"CHAT_PLACEHOLDER": "Escriu el teu missatge"
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
"SUBMIT": "Submit"
|
||||
}
|
||||
},
|
||||
"AGENT_AVAILABILITY": {
|
||||
"IS_AVAILABLE": "ist verfügbar",
|
||||
"ARE_AVAILABLE": "sind verfügbar",
|
||||
"OTHERS_ARE_AVAILABLE": "andere sind verfügbar",
|
||||
"AND": "und"
|
||||
},
|
||||
"POWERED_BY": "Unterstützt von Chatwoot",
|
||||
"EMAIL_PLACEHOLDER": "Bitte geben Sie ihre E-Mail-Adresse ein",
|
||||
"CHAT_PLACEHOLDER": "Geben Sie Ihre Nachricht ein"
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
"SUBMIT": "Καταχώρηση"
|
||||
}
|
||||
},
|
||||
"AGENT_AVAILABILITY": {
|
||||
"IS_AVAILABLE": "είναι διαθέσιμο",
|
||||
"ARE_AVAILABLE": "είναι διαθέσιμα",
|
||||
"OTHERS_ARE_AVAILABLE": "άλλοι είναι διαθέσιμοι",
|
||||
"AND": "και"
|
||||
},
|
||||
"POWERED_BY": "με την δύναμη του Chatwoot",
|
||||
"EMAIL_PLACEHOLDER": "Παρακαλώ εισάγετε το email σας",
|
||||
"CHAT_PLACEHOLDER": "Πληκτρολογήστε το μήνυμά σας"
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
"SUBMIT": "Submit"
|
||||
}
|
||||
},
|
||||
"AGENT_AVAILABILITY": {
|
||||
"IS_AVAILABLE": "is available",
|
||||
"ARE_AVAILABLE": "are available",
|
||||
"OTHERS_ARE_AVAILABLE": "others are available",
|
||||
"AND": "and"
|
||||
},
|
||||
"POWERED_BY": "Powered by Chatwoot",
|
||||
"EMAIL_PLACEHOLDER": "Please enter your email",
|
||||
"CHAT_PLACEHOLDER": "Type your message"
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
"SUBMIT": "Envoyer"
|
||||
}
|
||||
},
|
||||
"AGENT_AVAILABILITY": {
|
||||
"IS_AVAILABLE": "est disponible",
|
||||
"ARE_AVAILABLE": "sont disponibles",
|
||||
"OTHERS_ARE_AVAILABLE": "autres sont disponibles",
|
||||
"AND": "et"
|
||||
},
|
||||
"POWERED_BY": "Propulsé par Chatwoot",
|
||||
"EMAIL_PLACEHOLDER": "Veuillez saisir votre adresse de courriel",
|
||||
"CHAT_PLACEHOLDER": "Tapez votre message"
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
"SUBMIT": "Bevestigen"
|
||||
}
|
||||
},
|
||||
"AGENT_AVAILABILITY": {
|
||||
"IS_AVAILABLE": "is beschikbaar",
|
||||
"ARE_AVAILABLE": "zijn beschikbaar",
|
||||
"OTHERS_ARE_AVAILABLE": "anderen zijn beschikbaar",
|
||||
"AND": "en"
|
||||
},
|
||||
"POWERED_BY": "Mogelijk gemaakt door Chatwoot",
|
||||
"EMAIL_PLACEHOLDER": "Voer uw e-mailadres in",
|
||||
"CHAT_PLACEHOLDER": "Typ uw bericht"
|
||||
|
||||
24
app/javascript/widget/mixins/agentMixin.js
Normal file
24
app/javascript/widget/mixins/agentMixin.js
Normal file
@@ -0,0 +1,24 @@
|
||||
export default {
|
||||
methods: {
|
||||
getAvailableAgentsText(agents) {
|
||||
const count = agents.length;
|
||||
if (count === 1) {
|
||||
const [agent] = agents;
|
||||
return `${agent.name} ${this.$t('AGENT_AVAILABILITY.IS_AVAILABLE')}`;
|
||||
}
|
||||
|
||||
if (count === 2) {
|
||||
const [first, second] = agents;
|
||||
return `${first.name} ${this.$t('AGENT_AVAILABILITY.AND')} ${
|
||||
second.name
|
||||
} ${this.$t('AGENT_AVAILABILITY.ARE_AVAILABLE')}`;
|
||||
}
|
||||
|
||||
const [agent] = agents;
|
||||
const rest = agents.length - 1;
|
||||
return `${agent.name} ${this.$t(
|
||||
'AGENT_AVAILABILITY.AND'
|
||||
)} ${rest} ${this.$t('AGENT_AVAILABILITY.OTHERS_ARE_AVAILABLE')}`;
|
||||
},
|
||||
},
|
||||
};
|
||||
49
app/javascript/widget/mixins/specs/agentMixin.spec.js
Normal file
49
app/javascript/widget/mixins/specs/agentMixin.spec.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import { createWrapper } from '@vue/test-utils';
|
||||
import agentMixin from '../agentMixin';
|
||||
import Vue from 'vue';
|
||||
|
||||
const translations = {
|
||||
'AGENT_AVAILABILITY.IS_AVAILABLE': 'is available',
|
||||
'AGENT_AVAILABILITY.ARE_AVAILABLE': 'are available',
|
||||
'AGENT_AVAILABILITY.OTHERS_ARE_AVAILABLE': 'others are available',
|
||||
'AGENT_AVAILABILITY.AND': 'and',
|
||||
};
|
||||
|
||||
const TestComponent = {
|
||||
render() {},
|
||||
title: 'TestComponent',
|
||||
mixins: [agentMixin],
|
||||
methods: {
|
||||
$t(key) {
|
||||
return translations[key];
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
describe('agentMixin', () => {
|
||||
test('returns correct text', () => {
|
||||
const Constructor = Vue.extend(TestComponent);
|
||||
const vm = new Constructor().$mount();
|
||||
const wrapper = createWrapper(vm);
|
||||
|
||||
expect(wrapper.vm.getAvailableAgentsText([{ name: 'Pranav' }])).toEqual(
|
||||
'Pranav is available'
|
||||
);
|
||||
|
||||
expect(
|
||||
wrapper.vm.getAvailableAgentsText([
|
||||
{ name: 'Pranav' },
|
||||
{ name: 'Nithin' },
|
||||
])
|
||||
).toEqual('Pranav and Nithin are available');
|
||||
|
||||
expect(
|
||||
wrapper.vm.getAvailableAgentsText([
|
||||
{ name: 'Pranav' },
|
||||
{ name: 'Nithin' },
|
||||
{ name: 'Subin' },
|
||||
{ name: 'Sojan' },
|
||||
])
|
||||
).toEqual('Pranav and 3 others are available');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user