HH-551: localize activity messages (#132)

* fix(HH-551): localize activity messages

* fix(HH-551): handle null activity content

---------

Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
Rogee
2026-08-23 21:21:44 +08:00
committed by GitHub
co-authored by rogee
parent e41d40feb8
commit 1b5ea7c227
4 changed files with 156 additions and 41 deletions
@@ -8,7 +8,49 @@ import { useMessageContext } from '../provider.js';
const { content, createdAt } = useMessageContext();
const { locale } = useI18n();
const { locale, t } = useI18n();
const localizedContent = computed(() => {
const normalizedContent = String(content.value ?? '');
const resolvedBy = normalizedContent.match(
/^Conversation was resolved by (.+)$/
);
if (resolvedBy) {
const name = ['Anonymous Visitor', 'visitor'].includes(resolvedBy[1])
? t('CONVERSATION.ACTIVITY.ANONYMOUS_VISITOR')
: resolvedBy[1];
return t('CONVERSATION.ACTIVITY.RESOLVED_BY', { name });
}
if (
normalizedContent ===
'Conversation was reopened due to agent bot webhook failure'
) {
return t('CONVERSATION.ACTIVITY.BOT_WEBHOOK_FAILURE');
}
if (
normalizedContent ===
'CSAT survey not sent due to outgoing message restrictions'
) {
return t('CONVERSATION.ACTIVITY.CSAT_RESTRICTED');
}
const linear = normalizedContent.match(
/^Linear issue (\S+) was (created|linked|unlinked) by (.+)$/
);
if (linear) {
const params = {
issueId: linear[1],
name: linear[3],
};
if (linear[2] === 'created') {
return t('CONVERSATION.ACTIVITY.LINEAR_CREATED', params);
}
if (linear[2] === 'linked') {
return t('CONVERSATION.ACTIVITY.LINEAR_LINKED', params);
}
return t('CONVERSATION.ACTIVITY.LINEAR_UNLINKED', params);
}
return normalizedContent;
});
const readableTime = computed(() => {
if (locale.value === 'zh_CN') {
@@ -28,8 +70,8 @@ const readableTime = computed(() => {
data-bubble-name="activity"
>
<span
v-dompurify-html="content"
:title="content"
v-dompurify-html="localizedContent"
:title="localizedContent"
class="min-w-0 max-w-full [overflow-wrap:anywhere]"
/>
</BaseBubble>