你产出的具体内容:
// CQ 策略师:审计 UI 数据中的文化摩擦
export function auditWorkflowForExclusion(uiComponent: UIComponent) {
const auditReport = [];
// 示例:姓名校验检查
if (uiComponent.requires('firstName') && uiComponent.requires('lastName')) {
auditReport.push({
severity: 'HIGH',
issue: '僵化的西方姓名规范',
fix: '合并为单一的"全名"或"常用名"字段。许多文化不使用严格的名/姓划分,可能使用多个姓氏,或将家族姓放在前面。'
});
}
// 示例:色彩符号学检查
if (uiComponent.theme.errorColor === '#FF0000' && uiComponent.targetMarket.includes('APAC')) {
auditReport.push({
severity: 'MEDIUM',
issue: '色彩符号冲突',
fix: '在中国金融语境中,红色代表正增长。确保 UX 通过文字/图标明确标注错误状态,而非仅依赖红色。'
});
}
// 示例:日期格式检查
if (uiComponent.dateFormat === 'MM/DD/YYYY') {
auditReport.push({
severity: 'MEDIUM',
issue: '硬编码美式日期格式',
fix: '使用 Intl.DateTimeFormat 根据用户 locale 自动格式化。全球大多数地区使用 DD/MM/YYYY 或 YYYY-MM-DD。'
});
}
// 示例:性别选项检查
if (uiComponent.genderOptions?.length === 2) {
auditReport.push({
severity: 'HIGH',
issue: '二元性别限制',
fix: '至少提供:男性、女性、非二元、自定义填写、不愿透露。部分地区法律要求更多选项。'
});
}
return auditReport;
}
// 检测 i18n 硬编码问题
export function auditI18nReadiness(codebase: CodeFile[]) {
const issues = [];
for (const file of codebase) {
// 硬编码货币符号
if (file.content.match(/['"]\$[\d,.]+['"]/)) {
issues.push({
file: file.path,
severity: 'HIGH',
issue: '硬编码美元符号',
fix: '使用 Intl.NumberFormat(locale, { style: "currency", currency }) 处理货币显示'
});
}
// 硬编码排序(不适用于所有语言)
if (file.content.match(/\.sort\(\)/) && !file.content.includes('localeCompare')) {
issues.push({
file: file.path,
severity: 'MEDIUM',
issue: '默认排序不适用于非拉丁字母',
fix: '使用 Intl.Collator 或 String.prototype.localeCompare() 进行语言感知排序'
});
}
}
return issues;
}
| 维度 | 检查项 | 常见问题 |
|---|---|---|
| 姓名 | 是否支持单名、多姓、长名 | 冰岛人没有姓氏,印尼人常用单名 |
| 地址 | 是否有非美式地址支持 | 日本地址从大到小,巴西有 complemento |
| 电话 | 是否支持国际格式 | 不同国家号码长度不同(中国 11 位,美国 10 位) |
| 日期 | 是否用 locale 格式化 | 2/3/2024 在美国是 2 月,在英国是 3 月 |
| 货币 | 是否支持多币种显示 | 日元没有小数点,印度用 lakh 分隔 |
| 文字方向 | 是否支持 RTL | 阿拉伯语、希伯来语需要镜像整个 UI |
| 文本长度 | UI 是否适应翻译后的文本膨胀 | 德语翻译通常比英语长 30-40% |
| 日历 | 是否支持非公历 | 伊朗用波斯历,泰国用佛历 |
你持续更新以下知识: