@intlayer/docs 5.7.8 → 5.8.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blog/ar/intlayer_with_next-i18next.md +3 -4
- package/blog/ar/intlayer_with_next-intl.md +3 -4
- package/blog/ar/intlayer_with_react-i18next.md +1 -1
- package/blog/ar/intlayer_with_react-intl.md +1 -1
- package/blog/de/intlayer_with_next-i18next.md +3 -4
- package/blog/de/intlayer_with_react-intl.md +1 -1
- package/blog/en/intlayer_with_next-i18next.md +3 -4
- package/blog/en/intlayer_with_next-intl.md +3 -4
- package/blog/en/intlayer_with_react-i18next.md +1 -1
- package/blog/en/intlayer_with_react-intl.md +1 -1
- package/blog/en-GB/intlayer_with_next-i18next.md +3 -4
- package/blog/en-GB/intlayer_with_next-intl.md +3 -4
- package/blog/en-GB/intlayer_with_react-i18next.md +1 -1
- package/blog/en-GB/intlayer_with_react-intl.md +1 -1
- package/blog/es/intlayer_with_next-i18next.md +3 -4
- package/blog/es/intlayer_with_next-intl.md +3 -4
- package/blog/es/intlayer_with_react-i18next.md +1 -1
- package/blog/es/intlayer_with_react-intl.md +1 -1
- package/blog/fr/intlayer_with_next-i18next.md +3 -4
- package/blog/fr/intlayer_with_next-intl.md +3 -4
- package/blog/fr/intlayer_with_react-i18next.md +1 -1
- package/blog/fr/intlayer_with_react-intl.md +1 -1
- package/blog/hi/intlayer_with_next-i18next.md +3 -4
- package/blog/hi/intlayer_with_next-intl.md +3 -4
- package/blog/hi/intlayer_with_react-i18next.md +1 -1
- package/blog/hi/intlayer_with_react-intl.md +1 -1
- package/blog/it/intlayer_with_next-i18next.md +3 -4
- package/blog/it/intlayer_with_next-intl.md +3 -4
- package/blog/it/intlayer_with_react-i18next.md +1 -1
- package/blog/it/intlayer_with_react-intl.md +1 -1
- package/blog/ja/intlayer_with_next-i18next.md +3 -4
- package/blog/ja/intlayer_with_next-intl.md +3 -4
- package/blog/ja/intlayer_with_react-intl.md +1 -1
- package/blog/ko/intlayer_with_next-i18next.md +3 -4
- package/blog/ko/intlayer_with_next-intl.md +3 -4
- package/blog/ko/intlayer_with_react-intl.md +1 -1
- package/blog/pt/intlayer_with_next-i18next.md +3 -4
- package/blog/pt/intlayer_with_next-intl.md +3 -4
- package/blog/pt/intlayer_with_react-intl.md +1 -1
- package/blog/ru/intlayer_with_next-i18next.md +3 -4
- package/blog/ru/intlayer_with_next-intl.md +3 -4
- package/blog/ru/intlayer_with_react-i18next.md +1 -1
- package/blog/ru/intlayer_with_react-intl.md +1 -1
- package/blog/zh/intlayer_with_next-i18next.md +3 -4
- package/blog/zh/intlayer_with_next-intl.md +3 -4
- package/blog/zh/intlayer_with_react-i18next.md +1 -1
- package/blog/zh/intlayer_with_react-intl.md +1 -1
- package/dist/cjs/generated/docs.entry.cjs +41 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +41 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/formatters.md +239 -0
- package/docs/ar/interest_of_intlayer.md +162 -49
- package/docs/ar/introduction.md +3 -3
- package/docs/ar/packages/intlayer/index.md +3 -3
- package/docs/ar/packages/next-intlayer/index.md +3 -3
- package/docs/de/formatters.md +239 -0
- package/docs/de/interest_of_intlayer.md +161 -47
- package/docs/de/introduction.md +3 -3
- package/docs/de/packages/intlayer/index.md +3 -3
- package/docs/de/packages/next-intlayer/index.md +3 -3
- package/docs/de/packages/react-intlayer/index.md +3 -3
- package/docs/en/formatters.md +250 -0
- package/docs/en/interest_of_intlayer.md +159 -46
- package/docs/en/introduction.md +3 -3
- package/docs/en/packages/intlayer/index.md +3 -3
- package/docs/en/packages/next-intlayer/index.md +3 -3
- package/docs/en/packages/react-intlayer/index.md +3 -3
- package/docs/en-GB/formatters.md +239 -0
- package/docs/en-GB/interest_of_intlayer.md +160 -53
- package/docs/en-GB/packages/intlayer/index.md +3 -3
- package/docs/en-GB/packages/next-intlayer/index.md +3 -3
- package/docs/en-GB/packages/react-intlayer/index.md +3 -3
- package/docs/es/formatters.md +239 -0
- package/docs/es/interest_of_intlayer.md +159 -47
- package/docs/es/introduction.md +3 -3
- package/docs/es/packages/intlayer/index.md +3 -3
- package/docs/es/packages/next-intlayer/index.md +3 -3
- package/docs/fr/formatters.md +239 -0
- package/docs/fr/interest_of_intlayer.md +160 -46
- package/docs/fr/introduction.md +3 -3
- package/docs/fr/packages/intlayer/index.md +3 -3
- package/docs/fr/packages/next-intlayer/index.md +3 -3
- package/docs/fr/packages/react-intlayer/index.md +3 -3
- package/docs/hi/formatters.md +239 -0
- package/docs/hi/interest_of_intlayer.md +158 -42
- package/docs/hi/introduction.md +3 -3
- package/docs/hi/packages/intlayer/index.md +3 -3
- package/docs/hi/packages/next-intlayer/index.md +3 -3
- package/docs/hi/packages/react-intlayer/index.md +3 -3
- package/docs/it/formatters.md +239 -0
- package/docs/it/interest_of_intlayer.md +160 -46
- package/docs/it/introduction.md +3 -3
- package/docs/it/packages/intlayer/index.md +3 -3
- package/docs/it/packages/next-intlayer/index.md +3 -3
- package/docs/it/packages/react-intlayer/index.md +3 -3
- package/docs/ja/formatters.md +261 -0
- package/docs/ja/interest_of_intlayer.md +157 -48
- package/docs/ja/introduction.md +3 -3
- package/docs/ja/packages/intlayer/index.md +3 -3
- package/docs/ja/packages/next-intlayer/index.md +3 -3
- package/docs/ja/packages/react-intlayer/index.md +3 -3
- package/docs/ko/formatters.md +258 -0
- package/docs/ko/interest_of_intlayer.md +160 -48
- package/docs/ko/introduction.md +3 -3
- package/docs/ko/packages/intlayer/index.md +3 -3
- package/docs/ko/packages/next-intlayer/index.md +3 -3
- package/docs/ko/packages/react-intlayer/index.md +3 -3
- package/docs/pt/formatters.md +239 -0
- package/docs/pt/interest_of_intlayer.md +162 -47
- package/docs/pt/introduction.md +3 -3
- package/docs/pt/packages/intlayer/index.md +3 -3
- package/docs/pt/packages/next-intlayer/index.md +3 -3
- package/docs/pt/packages/react-intlayer/index.md +3 -3
- package/docs/ru/formatters.md +239 -0
- package/docs/ru/interest_of_intlayer.md +168 -50
- package/docs/ru/introduction.md +3 -3
- package/docs/ru/packages/intlayer/index.md +3 -3
- package/docs/ru/packages/next-intlayer/index.md +3 -3
- package/docs/ru/packages/react-intlayer/index.md +3 -3
- package/docs/zh/formatters.md +239 -0
- package/docs/zh/interest_of_intlayer.md +158 -48
- package/docs/zh/introduction.md +3 -3
- package/docs/zh/packages/intlayer/index.md +3 -3
- package/docs/zh/packages/next-intlayer/index.md +3 -3
- package/docs/zh/packages/react-intlayer/index.md +3 -3
- package/package.json +12 -12
- package/src/generated/docs.entry.ts +41 -0
|
@@ -148,8 +148,8 @@ const clientComponentContent = {
|
|
|
148
148
|
content: {
|
|
149
149
|
myTranslatedContent: t({
|
|
150
150
|
en: "Hello World",
|
|
151
|
-
fr: "Bonjour le monde",
|
|
152
151
|
es: "Hola Mundo",
|
|
152
|
+
fr: "Bonjour le monde",
|
|
153
153
|
}),
|
|
154
154
|
numberOfCar: enu({
|
|
155
155
|
"<-1": "Less than minus one car",
|
|
@@ -174,8 +174,8 @@ const clientComponentContent = {
|
|
|
174
174
|
content: {
|
|
175
175
|
myTranslatedContent: t({
|
|
176
176
|
en: "Hello World",
|
|
177
|
-
fr: "Bonjour le monde",
|
|
178
177
|
es: "Hola Mundo",
|
|
178
|
+
fr: "Bonjour le monde",
|
|
179
179
|
}),
|
|
180
180
|
numberOfCar: enu({
|
|
181
181
|
"<-1": "마이너스 1대 미만의 자동차",
|
|
@@ -200,8 +200,8 @@ const clientComponentContent = {
|
|
|
200
200
|
content: {
|
|
201
201
|
myTranslatedContent: t({
|
|
202
202
|
en: "Hello World",
|
|
203
|
-
fr: "Bonjour le monde",
|
|
204
203
|
es: "Hola Mundo",
|
|
204
|
+
fr: "Bonjour le monde",
|
|
205
205
|
}),
|
|
206
206
|
numberOfCar: enu({
|
|
207
207
|
"<-1": "마이너스 1대 미만의 자동차",
|
|
@@ -110,8 +110,8 @@ const clientComponentContent = {
|
|
|
110
110
|
content: {
|
|
111
111
|
myTranslatedContent: t({
|
|
112
112
|
en: "Hello World",
|
|
113
|
-
fr: "Bonjour le monde",
|
|
114
113
|
es: "Hola Mundo",
|
|
114
|
+
fr: "Bonjour le monde",
|
|
115
115
|
}),
|
|
116
116
|
numberOfCar: enu({
|
|
117
117
|
"<-1": "Less than minus one car",
|
|
@@ -136,8 +136,8 @@ const clientComponentContent = {
|
|
|
136
136
|
content: {
|
|
137
137
|
myTranslatedContent: t({
|
|
138
138
|
en: "Hello World",
|
|
139
|
-
fr: "Bonjour le monde",
|
|
140
139
|
es: "Hola Mundo",
|
|
140
|
+
fr: "Bonjour le monde",
|
|
141
141
|
}),
|
|
142
142
|
numberOfCar: enu({
|
|
143
143
|
"<-1": "자동차 마이너스 1대 미만",
|
|
@@ -163,8 +163,8 @@ const clientComponentContent = {
|
|
|
163
163
|
content: {
|
|
164
164
|
myTranslatedContent: t({
|
|
165
165
|
en: "Hello World",
|
|
166
|
-
fr: "Bonjour le monde",
|
|
167
166
|
es: "Hola Mundo",
|
|
167
|
+
fr: "Bonjour le monde",
|
|
168
168
|
}),
|
|
169
169
|
numberOfCar: enu({
|
|
170
170
|
"<-1": "Less than minus one car", // -1보다 작은 자동차 수
|
|
@@ -110,8 +110,8 @@ const component1Content = {
|
|
|
110
110
|
content: {
|
|
111
111
|
myTranslatedContent: t({
|
|
112
112
|
en: "Hello World",
|
|
113
|
-
fr: "Bonjour le monde",
|
|
114
113
|
es: "Hola Mundo",
|
|
114
|
+
fr: "Bonjour le monde",
|
|
115
115
|
}),
|
|
116
116
|
numberOfCar: enu({
|
|
117
117
|
"<-1": "마이너스 1대 미만의 자동차",
|
|
@@ -136,8 +136,8 @@ const component1Content = {
|
|
|
136
136
|
content: {
|
|
137
137
|
myTranslatedContent: t({
|
|
138
138
|
en: "Hello World",
|
|
139
|
-
fr: "Bonjour le monde",
|
|
140
139
|
es: "Hola Mundo",
|
|
140
|
+
fr: "Bonjour le monde",
|
|
141
141
|
}),
|
|
142
142
|
numberOfCar: enu({
|
|
143
143
|
"<-1": "마이너스 1대 미만의 자동차",
|
|
@@ -162,8 +162,8 @@ const component1Content = {
|
|
|
162
162
|
content: {
|
|
163
163
|
myTranslatedContent: t({
|
|
164
164
|
en: "Hello World",
|
|
165
|
-
fr: "Bonjour le monde",
|
|
166
165
|
es: "Hola Mundo",
|
|
166
|
+
fr: "Bonjour le monde",
|
|
167
167
|
}),
|
|
168
168
|
numberOfCar: enu({
|
|
169
169
|
"<-1": "마이너스 1대 미만의 차",
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2024-08-13
|
|
3
|
+
updatedAt: 2025-08-20
|
|
4
|
+
title: Formatadores
|
|
5
|
+
description: Utilitários de formatação sensíveis à localidade baseados no Intl para números, percentuais, moeda, datas, tempo relativo, unidades e notação compacta. Inclui um helper Intl com cache.
|
|
6
|
+
keywords:
|
|
7
|
+
- Formatadores
|
|
8
|
+
- Intl
|
|
9
|
+
- Número
|
|
10
|
+
- Moeda
|
|
11
|
+
- Percentual
|
|
12
|
+
- Data
|
|
13
|
+
- Tempo Relativo
|
|
14
|
+
- Unidades
|
|
15
|
+
- Compacto
|
|
16
|
+
- Internacionalização
|
|
17
|
+
slugs:
|
|
18
|
+
- doc
|
|
19
|
+
- formatters
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Formatadores Intlayer
|
|
23
|
+
|
|
24
|
+
## Visão Geral
|
|
25
|
+
|
|
26
|
+
O Intlayer fornece um conjunto de helpers leves construídos sobre as APIs nativas `Intl`, além de um wrapper `Intl` com cache para evitar a construção repetida de formatadores pesados. Esses utilitários são totalmente sensíveis à localidade e podem ser usados a partir do pacote principal `intlayer`.
|
|
27
|
+
|
|
28
|
+
### Importação
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import {
|
|
32
|
+
Intl,
|
|
33
|
+
number,
|
|
34
|
+
percentage,
|
|
35
|
+
currency,
|
|
36
|
+
date,
|
|
37
|
+
relativeTime,
|
|
38
|
+
units,
|
|
39
|
+
compact,
|
|
40
|
+
} from "intlayer";
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Se você estiver usando React, hooks também estão disponíveis; veja `react-intlayer/format`.
|
|
44
|
+
|
|
45
|
+
## Intl com Cache
|
|
46
|
+
|
|
47
|
+
O `Intl` exportado é um wrapper leve com cache em torno do `Intl` global. Ele memoiza instâncias de `NumberFormat`, `DateTimeFormat`, `RelativeTimeFormat`, o que evita reconstruir o mesmo formatador repetidamente.
|
|
48
|
+
|
|
49
|
+
Como a construção do formatador é relativamente custosa, esse cache melhora a performance sem alterar o comportamento. O wrapper expõe a mesma API do `Intl` nativo, então o uso é idêntico.
|
|
50
|
+
|
|
51
|
+
- O cache é por processo e transparente para os chamadores.
|
|
52
|
+
|
|
53
|
+
> Se `Intl.DisplayNames` não estiver disponível no ambiente, um único aviso para desenvolvedores é exibido (considere usar um polyfill).
|
|
54
|
+
|
|
55
|
+
Exemplo:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { Intl } from "intlayer";
|
|
59
|
+
|
|
60
|
+
const numberFormat = new Intl.NumberFormat("en-GB", {
|
|
61
|
+
style: "currency",
|
|
62
|
+
currency: "GBP",
|
|
63
|
+
});
|
|
64
|
+
numberFormat.format(1234.5); // "£1,234.50"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Formatadores
|
|
68
|
+
|
|
69
|
+
Todos os helpers abaixo são exportados do `intlayer`.
|
|
70
|
+
|
|
71
|
+
### `number(value, options?)`
|
|
72
|
+
|
|
73
|
+
Formata um valor numérico usando agrupamento e decimais sensíveis ao local.
|
|
74
|
+
|
|
75
|
+
- **value**: `number | string`
|
|
76
|
+
- **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
|
|
77
|
+
|
|
78
|
+
Exemplos:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { number } from "intlayer";
|
|
82
|
+
|
|
83
|
+
number(123456.789); // "123,456.789" (em en-US)
|
|
84
|
+
number("1000000", { locale: "fr" }); // "1 000 000"
|
|
85
|
+
number(1234.5, { minimumFractionDigits: 2 }); // "1,234.50"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### `percentage(value, options?)`
|
|
89
|
+
|
|
90
|
+
Formata um número como uma string percentual.
|
|
91
|
+
|
|
92
|
+
Comportamento: valores maiores que 1 são interpretados como percentagens inteiras e normalizados (por exemplo, `25` → `25%`, `0.25` → `25%`).
|
|
93
|
+
|
|
94
|
+
- **value**: `number | string`
|
|
95
|
+
- **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
|
|
96
|
+
|
|
97
|
+
Exemplos:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { percentage } from "intlayer";
|
|
101
|
+
|
|
102
|
+
percentage(0.25); // "25%"
|
|
103
|
+
percentage(25); // "25%"
|
|
104
|
+
percentage(0.237, { minimumFractionDigits: 1 }); // "23.7%"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `currency(value, options?)`
|
|
108
|
+
|
|
109
|
+
Formata um valor como moeda localizada. O padrão é `USD` com duas casas decimais.
|
|
110
|
+
|
|
111
|
+
- **value**: `number | string`
|
|
112
|
+
- **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
|
|
113
|
+
- Campos comuns: `currency` (por exemplo, `"EUR"`), `currencyDisplay` (`"symbol" | "code" | "name"`)
|
|
114
|
+
|
|
115
|
+
Exemplos:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { currency } from "intlayer";
|
|
119
|
+
|
|
120
|
+
currency(1234.5, { currency: "EUR" }); // "€1.234,50"
|
|
121
|
+
currency("5000", { locale: "fr", currency: "CAD", currencyDisplay: "code" }); // "5 000,00 CAD"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `date(date, optionsOrPreset?)`
|
|
125
|
+
|
|
126
|
+
Formata um valor de data/hora com `Intl.DateTimeFormat`.
|
|
127
|
+
|
|
128
|
+
- **date**: `Date | string | number`
|
|
129
|
+
- **optionsOrPreset**: `Intl.DateTimeFormatOptions & { locale?: LocalesValues }` ou um dos predefinidos:
|
|
130
|
+
- Predefinidos: `"short" | "long" | "dateOnly" | "timeOnly" | "full"`
|
|
131
|
+
|
|
132
|
+
Exemplos:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import { date } from "intlayer";
|
|
136
|
+
|
|
137
|
+
date(new Date(), "short"); // ex., "08/02/25, 14:30"
|
|
138
|
+
date("2025-08-02T14:30:00Z", { locale: "fr", month: "long", day: "numeric" }); // "2 août"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### `relativeTime(from, to = new Date(), options?)`
|
|
142
|
+
|
|
143
|
+
Formata o tempo relativo entre dois instantes com `Intl.RelativeTimeFormat`.
|
|
144
|
+
|
|
145
|
+
- Passe "now" como o primeiro argumento e o alvo como o segundo para obter uma frase natural.
|
|
146
|
+
- **from**: `Date | string | number`
|
|
147
|
+
- **to**: `Date | string | number` (padrão é `new Date()`)
|
|
148
|
+
- **options**: `{ locale?: LocalesValues; unit?: Intl.RelativeTimeFormatUnit; numeric?: Intl.RelativeTimeFormatNumeric; style?: Intl.RelativeTimeFormatStyle }`
|
|
149
|
+
- O `unit` padrão é `"second"`.
|
|
150
|
+
|
|
151
|
+
Exemplos:
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { relativeTime } from "intlayer";
|
|
155
|
+
|
|
156
|
+
const now = new Date();
|
|
157
|
+
const in3Days = new Date(now.getTime() + 3 * 864e5);
|
|
158
|
+
relativeTime(now, in3Days, { unit: "day" }); // "em 3 dias"
|
|
159
|
+
|
|
160
|
+
const twoHoursAgo = new Date(now.getTime() - 2 * 3600e3);
|
|
161
|
+
relativeTime(now, twoHoursAgo, { unit: "hour", numeric: "auto" }); // "há 2 horas"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `units(value, options?)`
|
|
165
|
+
|
|
166
|
+
Formata um valor numérico como uma string de unidade localizada usando `Intl.NumberFormat` com `style: 'unit'`.
|
|
167
|
+
|
|
168
|
+
- **value**: `number | string`
|
|
169
|
+
- **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
|
|
170
|
+
- Campos comuns: `unit` (ex.: `"kilometer"`, `"byte"`), `unitDisplay` (`"short" | "narrow" | "long"`)
|
|
171
|
+
- Padrões: `unit: 'day'`, `unitDisplay: 'short'`, `useGrouping: false`
|
|
172
|
+
|
|
173
|
+
Exemplos:
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
import { units } from "intlayer";
|
|
177
|
+
|
|
178
|
+
units(5, { unit: "kilometer", unitDisplay: "long", locale: "en-GB" }); // "5 quilômetros"
|
|
179
|
+
units(1024, { unit: "byte", unitDisplay: "narrow" }); // "1.024B" (dependente do locale)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### `compact(value, options?)`
|
|
183
|
+
|
|
184
|
+
Formata um número usando notação compacta (ex.: `1.2K`, `1M`).
|
|
185
|
+
|
|
186
|
+
- **value**: `number | string`
|
|
187
|
+
- **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }` (usa `notation: 'compact'` internamente)
|
|
188
|
+
|
|
189
|
+
Exemplos:
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
import { compact } from "intlayer";
|
|
193
|
+
|
|
194
|
+
compact(1200); // "1.2K"
|
|
195
|
+
compact("1000000", { locale: "fr", compactDisplay: "long" }); // "1 milhão"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Notas
|
|
199
|
+
|
|
200
|
+
- Todos os helpers aceitam entradas do tipo `string`; elas são internamente convertidas para números ou datas.
|
|
201
|
+
- O locale padrão é o configurado em `internationalization.defaultLocale` caso não seja fornecido.
|
|
202
|
+
- Essas utilidades são wrappers simples; para formatações avançadas, utilize as opções padrão do `Intl`.
|
|
203
|
+
|
|
204
|
+
## Pontos de entrada e reexportações (`@index.ts`)
|
|
205
|
+
|
|
206
|
+
Os formatadores estão no pacote core e são reexportados por pacotes de nível superior para manter os imports ergonômicos em diferentes runtimes:
|
|
207
|
+
|
|
208
|
+
Exemplos:
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
// Código da aplicação (recomendado)
|
|
212
|
+
import { number, currency, date, Intl } from "intlayer";
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### React
|
|
216
|
+
|
|
217
|
+
Componentes cliente:
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import { useNumber, useCurrency, useDate } from "react-intlayer/format";
|
|
221
|
+
// ou em apps Next.js
|
|
222
|
+
import { useNumber, useCurrency, useDate } from "next-intlayer/client/format";
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Componentes servidor (ou runtime React Server):
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
import { useNumber, useCurrency, useDate } from "intlayer/server/format";
|
|
229
|
+
// ou em apps Next.js
|
|
230
|
+
import { useNumber, useCurrency, useDate } from "next-intlayer/server/format";
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
> Esses hooks considerarão o locale do `IntlayerProvider` ou `IntlayerServerProvider`
|
|
234
|
+
|
|
235
|
+
## Histórico da documentação
|
|
236
|
+
|
|
237
|
+
| Versão | Data | Alterações |
|
|
238
|
+
| ------ | ---------- | -------------------------------------- |
|
|
239
|
+
| 5.8.0 | 2025-08-18 | Adiciona documentação dos formatadores |
|