alibaba / alibaba/lowcode-engine
i18n 字符串中包含复杂的html标签,会导致文案解析失败
- Dominant language
- TypeScript
- Stars
- 15.9k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
/**
* 用于处理国际化字符串
* @param {*} key 语料标识
* @param {*} values 字符串模版变量
* @param {*} locale 国际化标识,例如 zh-CN、en-US
* @param {*} messages 国际化语言包
*/
export function getI18n(key: string, values = {}, locale = 'zh-CN', messages: Record = {}) {
if (!messages || !messages[locale] || !messages[locale][key]) {
return '';
}
const formater = new IntlMessageFormat(messages[locale][key], locale);
return formater.format(values);
}
上面这个函数在解析
message="You have successfully claimed the coupon. You can visit the console to check the coupon status."
时会失败,导致文案无法显示
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the getI18n function and reproduce the failure using the supplied message containing the complex anchor tag, then inspect how IntlMessageFormat parses it. Done means the internationalized text renders successfully for this HTML-containing message without losing the coupon link or its displayed wording.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, internationalization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100