For AI agents: the complete documentation index is available at /tc39-atlas/llms.txt, the full documentation bundle is available at /tc39-atlas/llms-full.txt, and this page is available as Markdown at /tc39-atlas/proposals/year/2026/proposal-intl-locale-info.md.
  • 简体中文
  • Intl Locale Info S4

    中文标题:Intl 区域设置信息

    提案概览
    提案速览

    该提案为 Intl.Locale 添加了方法,以公开区域设置特定信息,包括周数据(第一天、周末)、文本方向以及日历、排序规则、小时周期、编号系统和时区的默认值。

    Note

    以下 README 来自上游仓库,其中的阶段或状态标注可能滞后;当前信息以提案概览为准。

    Intl Locale Info API

    本提案已完全纳入 ECMA-402 第 13 版,2026 年 6 月“ECMAScript® 2026 国际化 API 规范”

    草案规范

    https://tc39.github.io/proposal-intl-locale-info

    阶段

    阶段 4

    阶段 1(提案)进入标准

    • 已确定将推进该新增功能的“ champions”:Frank Yung-Fong Tang
    • 概述问题或需求以及解决方案大致形态的说明性文字:见本文档
    • 说明性使用示例:见本文档
    • 高层级 API:见本文档
    • 关键算法、抽象和语义的讨论
    • 识别潜在的“跨领域”关注点以及实现挑战/复杂性
    • 一个可公开访问的用于存储满足上述要求的提案的仓库:

    阶段 2(草案)进入标准

    • 上述内容
    • 初始规范文本:已完成
    • 接受意味着:委员会期望该功能被开发并最终纳入标准

    阶段 3(候选)进入标准

    • 上述内容
    • 完整的规范文本
    • 指定的审阅者已签署当前规范文本
    • 所有 ECMAScript 编辑已签署当前规范文本
    • 接受意味着:解决方案已完成,没有实现经验、大量使用和外部反馈,无法进行进一步工作。

    提案推进人

    • Frank Tang @FrankYFTang

    指定审阅者

    • Shane Carr @sffc
    • Zibi Braniecki @zbraniecki

    ECMAScript 编辑

    • Richard Gibson @gibson042

    实现状态

    • V8(更新于 2021-5-6:):在标志后面(cl/2570218 已合并到主干)
      • $ out/x64.release/d8 --harmony_intl_locale_info
      • Chrome - 待定
      • Edge - ???
    • FireFox - 跟踪 Bug
    • Safari - ???

    范围

    一个用于公开区域设置信息(如周数据(一周的第一天、周末开始日、周末结束日)、区域设置中使用的文本方向和小时周期,区域设置中使用的度量衡系统)的提案。

    动机/用例

    区域设置信息对于许多底层操作是必需的。

    • textInfo 中的方向将用于布局和本地化信息(带占位符等的 bidi 边界)
    • WeekInfo 将用于日历组件和应用程序,以显示正确的月视图和周视图。

    高层设计

    向 Intl 添加方法以获取包含一组信息的对象:

    周数据
    let he = new Intl.Locale("he")
    he.getWeekInfo()
    // {firstDay: 7, weekend: [5, 6]}
    let af = new Intl.Locale("af")
    af.getWeekInfo()
    // {firstDay: 7, weekend: [6, 7]}
    enGB = new Intl.Locale("en-GB")
    enGB.getWeekInfo()
    // {firstDay: 1, weekend: [6, 7]}
    
    let msBN = new Intl.Locale("ms-BN")
    msBN.getWeekInfo()
    // {firstDay: 7, weekend: [5, 7]}  // 文莱的周末是星期五和星期日,但不是星期六

    星期一为 1,星期日为 7,由 ISO-8861 定义并遵循 Temporal 提案

    文本信息
    l = new Intl.Locale("ar")
    let ti = l.getTextInfo();
    // { direction: "rtl" }
    ti.direction
    // rtl
    默认值
    ~/v8/v8$ out/x64.release/d8 --harmony_intl_locale_info
    V8 version 9.1.0 (candidate)
    d8> ar = new Intl.Locale("ar")
    ar
    d8> ar.getCalendars()
    ["gregory", "coptic", "islamic", "islamic-civil", "islamic-tbla"]
    d8> ar.getCollations()
    ["compat", "emoji", "eor"]
    d8> ar.getHourCycles()
    ["h12"]
    d8> ar.getNumberingSystems()
    ["latn"]
    d8> ar.getTimeZones()
    undefined
    
    d8> arEG = new Intl.Locale("ar-EG")
    ar-EG
    d8> arEG.getCalendars()
    ["gregory", "coptic", "islamic", "islamic-civil", "islamic-tbla"]
    d8> arEG.getCollations()
    ["compat", "emoji", "eor"]
    d8> arEG.getHourCycles()
    ["h12"]
    d8> arEG.getNumberingSystems()
    ["arab"]
    d8> arEG.getTimeZones()
    ["Africa/Cairo"]
    
    d8> arSA = new Intl.Locale("ar-SA")
    ar-SA
    d8> arSA.getCalendars()
    ["islamic-umalqura", "gregory", "islamic", "islamic-rgsa"]
    d8> arSA.getCollations()
    ["compat", "emoji", "eor"]
    d8> arSA.getHourCycles()
    ["h12"]
    d8> arSA.getNumberingSystems()
    ["arab"]
    d8> arSA.getTimeZones()
    timeZones: ["Asia/Riyadh"]
    
    d8> ja = new Intl.Locale("ja")
    ja
    d8> ja.getCalendars()
    ["gregory", "japanese"]
    d8> ja.getCollations()
    ["unihan", "emoji", "eor"]
    d8> ja.getHourCycles()
    ["h23"]
    d8> ja.getNumberingSystems()
    ["latn"]
    d8> ja.getTimeZones()
    undefined
    
    d8> jaJP = new Intl.Locale("ja-JP")
    ja-JP
    d8> jaJP.getCalendars()
    ["gregory", "japanese"]
    d8> jaJP.getCollations()
    ["unihan", "emoji", "eor"]
    d8> jaJP.getHourCycles()
    ["h23"]
    d8> jaJP.getNumberingSystems()
    ["latn"]
    d8> jaJP.getTimeZones()
    ["Asia/Tokyo"]}
    
    d8> enUS = new Intl.Locale("en-US")
    en-US
    d8> enUS.getCalendars()
    ["gregory"]
    d8> enUS.getCollations()
    ["emoji", "eor"]
    d8> enUS.getHourCycles()
    ["h12"]
    d8> enUS.getNumberingSystems()
    ["latn"]
    d8> enUS.getTimeZones()
    ["America/Adak", "America/Anchorage", "America/Boise", "America/Chicago", "America/Denver", "America/Detroit", "America/Indiana/Knox", "America/Indiana/Marengo", "America/Indiana/Petersburg", "America/Indiana/Tell_City", "America/Indiana/Vevay", "America/Indiana/Vincennes", "America/Indiana/Winamac", "America/Indianapolis", "America/Juneau", "America/Kentucky/Monticello", "America/Los_Angeles", "America/Louisville", "America/Menominee", "America/Metlakatla", "America/New_York", "America/Nome", "America/North_Dakota/Beulah", "America/North_Dakota/Center", "America/North_Dakota/New_Salem", "America/Phoenix", "America/Sitka", "America/Yakutat", "Pacific/Honolulu"]
    
    d8> enNZ = new Intl.Locale("en-NZ")
    en-NZ
    d8> enNZ.getCalendars()
    ["gregory"]
    d8> enNZ.getCollations()
    ["emoji", "eor"]
    d8> enNZ.getHourCycles()
    ["h12"]
    d8> enNZ.getNumberingSystems()
    ["latn"]
    d8> enNZ.getTimeZones()
    ["Pacific/Auckland", "Pacific/Chatham"]
    
    d8> zh = new Intl.Locale("zh")
    zh
    d8> zh.getCalendars()
    ["gregory", "chinese"]
    d8> zh.getCollations()
    ["pinyin", "big5han", "gb2312han", "stroke", "unihan", "zhuyin", "emoji", "eor"]
    d8> zh.getHourCycles()
    ["h12"]
    d8> zh.getNumberingSystems()
    ["latn"]
    d8> zh.getTimeZones()
    undefined
    
    d8> zhTW = new Intl.Locale("zh-TW")      
    zh-TW
    d8>  zhTW.getCalendars()
    ["gregory", "roc", "chinese"]
    d8>  zhTW.getCollations()
    ["stroke", "big5han", "gb2312han", "pinyin", "unihan", "zhuyin", "emoji", "eor"]
    d8>  zhTW.getHourCycles()
    ["h12"]
    d8>  zhTW.getNumberingSystems()
    ["latn"]
    d8>  zhTW.getTimeZones()
    ["Asia/Taipei"]
    
    d8> zhHK = new Intl.Locale("zh-HK")
    zh-HK
    d8> zhHK.getCalendars()
    ["gregory", "chinese"]
    d8> zhHK.getCollations()
    ["stroke", "big5han", "gb2312han", "pinyin", "unihan", "zhuyin", "emoji", "eor"]
    d8> zhHK.getHourCycles()
    ["h12"]
    d8> zhHK.getNumberingSystems()
    ["latn"]
    d8> zhHK.getTimeZones()
    ["Asia/Hong_Kong"]
    
    d8> fa = new Intl.Locale("fa")
    fa
    d8> fa.getCalendars()
    ["persian", "gregory", "islamic", "islamic-civil", "islamic-tbla"]
    d8> fa.getCollations()
    ["emoji", "eor"]
    d8> fa.getHourCycles()
    ["h23"]
    d8> fa.getNumberingSystems()
    ["arabext"]
    d8> fa.getTimeZones()
    undefined 
    
    单位信息 已放弃的功能
    l = new Intl.Locale("ar")
    let unitInfo = l.unitInfo;
    // {measurementSystem: "metric"}
    l.unitInfo.measurementSystem
    // metric
    l = new Intl.Locale("en-GB")
    l.unitInfo
    // {measurementSystem: "uksystem"}
    l = new Intl.Locale("en-GB")
    l.unitInfo
    // {measurementSystem: "uksystem"}
    l = new Intl.Locale("en")
    l.unitInfo
    // {measurementSystem: "ussystem"}
    

    Polyfills