This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 09a0db4c1 fix(web): localize the two email failures the outbox raises
itself (#7035)
09a0db4c1 is described below
commit 09a0db4c1fec37aeb98cd34ea52925f99584c410
Author: bai mengxuan <[email protected]>
AuthorDate: Fri Nov 27 12:21:38 2026 +0800
fix(web): localize the two email failures the outbox raises itself (#7035)
---
web/src/i18n/translations.ts | 8 ++++++++
web/src/utils/deliveryResult.test.ts | 40 ++++++++++++++++++++++++++++++++++++
web/src/utils/deliveryResult.ts | 5 +++++
3 files changed, 53 insertions(+)
diff --git a/web/src/i18n/translations.ts b/web/src/i18n/translations.ts
index 50d21c4e1..7d3f506be 100644
--- a/web/src/i18n/translations.ts
+++ b/web/src/i18n/translations.ts
@@ -1286,6 +1286,14 @@ const translations: Record<string, Record<Lang, string>>
= {
zh: '未配置邮件收件人',
en: 'No configured email recipients',
},
+ 'deliveries.errInvalidEmailRecipients': {
+ zh: '邮件收件人地址无效',
+ en: 'No valid email recipients',
+ },
+ 'deliveries.errSmtpNotConfigured': {
+ zh: '未配置 SMTP 邮件服务器,请在设置中填写 SMTP 主机与端口',
+ en: 'SMTP is not configured; set the SMTP host and port in Settings',
+ },
'deliveries.errNoWebhook': {
zh: '未配置 {channel} Webhook',
en: 'No configured {channel} webhook',
diff --git a/web/src/utils/deliveryResult.test.ts
b/web/src/utils/deliveryResult.test.ts
new file mode 100644
index 000000000..a739f127e
--- /dev/null
+++ b/web/src/utils/deliveryResult.test.ts
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+import { localizeDeliveryError } from './deliveryResult';
+
+const t = (key: string) => `key:${key}`;
+
+describe('localizeDeliveryError', () => {
+ it('localizes the SMTP and recipient failures the outbox records itself', ()
=> {
+ // Both strings come from NotificationOutboxService and are what an
operator sees whenever the
+ // email channel is not usable; the helper used to leave them as raw
English.
+ expect(localizeDeliveryError('SMTP is not configured', t)).toBe(
+ 'key:deliveries.errSmtpNotConfigured',
+ );
+ expect(localizeDeliveryError('No valid email recipients', t)).toBe(
+ 'key:deliveries.errInvalidEmailRecipients',
+ );
+ });
+
+ it('keeps an unmapped failure unchanged', () => {
+ expect(localizeDeliveryError('Connection refused', t)).toBe('Connection
refused');
+ expect(localizeDeliveryError('', t)).toBe('');
+ expect(localizeDeliveryError(null, t)).toBe('');
+ });
+});
diff --git a/web/src/utils/deliveryResult.ts b/web/src/utils/deliveryResult.ts
index e86328434..5cc72320b 100644
--- a/web/src/utils/deliveryResult.ts
+++ b/web/src/utils/deliveryResult.ts
@@ -29,6 +29,11 @@ export const localizeDeliveryError = (raw: string | null |
undefined, t: Transla
if (!raw) return '';
const trimmed = raw.trim();
if (trimmed === 'No configured email recipients') return
t('deliveries.errNoEmailRecipients');
+ // The outbox throws these two itself (NotificationOutboxService): a missing
mail sender and a
+ // recipient list that parsed to nothing. They are the two failures an
operator sees most when
+ // the email channel is misconfigured, so leaving them in English defeats
the mapping above.
+ if (trimmed === 'No valid email recipients') return
t('deliveries.errInvalidEmailRecipients');
+ if (trimmed === 'SMTP is not configured') return
t('deliveries.errSmtpNotConfigured');
const webhook = WEBHOOK_PATTERN.exec(trimmed);
if (webhook) return t('deliveries.errNoWebhook', { channel: webhook[1] });
const unsupported = UNSUPPORTED_PATTERN.exec(trimmed);