ECMAScript Internationalization API - Intl: Difference between revisions
From WikiMLT
m (→References) |
mNo edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
== References == | == References == | ||
* MDN: ''' | * MDN: '''[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl <code>Intl</code> ECMAScript Internationalization API]''' | ||
== Simple example == | == Simple example == | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" class="code-continue"> | ||
const formatter = new Intl.RelativeTimeFormat("bg-BG", { style: "long" }); | const formatter = new Intl.RelativeTimeFormat("bg-BG", { style: "long" }); | ||
</syntaxhighlight><syntaxhighlight lang="javascript"> | </syntaxhighlight> | ||
<syntaxhighlight lang="javascript" class="code-continue"> | |||
formatter.format(-1, "minute"); | formatter.format(-1, "minute"); | ||
</syntaxhighlight><syntaxhighlight lang="javascript"> | </syntaxhighlight> | ||
<syntaxhighlight lang="javascript" class="code-continue"> | |||
'преди 1 минута' | 'преди 1 минута' | ||
</syntaxhighlight><noinclude> | </syntaxhighlight><noinclude> | ||
Line 26: | Line 28: | ||
{{devStage | {{devStage | ||
| Прндл = JavaScript | | Прндл = JavaScript | ||
| Стадий = | | Стадий = 6 | ||
| Фаза = | | Фаза = Утвърждаване | ||
| Статус = | | Статус = Утвърден | ||
| ИдтПт = Spas | | ИдтПт = Spas | ||
| РзбПт = {{REVISIONUSER}} | | РзбПт = Spas | ||
| АвтПт = Spas | |||
| УтвПт = {{REVISIONUSER}} | |||
| ИдтДт = 21.03.2023 | | ИдтДт = 21.03.2023 | ||
| РзбДт = {{Today}} | | РзбДт = 21.03.2023 | ||
| АвтДт = 21.03.2023 | |||
| УтвДт = {{Today}} | |||
| ИдтРв = [[Special:Permalink/32444|32444]] | | ИдтРв = [[Special:Permalink/32444|32444]] | ||
| РзбРв = {{REVISIONID}} | | РзбРв = [[Special:Permalink/32449|32449]] | ||
| АвтРв = [[Special:Permalink/32450|32450]] | |||
| УтвРв = {{REVISIONID}} | |||
}} | }} | ||
</div> | </div> | ||
</noinclude> | </noinclude> |
Latest revision as of 20:27, 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
Simple example
const formatter = new Intl.RelativeTimeFormat("bg-BG", { style: "long" });
formatter.format(-1, "minute");
'преди 1 минута'