Skip to content

Commit 497b54f

Browse files
committed
feat: translate automations
1 parent 9d18d3d commit 497b54f

File tree

9 files changed

+193
-85
lines changed

9 files changed

+193
-85
lines changed

frontend/src/features/admin/automation/ActionBox.vue

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@update:modelValue="(value) => handleFieldChange(value, index)"
1717
>
1818
<SelectTrigger class="m-auto">
19-
<SelectValue placeholder="Select action" />
19+
<SelectValue :placeholder="t('form.field.selectAction')" />
2020
</SelectTrigger>
2121
<SelectContent>
2222
<SelectGroup>
@@ -40,7 +40,7 @@
4040
<SelectTag
4141
v-model="action.value"
4242
:items="tagsStore.tagNames.map((tag) => ({ label: tag, value: tag }))"
43-
placeholder="Select tag"
43+
:placeholder="t('form.field.selectTag')"
4444
/>
4545
</div>
4646

@@ -51,7 +51,7 @@
5151
<ComboBox
5252
v-model="action.value[0]"
5353
:items="conversationActions[action.type]?.options"
54-
placeholder="Select"
54+
:placeholder="t('form.field.select')"
5555
@select="handleValueChange($event, index)"
5656
>
5757
<template #item="{ item }">
@@ -75,7 +75,7 @@
7575
{{ selected.emoji }}
7676
<span>{{ selected.label }}</span>
7777
</div>
78-
<span v-else>Select team</span>
78+
<span v-else>{{ $t('form.field.selectTeam') }}</span>
7979
</div>
8080

