大网数据广告活动
Web 标准与前端开发

Intl.Locale.prototype.minimize()

· 52CE 我爱测

The **`minimize()`** method of Intl.Locale instances attempts to remove information about this locale that would be added by calling Intl/Locale/maximize.

The minimize() method of Intl.Locale instances attempts to remove information about this locale that would be added by calling Intl/Locale/maximize.

JavaScript Demo: Intl.Locale.prototype.minimize()

const english = new Intl.Locale("en-Latn-US");
const korean = new Intl.Locale("ko-Kore-KR");
const arabic = new Intl.Locale("ar-Arab-EG");

console.log(english.minimize().baseName);
// Expected output: "en"

console.log(korean.minimize().baseName);
// Expected output: "ko"

console.log(arabic.minimize().baseName);
// Expected output: "ar"

Syntax

minimize()

Parameters

None.

Return value

An Intl.Locale instance whose baseName property returns the result of the Remove Likely Subtags algorithm executed against Intl/Locale/baseName.

Description

This method carries out the reverse of Intl/Locale/maximize, removing any language, script, or region subtags from the locale language identifier (essentially the contents of baseName). This is useful when there are superfluous subtags in the language identifier; for instance, "en-Latn" can be simplified to "en", since "Latn" is the only script used to write English. minimize() only affects the main subtags that comprise the language identifier: language, script, and region subtags. Other subtags after the "-u" in the locale identifier are called extension subtags and are not affected by the minimize() method. Examples of these subtags include Intl/Locale/hourCycle, Intl/Locale/calendar, and Intl/Locale/numeric.

Examples

Using minimize

const myLocale = new Intl.Locale("fr-Latn-FR", {
  hourCycle: "h12",
  calendar: "gregory",
});
console.log(myLocale.baseName); // Prints "fr-Latn-FR"
console.log(myLocale.toString()); // Prints "fr-Latn-FR-u-ca-gregory-hc-h12"

const myLocMinimized = myLocale.minimize();

// Prints "fr", since French is only written in the Latin script
// and is most likely to be spoken in France.
console.log(myLocMinimized.baseName);

// Prints "fr-u-ca-gregory-hc-h12".
// Note that the extension tags (after "-u") remain unchanged.
console.log(myLocMinimized.toString());

Specifications

Browser compatibility

See also

  • Intl.Locale
  • Intl/Locale/baseName

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。