mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-16 11:10:45 +08:00
Add zh/en i18n and follow DSH locale.bind for UI.
Wire API/delivery/tool strings through lib/i18n.js, and make the sidebar use ctx.locale.bind plus locale/change so English host preference no longer stays frozen on Chinese. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
51deaf037b
commit
b35bfde557
12 changed files with 373 additions and 37 deletions
|
|
@ -3,6 +3,8 @@
|
|||
* Group jobs may also pin mentionJid so delivery @s the creator.
|
||||
*/
|
||||
|
||||
import { DEFAULT_LOCALE, t } from './i18n.js'
|
||||
|
||||
export function normalizeDelivery(input = {}) {
|
||||
const src = input && typeof input === 'object' ? input : {}
|
||||
const kind = String(src.kind || 'dsh').trim().toLowerCase()
|
||||
|
|
@ -181,7 +183,7 @@ export function deliveryDraftFromPeer(peer) {
|
|||
// Non-WhatsApp peers are not auto-materialized yet.
|
||||
return null
|
||||
}
|
||||
const name = String(peer.label || (isGroup ? 'WhatsApp 群聊' : 'WhatsApp 私聊')).trim().slice(0, 80)
|
||||
const name = String(peer.label || (isGroup ? t('delivery.wa_group') : t('delivery.wa_dm'))).trim().slice(0, 80)
|
||||
const targetId = isGroup
|
||||
? `auto-group-${slugId(routeJid, 'chat')}`
|
||||
: `auto-dm-${slugId(peer.phone || routeJid, 'user')}`
|
||||
|
|
@ -427,11 +429,13 @@ const IM_MAX_CHARS = 3500
|
|||
* Shared body for IM delivery and session mirror (without @mention prefix).
|
||||
* @param {object} job
|
||||
* @param {string} [summary]
|
||||
* @param {'zh' | 'en' | string} [locale]
|
||||
*/
|
||||
export function formatRunResultBody(job, summary) {
|
||||
const text = String(summary || '').trim() || `(定时任务「${job?.name || ''}」已完成,无文本摘要)`
|
||||
export function formatRunResultBody(job, summary, locale = DEFAULT_LOCALE) {
|
||||
const name = job?.name || ''
|
||||
const text = String(summary || '').trim() || t('delivery.empty_summary', locale, { name })
|
||||
const clipped = text.length > IM_MAX_CHARS ? `${text.slice(0, IM_MAX_CHARS)}…` : text
|
||||
return `【定时任务 · ${job?.name || ''}】\n${clipped}`
|
||||
return `${t('delivery.header', locale, { name })}\n${clipped}`
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue