@intlayer/docs 5.7.7 → 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.
Files changed (142) hide show
  1. package/blog/ar/intlayer_with_next-i18next.md +3 -4
  2. package/blog/ar/intlayer_with_next-intl.md +3 -4
  3. package/blog/ar/intlayer_with_react-i18next.md +1 -1
  4. package/blog/ar/intlayer_with_react-intl.md +1 -1
  5. package/blog/de/intlayer_with_next-i18next.md +3 -4
  6. package/blog/de/intlayer_with_react-intl.md +1 -1
  7. package/blog/en/intlayer_with_next-i18next.md +3 -4
  8. package/blog/en/intlayer_with_next-intl.md +3 -4
  9. package/blog/en/intlayer_with_react-i18next.md +1 -1
  10. package/blog/en/intlayer_with_react-intl.md +1 -1
  11. package/blog/en-GB/intlayer_with_next-i18next.md +3 -4
  12. package/blog/en-GB/intlayer_with_next-intl.md +3 -4
  13. package/blog/en-GB/intlayer_with_react-i18next.md +1 -1
  14. package/blog/en-GB/intlayer_with_react-intl.md +1 -1
  15. package/blog/es/intlayer_with_next-i18next.md +3 -4
  16. package/blog/es/intlayer_with_next-intl.md +3 -4
  17. package/blog/es/intlayer_with_react-i18next.md +1 -1
  18. package/blog/es/intlayer_with_react-intl.md +1 -1
  19. package/blog/fr/intlayer_with_next-i18next.md +3 -4
  20. package/blog/fr/intlayer_with_next-intl.md +3 -4
  21. package/blog/fr/intlayer_with_react-i18next.md +1 -1
  22. package/blog/fr/intlayer_with_react-intl.md +1 -1
  23. package/blog/hi/intlayer_with_next-i18next.md +3 -4
  24. package/blog/hi/intlayer_with_next-intl.md +3 -4
  25. package/blog/hi/intlayer_with_react-i18next.md +1 -1
  26. package/blog/hi/intlayer_with_react-intl.md +1 -1
  27. package/blog/it/intlayer_with_next-i18next.md +3 -4
  28. package/blog/it/intlayer_with_next-intl.md +3 -4
  29. package/blog/it/intlayer_with_react-i18next.md +1 -1
  30. package/blog/it/intlayer_with_react-intl.md +1 -1
  31. package/blog/ja/intlayer_with_next-i18next.md +3 -4
  32. package/blog/ja/intlayer_with_next-intl.md +3 -4
  33. package/blog/ja/intlayer_with_react-intl.md +1 -1
  34. package/blog/ko/intlayer_with_next-i18next.md +3 -4
  35. package/blog/ko/intlayer_with_next-intl.md +3 -4
  36. package/blog/ko/intlayer_with_react-intl.md +1 -1
  37. package/blog/pt/intlayer_with_next-i18next.md +3 -4
  38. package/blog/pt/intlayer_with_next-intl.md +3 -4
  39. package/blog/pt/intlayer_with_react-intl.md +1 -1
  40. package/blog/ru/intlayer_with_next-i18next.md +3 -4
  41. package/blog/ru/intlayer_with_next-intl.md +3 -4
  42. package/blog/ru/intlayer_with_react-i18next.md +1 -1
  43. package/blog/ru/intlayer_with_react-intl.md +1 -1
  44. package/blog/zh/intlayer_with_next-i18next.md +3 -4
  45. package/blog/zh/intlayer_with_next-intl.md +3 -4
  46. package/blog/zh/intlayer_with_react-i18next.md +1 -1
  47. package/blog/zh/intlayer_with_react-intl.md +1 -1
  48. package/dist/cjs/generated/docs.entry.cjs +41 -0
  49. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  50. package/dist/esm/generated/docs.entry.mjs +41 -0
  51. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  52. package/dist/types/generated/docs.entry.d.ts +1 -0
  53. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  54. package/docs/ar/CI_CD.md +67 -41
  55. package/docs/ar/formatters.md +239 -0
  56. package/docs/ar/interest_of_intlayer.md +162 -49
  57. package/docs/ar/introduction.md +3 -3
  58. package/docs/ar/packages/intlayer/index.md +3 -3
  59. package/docs/ar/packages/next-intlayer/index.md +3 -3
  60. package/docs/de/CI_CD.md +63 -37
  61. package/docs/de/formatters.md +239 -0
  62. package/docs/de/interest_of_intlayer.md +161 -47
  63. package/docs/de/introduction.md +3 -3
  64. package/docs/de/packages/intlayer/index.md +3 -3
  65. package/docs/de/packages/next-intlayer/index.md +3 -3
  66. package/docs/de/packages/react-intlayer/index.md +3 -3
  67. package/docs/en/CI_CD.md +51 -27
  68. package/docs/en/formatters.md +250 -0
  69. package/docs/en/interest_of_intlayer.md +159 -46
  70. package/docs/en/introduction.md +3 -3
  71. package/docs/en/packages/intlayer/index.md +3 -3
  72. package/docs/en/packages/next-intlayer/index.md +3 -3
  73. package/docs/en/packages/react-intlayer/index.md +3 -3
  74. package/docs/en-GB/CI_CD.md +58 -32
  75. package/docs/en-GB/formatters.md +239 -0
  76. package/docs/en-GB/interest_of_intlayer.md +160 -53
  77. package/docs/en-GB/packages/intlayer/index.md +3 -3
  78. package/docs/en-GB/packages/next-intlayer/index.md +3 -3
  79. package/docs/en-GB/packages/react-intlayer/index.md +3 -3
  80. package/docs/es/CI_CD.md +68 -42
  81. package/docs/es/formatters.md +239 -0
  82. package/docs/es/interest_of_intlayer.md +159 -47
  83. package/docs/es/introduction.md +3 -3
  84. package/docs/es/packages/intlayer/index.md +3 -3
  85. package/docs/es/packages/next-intlayer/index.md +3 -3
  86. package/docs/fr/formatters.md +239 -0
  87. package/docs/fr/interest_of_intlayer.md +160 -46
  88. package/docs/fr/introduction.md +3 -3
  89. package/docs/fr/packages/intlayer/index.md +3 -3
  90. package/docs/fr/packages/next-intlayer/index.md +3 -3
  91. package/docs/fr/packages/react-intlayer/index.md +3 -3
  92. package/docs/hi/CI_CD.md +69 -44
  93. package/docs/hi/formatters.md +239 -0
  94. package/docs/hi/interest_of_intlayer.md +158 -42
  95. package/docs/hi/introduction.md +3 -3
  96. package/docs/hi/packages/intlayer/index.md +3 -3
  97. package/docs/hi/packages/next-intlayer/index.md +3 -3
  98. package/docs/hi/packages/react-intlayer/index.md +3 -3
  99. package/docs/it/CI_CD.md +67 -41
  100. package/docs/it/formatters.md +239 -0
  101. package/docs/it/interest_of_intlayer.md +160 -46
  102. package/docs/it/introduction.md +3 -3
  103. package/docs/it/packages/intlayer/index.md +3 -3
  104. package/docs/it/packages/next-intlayer/index.md +3 -3
  105. package/docs/it/packages/react-intlayer/index.md +3 -3
  106. package/docs/ja/CI_CD.md +67 -41
  107. package/docs/ja/formatters.md +261 -0
  108. package/docs/ja/interest_of_intlayer.md +157 -48
  109. package/docs/ja/introduction.md +3 -3
  110. package/docs/ja/packages/intlayer/index.md +3 -3
  111. package/docs/ja/packages/next-intlayer/index.md +3 -3
  112. package/docs/ja/packages/react-intlayer/index.md +3 -3
  113. package/docs/ko/CI_CD.md +63 -37
  114. package/docs/ko/formatters.md +258 -0
  115. package/docs/ko/interest_of_intlayer.md +160 -48
  116. package/docs/ko/introduction.md +3 -3
  117. package/docs/ko/packages/intlayer/index.md +3 -3
  118. package/docs/ko/packages/next-intlayer/index.md +3 -3
  119. package/docs/ko/packages/react-intlayer/index.md +3 -3
  120. package/docs/pt/CI_CD.md +67 -41
  121. package/docs/pt/formatters.md +239 -0
  122. package/docs/pt/interest_of_intlayer.md +162 -47
  123. package/docs/pt/introduction.md +3 -3
  124. package/docs/pt/packages/intlayer/index.md +3 -3
  125. package/docs/pt/packages/next-intlayer/index.md +3 -3
  126. package/docs/pt/packages/react-intlayer/index.md +3 -3
  127. package/docs/ru/CI_CD.md +70 -44
  128. package/docs/ru/formatters.md +239 -0
  129. package/docs/ru/interest_of_intlayer.md +168 -50
  130. package/docs/ru/introduction.md +3 -3
  131. package/docs/ru/packages/intlayer/index.md +3 -3
  132. package/docs/ru/packages/next-intlayer/index.md +3 -3
  133. package/docs/ru/packages/react-intlayer/index.md +3 -3
  134. package/docs/zh/CI_CD.md +62 -36
  135. package/docs/zh/formatters.md +239 -0
  136. package/docs/zh/interest_of_intlayer.md +158 -48
  137. package/docs/zh/introduction.md +3 -3
  138. package/docs/zh/packages/intlayer/index.md +3 -3
  139. package/docs/zh/packages/next-intlayer/index.md +3 -3
  140. package/docs/zh/packages/react-intlayer/index.md +3 -3
  141. package/package.json +12 -12
  142. package/src/generated/docs.entry.ts +41 -0
@@ -149,8 +149,8 @@ const clientComponentContent = {
149
149
  content: {
150
150
  myTranslatedContent: t({
151
151
  en: "Hello World",
152
- fr: "Bonjour le monde",
153
152
  es: "Hola Mundo",
153
+ fr: "Bonjour le monde",
154
154
  }),
155
155
  numberOfCar: enu({
156
156
  "<-1": "Weniger als minus ein Auto",
@@ -175,8 +175,8 @@ const clientComponentContent = {
175
175
  content: {
176
176
  myTranslatedContent: t({
177
177
  en: "Hello World",
178
- fr: "Bonjour le monde",
179
178
  es: "Hola Mundo",
179
+ fr: "Bonjour le monde",
180
180
  }),
181
181
  numberOfCar: enu({
182
182
  "<-1": "Weniger als minus ein Auto",
@@ -201,8 +201,8 @@ const clientComponentContent = {
201
201
  content: {
202
202
  myTranslatedContent: t({
203
203
  en: "Hello World",
204
- fr: "Bonjour le monde",
205
204
  es: "Hola Mundo",
205
+ fr: "Bonjour le monde",
206
206
  }),
207
207
  numberOfCar: enu({
208
208
  "<-1": "Weniger als minus ein Auto",
@@ -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": "Weniger als minus ein Auto",
@@ -162,8 +162,8 @@ const clientComponentContent = {
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": "Weniger als minus ein Auto",
@@ -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": "Weniger als minus ein Auto",
@@ -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": "Weniger als minus ein Auto",
@@ -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": "Weniger als minus ein Auto",
package/docs/en/CI_CD.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  createdAt: 2025-05-20
3
- updatedAt: 2025-06-29
3
+ updatedAt: 2025-08-13
4
4
  title: CI/CD Integration
5
5
  description: Learn how to integrate Intlayer into your CI/CD pipeline for automated content management and deployment.
6
6
  keywords:
@@ -109,58 +109,82 @@ Intlayer provides a CLI command to autofill and review dictionary content. This
109
109
 
110
110
  ```yaml fileName=".github/workflows/intlayer-translate.yml"
111
111
  name: Intlayer Auto-Fill
112
+ # Trigger conditions for this workflow
112
113
  on:
113
- push:
114
- branches: [ main ]
115
- paths:
116
- - 'src/**'
117
114
  pull_request:
118
- branches: [ main ]
119
- paths:
120
- - 'src/**'
121
- workflow_dispatch: {}
115
+ branches:
116
+ - "main"
117
+
118
+ permissions:
119
+ contents: write
120
+ pull-requests: write
122
121
 
123
122
  concurrency:
124
- group: 'autofill-${{ github.ref }}'
123
+ group: "autofill-${{ github.ref }}"
125
124
  cancel-in-progress: true
126
125
 
127
126
  jobs:
128
127
  autofill:
129
128
  runs-on: ubuntu-latest
130
129
  env:
131
- INTLAYER_CLIENT_ID: ${{ secrets.INTLAYER_CLIENT_ID }}
132
- INTLAYER_CLIENT_SECRET: ${{ secrets.INTLAYER_CLIENT_SECRET }}
133
- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
130
+ # OpenAI
131
+ AI_MODEL: openai
132
+ AI_PROVIDER: gpt-5-mini
133
+ AI_API_KEY: ${{ secrets.AI_API_KEY }}
134
134
 
135
135
  steps:
136
+ # Step 1: Get the latest code from the repository
136
137
  - name: ⬇️ Checkout repository
137
- uses: actions/checkout@v3
138
+ uses: actions/checkout@v4
138
139
  with:
139
- persist-credentials: true
140
+ persist-credentials: true # Keep credentials for creating PRs
141
+ fetch-depth: 0 # Get full git history for diff analysis
140
142
 
143
+ # Step 2: Set up Node.js environment
141
144
  - name: 🟢 Set up Node.js
142
- uses: actions/setup-node@v3
145
+ uses: actions/setup-node@v4
143
146
  with:
144
- node-version: 20
147
+ node-version: 20 # Use Node.js 20 LTS for stability
145
148
 
149
+ # Step 3: Install project dependencies
146
150
  - name: 📦 Install dependencies
147
- run: npm ci
151
+ run: npm install
152
+
153
+ # Step 4: Install Intlayer CLI globally for translation management
154
+ - name: 📦 Install Intlayer
155
+ run: npm install -g intlayer-cli
148
156
 
157
+ # Step 5: Build the Intlayer project to generate translation files
149
158
  - name: ⚙️ Build Intlayer project
150
159
  run: npx intlayer build
151
160
 
161
+ # Step 6: Use AI to automatically fill missing translations
152
162
  - name: 🤖 Auto-fill missing translations
153
- run: npx intlayer fill --git-diff --mode fill
154
-
155
- - name: 📤 Create or update translation PR
156
- uses: peter-evans/create-pull-request@v4
157
- with:
158
- commit-message: chore: auto-fill missing translations [skip ci]
159
- branch: auto-translations
160
- title: chore: update missing translations
161
- labels: translation, automated
163
+ run: npx intlayer fill --git-diff --mode fill --provider $AI_PROVIDER --model $AI_MODEL --api-key $AI_API_KEY
164
+
165
+ # Step 7: Check if there are changes and commit them
166
+ - name: � Check for changes
167
+ id: check-changes
168
+ run: |
169
+ if [ -n "$(git status --porcelain)" ]; then
170
+ echo "has-changes=true" >> $GITHUB_OUTPUT
171
+ else
172
+ echo "has-changes=false" >> $GITHUB_OUTPUT
173
+ fi
174
+
175
+ # Step 8: Commit and push changes if any exist
176
+ - name: 📤 Commit and push changes
177
+ if: steps.check-changes.outputs.has-changes == 'true'
178
+ run: |
179
+ git config --local user.email "action@github.com"
180
+ git config --local user.name "GitHub Action"
181
+ git add .
182
+ git commit -m "chore: auto-fill missing translations [skip ci]"
183
+ git push origin HEAD:${{ github.head_ref }}
162
184
  ```
163
185
 
186
+ To set up the environment variables, go to GitHub → Settings → Secrets and variables → Actions and add the secret .
187
+
164
188
  > Same as for Husky, in the case of a monorepo, you can use the `--base-dir` argument to sequentially treat each app.
165
189
 
166
190
  > By default, the `--git-diff` argument filters dictionaries that include changes from base (default `origin/main`) to current branch (default: `HEAD`).
@@ -0,0 +1,250 @@
1
+ ---
2
+ createdAt: 2024-08-13
3
+ updatedAt: 2025-08-20
4
+ title: Formatters
5
+ description: Locale-aware formatting utilities based on Intl for numbers, percentages, currency, dates, relative time, units, and compact notation. Includes a cached Intl helper.
6
+ keywords:
7
+ - Formatters
8
+ - Intl
9
+ - Number
10
+ - Currency
11
+ - Percentage
12
+ - Date
13
+ - Relative Time
14
+ - Units
15
+ - Compact
16
+ - Internationalization
17
+ slugs:
18
+ - doc
19
+ - formatters
20
+ ---
21
+
22
+ # Intlayer Formatters
23
+
24
+ ## Overview
25
+
26
+ Intlayer provides a set of lightweight helpers built on top of the native `Intl` APIs, plus a cached `Intl` wrapper to avoid repeatedly constructing heavy formatters. These utilities are fully locale-aware and can be used from the main `intlayer` package.
27
+
28
+ ### Import
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
+ If you are using React, hooks are also available; see `react-intlayer/format`.
44
+
45
+ ## Cached Intl
46
+
47
+ The exported `Intl` is a thin, cached wrapper around the global `Intl`. It memoizes instances of `NumberFormat`, `DateTimeFormat`, `RelativeTimeFormat`, which avoids rebuilding the same formatter repeatedly.
48
+
49
+ Because formatter construction is relatively expensive, this caching improves performance without changing behavior. The wrapper exposes the same API as the native `Intl`, so usage is identical.
50
+
51
+ - Caching is per process and transparent to callers.
52
+
53
+ > If `Intl.DisplayNames` is not available in the environment, a single dev-only warning is printed (consider a polyfill).
54
+
55
+ Example:
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
+ ## Formatters
68
+
69
+ All helpers below are exported from `intlayer`.
70
+
71
+ ### `number(value, options?)`
72
+
73
+ Formats a numeric value using locale-aware grouping and decimals.
74
+
75
+ - **value**: `number | string`
76
+ - **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
77
+
78
+ Examples:
79
+
80
+ ```ts
81
+ import { number } from "intlayer";
82
+
83
+ number(123456.789); // "123,456.789" (in 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
+ Formats a number as a percentage string.
91
+
92
+ Behavior: values greater than 1 are interpreted as whole percentages and normalized (e.g., `25` → `25%`, `0.25` → `25%`).
93
+
94
+ - **value**: `number | string`
95
+ - **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
96
+
97
+ Examples:
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
+ Formats a value as localized currency. Defaults to `USD` with two fraction digits.
110
+
111
+ - **value**: `number | string`
112
+ - **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
113
+ - Common fields: `currency` (e.g., `"EUR"`), `currencyDisplay` (`"symbol" | "code" | "name"`)
114
+
115
+ Examples:
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
+ Formats a date/time value with `Intl.DateTimeFormat`.
127
+
128
+ - **date**: `Date | string | number`
129
+ - **optionsOrPreset**: `Intl.DateTimeFormatOptions & { locale?: LocalesValues }` or one of the presets:
130
+ - Presets: `"short" | "long" | "dateOnly" | "timeOnly" | "full"`
131
+
132
+ Examples:
133
+
134
+ ```ts
135
+ import { date } from "intlayer";
136
+
137
+ date(new Date(), "short"); // e.g., "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
+ Formats relative time between two instants with `Intl.RelativeTimeFormat`.
144
+
145
+ - Pass "now" as the first argument and the target as the second to get natural phrasing.
146
+ - **from**: `Date | string | number`
147
+ - **to**: `Date | string | number` (defaults to `new Date()`)
148
+ - **options**: `{ locale?: LocalesValues; unit?: Intl.RelativeTimeFormatUnit; numeric?: Intl.RelativeTimeFormatNumeric; style?: Intl.RelativeTimeFormatStyle }`
149
+ - Default `unit` is `"second"`.
150
+
151
+ Examples:
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" }); // "in 3 days"
159
+
160
+ const twoHoursAgo = new Date(now.getTime() - 2 * 3600e3);
161
+ relativeTime(now, twoHoursAgo, { unit: "hour", numeric: "auto" }); // "2 hours ago"
162
+ ```
163
+
164
+ ### `units(value, options?)`
165
+
166
+ Formats a numeric value as a localized unit string using `Intl.NumberFormat` with `style: 'unit'`.
167
+
168
+ - **value**: `number | string`
169
+ - **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
170
+ - Common fields: `unit` (e.g., `"kilometer"`, `"byte"`), `unitDisplay` (`"short" | "narrow" | "long"`)
171
+ - Defaults: `unit: 'day'`, `unitDisplay: 'short'`, `useGrouping: false`
172
+
173
+ Examples:
174
+
175
+ ```ts
176
+ import { units } from "intlayer";
177
+
178
+ units(5, { unit: "kilometer", unitDisplay: "long", locale: "en-GB" }); // "5 kilometers"
179
+ units(1024, { unit: "byte", unitDisplay: "narrow" }); // "1,024B" (locale-dependent)
180
+ ```
181
+
182
+ ### `compact(value, options?)`
183
+
184
+ Formats a number using compact notation (e.g., `1.2K`, `1M`).
185
+
186
+ - **value**: `number | string`
187
+ - **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }` (uses `notation: 'compact'` under the hood)
188
+
189
+ Examples:
190
+
191
+ ```ts
192
+ import { compact } from "intlayer";
193
+
194
+ compact(1200); // "1.2K"
195
+ compact("1000000", { locale: "fr", compactDisplay: "long" }); // "1 million"
196
+ ```
197
+
198
+ ## Notes
199
+
200
+ - All helpers accept `string` inputs; they are internally coerced to numbers or dates.
201
+ - Locale defaults to your configured `internationalization.defaultLocale` if not provided.
202
+ - These utilities are thin wrappers; for advanced formatting, pass through the standard `Intl` options.
203
+
204
+ ## Entry points and re-exports (`@index.ts`)
205
+
206
+ The formatters live in the core package and are re-exported from higher-level packages to keep imports ergonomic across runtimes:
207
+
208
+ Examples:
209
+
210
+ ```ts
211
+ // App code (recommended)
212
+ import { number, currency, date, Intl } from "intlayer";
213
+ ```
214
+
215
+ ### React
216
+
217
+ Client components:
218
+
219
+ ```ts
220
+ import { useNumber, useCurrency, useDate } from "react-intlayer/format";
221
+ // or in Next.js apps
222
+ import { useNumber, useCurrency, useDate } from "next-intlayer/client/format";
223
+ ```
224
+
225
+ Server components (or React Server runtime):
226
+
227
+ ```ts
228
+ import { useNumber, useCurrency, useDate } from "react-intlayer/server/format";
229
+ // or in Next.js apps
230
+ import { useNumber, useCurrency, useDate } from "next-intlayer/server/format";
231
+ ```
232
+
233
+ > That hooks will consider the locale from the `IntlayerProvider` or `IntlayerServerProvider`
234
+
235
+ ### Vue
236
+
237
+ Client components:
238
+
239
+ ```ts
240
+ import { useNumber, useCurrency, useDate } from "vue-intlayer/format";
241
+ ```
242
+
243
+ > That composables will consider the locale from the injected `IntlayerProvider`
244
+
245
+ ## Doc History
246
+
247
+ | Version | Date | Changes |
248
+ | ------- | ---------- | ---------------------------- |
249
+ | 5.8.0 | 2025-08-20 | Add vue formatters |
250
+ | 5.8.0 | 2025-08-18 | Add formatters documentation |