ECMAScript Internationalization API - Intl: Difference between revisions
From WikiMLT
m Стадий: 3 [Фаза:Разработване, Статус:Разработван]; Категория:JavaScript |
|||
Line 1: | Line 1: | ||
<noinclude><!--[[Category:JavaScript|?]]-->{{ContentArticleHeader/JavaScript}}</noinclude> | <noinclude><!--[[Category:JavaScript|?]]-->{{ContentArticleHeader/JavaScript}}</noinclude> | ||
''The <code>Intl</code> object is the namespace for the ECMAScript Internationalization API, which provides language sensitive string comparison, number formatting, and date and time formatting. The <code>Intl</code> object provides access to several constructors as well as functionality common to the internationalization constructors and other language sensitive functions.'' | |||
{{media | |||
| n = 1 | |||
| img = YouTube-loading.webp | |||
| label = v | |||
| special = youtube | |||
| vid = 4oGWpTAY_hc | |||
| sz = 1200 | |||
| pos = center | |||
| ca = Web Dev Simplified on YouTube: [https://youtu.be/4oGWpTAY_hc Formatting Is So Easy With The Intl JavaScript API]. | |||
}} | |||
== References == | == References == | ||
* [https:// | * MDN: '''<code>[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl Intl]</code> ECMAScript Internationalization API''' | ||
== | == Simple example == | ||
.. | <syntaxhighlight lang="javascript"> | ||
const formatter = new Intl.RelativeTimeFormat("bg-BG", { style: "long" }); | |||
<noinclude> | </syntaxhighlight><syntaxhighlight lang="javascript"> | ||
formatter.format(-1, "minute"); | |||
</syntaxhighlight><syntaxhighlight lang="javascript"> | |||
'преди 1 минута' | |||
</syntaxhighlight><noinclude> | |||
<div id='devStage'> | <div id='devStage'> | ||
{{devStage | {{devStage |
Revision as of 20:23, 21 March 2023
The Intl
object is the namespace for the ECMAScript Internationalization API, which provides language sensitive string comparison, number formatting, and date and time formatting. The Intl
object provides access to several constructors as well as functionality common to the internationalization constructors and other language sensitive functions.
References
- MDN:
Intl
ECMAScript Internationalization API
Simple example
const formatter = new Intl.RelativeTimeFormat("bg-BG", { style: "long" });
formatter.format(-1, "minute");
'преди 1 минута'