---
title: Intl.ListFormat:列表文案与本地化
keywords:
- Intl.ListFormat
- 列表文案
- conjunction/disjunction
- 本地化
- 格式化
description: 使用 Intl.ListFormat 根据语言规则生成正确的列表文案(如“A、B和C”),支持不同样式与类型,提升国际化展示质量。
categories:
- 文章资讯
- 编程技术
---
概述
Intl.ListFormat 根据 locale 生成符合语言习惯的列表文案,支持并列(conjunction)、或(disjunction)等类型与 long/short/narrow 样式。
用法/示例
const lf = new Intl.ListFormat('zh-CN', { style: 'long', type: 'conjunction' })
lf.format(['A', 'B', 'C']) // "A、B和C"
const en = new Intl.ListFormat('en', { style: 'short', type: 'disjunction' })
en.format(['read', 'write', 'execute']) // "read, write, or execute"
工程建议
- 统一使用配置中心的 locale 与样式,保持跨页面一致;为缺失覆盖提供兜底。
- 与
DisplayNames/NumberFormat/DateTimeFormat协作,构建完整的本地化系统。 - 验证不同语言规则与边界(单项/双项)表现,避免硬编码。
参考与验证
- MDN:Intl.ListFormat — https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat

发表评论 取消回复