8181
<div v-else-if="action.type === 'assign_user'" class="flex items-center gap-2">
@@ -91,10 +91,10 @@
9191
</Avatar>
9292
<span>{{ selected.label }}</span>
9393
</div>
94-
<span v-else>Select user</span>
94+
<span v-else>{{ $t('form.field.selectUser') }}</span>
9595
</div>
9696
<span v-else>
97-
<span v-if="!selected"> Select</span>
97+
<span v-if="!selected"> {{ $t('form.field.select') }}</span>
9898
<span v-else>{{ selected.label }} </span>
9999
</span>
100100
</template>
@@ -114,14 +114,18 @@
114114
<Editor
115115
v-model:htmlContent="action.value[0]"
116116
@update:htmlContent="(value) => handleEditorChange(value, index)"
117-
:placeholder="'Shift + Enter to add new line'"
117+
:placeholder="t('admin.macro.message_content.placeholder')"
118118
/>
119119
</div>
120120
</div>
121121
</div>
122122
</div>
123123
<div>
124-
<Button variant="outline" @click.prevent="addAction">Add action</Button>
124+
<Button variant="outline" @click.prevent="addAction">{{
125+
$t('globals.messages.add', {
126+
name: $t('globals.entities.action')
127+
})
128+
}}</Button>
125129
</div>
126130
</div>
127131
</template>
@@ -144,6 +148,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
144148
import { SelectTag } from '@/components/ui/select'
145149
import { useConversationFilters } from '@/composables/useConversationFilters'
146150
import { getTextFromHTML } from '@/utils/strings.js'
151+
import { useI18n } from 'vue-i18n'
147152
import Editor from '@/features/conversation/ConversationTextEditor.vue'
148153
149154
const props = defineProps({
@@ -154,6 +159,7 @@ const props = defineProps({
154159
})
155160
156161
const { actions } = toRefs(props)
162+
const { t } = useI18n()
157163
const emit = defineEmits(['update-actions', 'add-action', 'remove-action'])
158164
const tagsStore = useTagStore()
159165
const { conversationActions } = useConversationFilters()

frontend/src/features/admin/automation/AutomationTabs.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
<template>
22
<Tabs default-value="new_conversation" v-model="selectedTab">
33
<TabsList class="grid w-full grid-cols-3 mb-5">
4-
<TabsTrigger value="new_conversation">New conversation</TabsTrigger>
5-
<TabsTrigger value="conversation_update">Conversation update</TabsTrigger>
6-
<TabsTrigger value="time_trigger">Time triggers</TabsTrigger>
4+
<TabsTrigger value="new_conversation">{{
5+
$t('admin.automation.newConversation')
6+
}}</TabsTrigger>
7+
<TabsTrigger value="conversation_update">{{
8+
$t('admin.automation.conversationUpdate')
9+
}}</TabsTrigger>
10+
<TabsTrigger value="time_trigger">{{ $t('admin.automation.timeTriggers') }}</TabsTrigger>
711
</TabsList>
812
<TabsContent value="new_conversation">
9-
<RuleTab type="new_conversation" helptext="Rules that run when a new conversation is created, drag and drop to reorder rules." />
13+
<RuleTab
14+
type="new_conversation"
15+
:helptext="t('admin.automation.newConversation.description')"
16+
/>
1017
</TabsContent>
1118
<TabsContent value="conversation_update">
12-
<RuleTab type="conversation_update" helptext="Rules that run when a conversation is updated." />
19+
<RuleTab
20+
type="conversation_update"
21+
:helptext="t('admin.automation.conversationUpdate.description')"
22+
/>
1323
</TabsContent>
1424
<TabsContent value="time_trigger">
15-
<RuleTab type="time_trigger" helptext="Rules that run once an hour." />
25+
<RuleTab type="time_trigger" :helptext="t('admin.automation.timeTriggers.description')" />
1626
</TabsContent>
1727
</Tabs>
1828
</template>
1929

2030
<script setup>
2131
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
32+
import { useI18n } from 'vue-i18n'
2233
import RuleTab from './RuleTab.vue'
2334
35+
const { t } = useI18n()
2436
const selectedTab = defineModel('automationsTab', {
2537
default: 'new_conversation',
2638
type: String,

frontend/src/features/admin/automation/RuleBox.vue

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88
>
99
<div class="flex items-center space-x-2">
1010
<RadioGroupItem value="OR" />
11-
<Label>Match <b>ANY</b> of below.</Label>
11+
<Label
12+
>{{ $t('admin.automation.match') }} <b>{{ $t('admin.automation.any') }}</b>
13+
{{ $t('admin.automation.below') }}.</Label
14+
>
1215
</div>
1316
<div class="flex items-center space-x-2">
1417
<RadioGroupItem value="AND" />
15-
<Label>Match <b>ALL</b> of below.</Label>
18+
<Label
19+
>{{ $t('admin.automation.match') }} <b>{{ $t('admin.automation.all') }}</b>
20+
{{ $t('admin.automation.below') }}.</Label
21+
>
1622
</div>
1723
</RadioGroup>
1824
</div>
@@ -31,11 +37,11 @@
3137
@update:modelValue="(value) => handleFieldChange(value, index)"
3238
>
3339
<SelectTrigger class="w-56">
34-
<SelectValue placeholder="Select field" />
40+
<SelectValue :placeholder="t('form.field.selectField')" />
3541
</SelectTrigger>
3642
<SelectContent>
3743
<SelectGroup>
38-
<SelectLabel>Conversation</SelectLabel>
44+
<SelectLabel>{{ $t('globals.entities.conversation') }}</SelectLabel>
3945
<SelectItem v-for="(field, key) in currentFilters" :key="key" :value="key">
4046
{{ field.label }}
4147
</SelectItem>
@@ -49,7 +55,7 @@
4955
@update:modelValue="(value) => handleOperatorChange(value, index)"
5056
>
5157
<SelectTrigger class="w-56">
52-
<SelectValue placeholder="Select operator" />
58+
<SelectValue :placeholder="t('form.field.selectOperator')" />
5359
</SelectTrigger>
5460
<SelectContent>
5561
<SelectGroup>
@@ -69,7 +75,7 @@
6975
<!-- Plain text input -->
7076
<Input
7177
type="text"
72-
placeholder="Set value"
78+
:placeholder="t('form.fields.setValue')"
7379
v-if="inputType(index) === 'text'"
7480
v-model="rule.value"
7581
@update:modelValue="(value) => handleValueChange(value, index)"
@@ -78,7 +84,7 @@
7884
<!-- Number input -->
7985
<Input
8086
type="number"
81-
placeholder="Set value"
87+
:placeholder="t('form.fields.setValue')"
8288
v-if="inputType(index) === 'number'"
8389
v-model="rule.value"
8490
@update:modelValue="(value) => handleValueChange(value, index)"
@@ -112,7 +118,7 @@
112118
{{ selected.emoji }}
113119
<span>{{ selected.label }}</span>
114120
</div>
115-
<span v-else>Select team</span>
121+
<span v-else>{{ $t('form.field.selectTeam') }}</span>
116122
</div>
117123

118124
<div
@@ -131,10 +137,10 @@
131137
</Avatar>
132138
<span>{{ selected.label }}</span>
133139
</div>
134-
<span v-else>Select user</span>
140+
<span v-else>{{ $t('form.field.selectUser') }}</span>
135141
</div>
136142
<span v-else>
137-
<span v-if="!selected"> Select</span>
143+
<span v-if="!selected"> {{ $t('form.field.select') }}</span>
138144
<span v-else>{{ selected.label }} </span>
139145
</span>
140146
</template>
@@ -155,9 +161,11 @@
155161
<TagsInputItemText />
156162
<TagsInputItemDelete />
157163
</TagsInputItem>
158-
<TagsInputInput placeholder="Select values" />
164+
<TagsInputInput :placeholder="t('form.field.selectValue')" />
159165
</TagsInput>
160-
<p class="text-xs text-gray-500 mt-1">Press enter to select a value</p>
166+
<p class="text-xs text-gray-500 mt-1">
167+
{{ $t('globals.messages.pressEnterToSelectAValue') }}
168+
</p>
161169
</div>
162170
</div>
163171

@@ -173,12 +181,18 @@
173181
:defaultChecked="rule.case_sensitive_match"
174182
@update:checked="(value) => handleCaseSensitiveCheck(value, index)"
175183
/>
176-
<label> Case sensitive match </label>
184+
<label> {{ $t('globals.messages.caseSensitiveMatch') }} </label>
177185
</div>
178186
</div>
179187
</div>
180188
<div>
181-
<Button variant="outline" size="sm" @click.prevent="addCondition">Add condition</Button>
189+
<Button variant="outline" size="sm" @click.prevent="addCondition">
190+
{{
191+
$t('globals.messages.add', {
192+
name: $t('globals.entities.condition')
193+
})
194+
}}
195+
</Button>
182196
</div>
183197
</div>
184198
</div>
@@ -210,6 +224,7 @@ import { Label } from '@/components/ui/label'
210224
import { Input } from '@/components/ui/input'
211225
import ComboBox from '@/components/ui/combobox/ComboBox.vue'
212226
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
227+
import { useI18n } from 'vue-i18n'
213228
import { useConversationFilters } from '@/composables/useConversationFilters'
214229
215230
const props = defineProps({
@@ -230,6 +245,7 @@ const props = defineProps({
230245
const { conversationFilters, newConversationFilters } = useConversationFilters()
231246
const { ruleGroup } = toRefs(props)
232247
const emit = defineEmits(['update-group', 'add-condition', 'remove-condition'])
248+
const { t } = useI18n()
233249
234250
// Computed property to get the correct filters based on type
235251
const currentFilters = computed(() => {

frontend/src/features/admin/automation/RuleList.vue

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
{{ rule.name }}
88
</div>
99
<div class="mb-1">
10-
<Badge v-if="rule.enabled" class="text-[9px]">Enabled</Badge>
11-
<Badge v-else variant="secondary">Disabled</Badge>
10+
<Badge v-if="rule.enabled" class="text-[9px]">{{ $t('form.field.enabled') }}</Badge>
11+
<Badge v-else variant="secondary">{{ $t('form.field.disabled') }}</Badge>
1212
</div>
1313
</span>
1414
</div>
@@ -21,16 +21,16 @@
2121
</DropdownMenuTrigger>
2222
<DropdownMenuContent>
2323
<DropdownMenuItem @click="navigateToEditRule(rule.id)">
24-
<span>Edit</span>
24+
<span>{{ $t('globals.buttons.edit') }}</span>
2525
</DropdownMenuItem>
2626
<DropdownMenuItem @click="() => (alertOpen = true)">
27-
<span>Delete</span>
27+
<span>{{ $t('globals.buttons.delete') }}</span>
2828
</DropdownMenuItem>
2929
<DropdownMenuItem @click="$emit('toggle-rule', rule.id)" v-if="rule.enabled">
30-
<span>Disable</span>
30+
<span>{{ $t('globals.buttons.disable') }}</span>
3131
</DropdownMenuItem>
3232
<DropdownMenuItem @click="$emit('toggle-rule', rule.id)" v-else>
33-
<span>Enable</span>
33+
<span>{{ $t('globals.buttons.enable') }}</span>
3434
</DropdownMenuItem>
3535
</DropdownMenuContent>
3636
</DropdownMenu>
@@ -42,14 +42,16 @@
4242
<AlertDialog :open="alertOpen" @update:open="alertOpen = $event">
4343
<AlertDialogContent>
4444
<AlertDialogHeader>
45-
<AlertDialogTitle>Delete Rule</AlertDialogTitle>
45+
<AlertDialogTitle>{{ $t('globals.messages.areYouAbsolutelySure') }}</AlertDialogTitle>
4646
<AlertDialogDescription>
47-
This action cannot be undone. This will permanently delete the automation rule.
47+
{{ $t('admin.automation.deleteConfirmation') }}
4848
</AlertDialogDescription>
4949
</AlertDialogHeader>
5050
<AlertDialogFooter>
51-
<AlertDialogCancel>Cancel</AlertDialogCancel>
52-
<AlertDialogAction @click="handleDelete">Delete</AlertDialogAction>
51+
<AlertDialogCancel>{{ $t('globals.buttons.cancel') }}</AlertDialogCancel>
52+
<AlertDialogAction @click="handleDelete">{{
53+
$t('globals.buttons.delete')
54+
}}</AlertDialogAction>
5355
</AlertDialogFooter>
5456
</AlertDialogContent>
5557
</AlertDialog>

frontend/src/features/admin/automation/RuleTab.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
}}</SelectValue>
1616
</SelectTrigger>
1717
<SelectContent>
18-
<SelectItem value="first_match">Execute the first matching rule</SelectItem>
19-
<SelectItem value="all">Execute all matching rules</SelectItem>
18+
<SelectItem value="first_match">{{
19+
$t('admin.automation.executeFirstMatchingRule')
20+
}}</SelectItem>
21+
<SelectItem value="all">{{ $t('admin.automation.executeAllMatchingRules') }}</SelectItem>
2022
</SelectContent>
2123
</Select>
2224
</div>

frontend/src/features/admin/automation/formSchema.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
import * as z from 'zod';
22

3-
export const formSchema = z
3+
export const createFormSchema = (t) => z
44
.object({
55
name: z.string({
6-
required_error: 'Rule name is required.',
6+
required_error: t('globals.messages.required'),
77
}),
88
description: z.string({
9-
required_error: 'Rule description is required.',
9+
required_error: t('globals.messages.required'),
1010
}),
1111
enabled: z.boolean().default(true),
1212
type: z.string({
13-
required_error: 'Rule type is required.',
13+
required_error: t('globals.messages.required'),
1414
}),
1515
events: z.array(z.string()).optional(),
1616
})
1717
.superRefine((data, ctx) => {
1818
if (data.type === 'conversation_update' && (!data.events || data.events.length === 0)) {
1919
ctx.addIssue({
2020
path: ['events'],
21-
message: 'Please select at least one event.',
21+
message: t('globals.messages.pleaseSelectAtLeastOne', {
22+
name: t('globals.entities.event')
23+
}),
2224
code: z.ZodIssueCode.custom,
2325
});
2426
}

frontend/src/views/admin/automations/Automation.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
<div v-if="router.currentRoute.value.name === 'automations'">
55
<div class="flex justify-between mb-5">
66
<div class="ml-auto">
7-
<Button @click="newRule">New rule</Button>
7+
<Button @click="newRule">{{
8+
$t('globals.messages.new', {
9+
name: $t('globals.entities.rule')
10+
})
11+
}}</Button>
812
</div>
913
</div>
1014
<div v-if="selectedTab">
11-
<AutomationTabs v-model="selectedTab" />
15+
<AutomationTabs v-model:automationsTab="selectedTab" />
1216
</div>
1317
</div>
1418
<router-view />

0 commit comments

Comments
 (0)