@intlayer/docs 5.8.0-canary.0 → 5.8.1-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 +2 -2
- package/blog/ar/next-i18next_vs_next-intl_vs_intlayer.md +96 -219
- package/blog/ar/react-i18next_vs_react-intl_vs_intlayer.md +88 -129
- package/blog/ar/vue-i18n_vs_intlayer.md +268 -0
- package/blog/de/intlayer_with_next-i18next.md +2 -2
- package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/de/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/de/vue-i18n_vs_intlayer.md +268 -0
- package/blog/en/intlayer_with_next-i18next.md +2 -2
- package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/en/react-i18next_vs_react-intl_vs_intlayer.md +88 -120
- package/blog/en/vue-i18n_vs_intlayer.md +276 -0
- package/blog/en-GB/intlayer_with_next-i18next.md +2 -2
- package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +85 -218
- package/blog/en-GB/react-i18next_vs_react-intl_vs_intlayer.md +80 -130
- package/blog/en-GB/vue-i18n_vs_intlayer.md +258 -0
- package/blog/es/intlayer_with_next-i18next.md +2 -2
- package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/es/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/es/vue-i18n_vs_intlayer.md +268 -0
- package/blog/fr/intlayer_with_next-i18next.md +2 -2
- package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +91 -214
- package/blog/fr/react-i18next_vs_react-intl_vs_intlayer.md +86 -127
- package/blog/fr/vue-i18n_vs_intlayer.md +269 -0
- package/blog/hi/intlayer_with_next-i18next.md +2 -2
- package/blog/hi/next-i18next_vs_next-intl_vs_intlayer.md +97 -220
- package/blog/hi/react-i18next_vs_react-intl_vs_intlayer.md +89 -130
- package/blog/hi/vue-i18n_vs_intlayer.md +268 -0
- package/blog/it/intlayer_with_next-i18next.md +2 -2
- package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +91 -214
- package/blog/it/react-i18next_vs_react-intl_vs_intlayer.md +86 -127
- package/blog/it/vue-i18n_vs_intlayer.md +268 -0
- package/blog/ja/intlayer_with_next-i18next.md +2 -2
- package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/ja/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/ja/vue-i18n_vs_intlayer.md +268 -0
- package/blog/ko/intlayer_with_next-i18next.md +2 -2
- package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +95 -217
- package/blog/ko/react-i18next_vs_react-intl_vs_intlayer.md +89 -130
- package/blog/ko/vue-i18n_vs_intlayer.md +268 -0
- package/blog/pt/intlayer_with_next-i18next.md +2 -2
- package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/pt/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/pt/vue-i18n_vs_intlayer.md +268 -0
- package/blog/ru/intlayer_with_next-i18next.md +2 -2
- package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +94 -217
- package/blog/ru/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/ru/vue-i18n_vs_intlayer.md +268 -0
- package/blog/zh/intlayer_with_next-i18next.md +2 -2
- package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/zh/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/zh/vue-i18n_vs_intlayer.md +269 -0
- package/dist/cjs/generated/blog.entry.cjs +41 -0
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +41 -0
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts +1 -0
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/docs/ar/formatters.md +417 -31
- package/docs/ar/how_works_intlayer.md +2 -4
- package/docs/ar/interest_of_intlayer.md +7 -10
- package/docs/ar/intlayer_CMS.md +2 -3
- package/docs/ar/intlayer_visual_editor.md +2 -3
- package/docs/ar/intlayer_with_tanstack.md +1 -1
- package/docs/ar/introduction.md +4 -4
- package/docs/de/formatters.md +444 -34
- package/docs/de/introduction.md +2 -2
- package/docs/en/dictionary/enumeration.md +2 -2
- package/docs/en/dictionary/function_fetching.md +2 -2
- package/docs/en/dictionary/get_started.md +2 -2
- package/docs/en/dictionary/translation.md +2 -2
- package/docs/en/formatters.md +383 -15
- package/docs/en/how_works_intlayer.md +2 -4
- package/docs/en/interest_of_intlayer.md +48 -29
- package/docs/en/intlayer_CMS.md +2 -3
- package/docs/en/intlayer_visual_editor.md +2 -3
- package/docs/en/intlayer_with_create_react_app.md +2 -2
- package/docs/en/intlayer_with_express.md +2 -2
- package/docs/en/intlayer_with_tanstack.md +1 -1
- package/docs/en/introduction.md +4 -4
- package/docs/en/packages/express-intlayer/index.md +2 -2
- package/docs/en/packages/intlayer/getConfiguration.md +2 -3
- package/docs/en/packages/intlayer/getEnumeration.md +2 -7
- package/docs/en/packages/intlayer/getHTMLTextDir.md +2 -4
- package/docs/en/packages/intlayer/getLocaleLang.md +2 -4
- package/docs/en/packages/intlayer/getLocaleName.md +2 -3
- package/docs/en/packages/intlayer/getLocalizedUrl.md +2 -8
- package/docs/en/packages/intlayer/getMultilingualUrls.md +2 -7
- package/docs/en/packages/intlayer/getPathWithoutLocale.md +2 -3
- package/docs/en/packages/intlayer/getTranslation.md +2 -4
- package/docs/en/packages/intlayer/index.md +2 -2
- package/docs/en/packages/next-intlayer/index.md +2 -2
- package/docs/en/packages/next-intlayer/t.md +2 -2
- package/docs/en/packages/next-intlayer/useDictionary.md +2 -2
- package/docs/en/packages/next-intlayer/useIntlayer.md +2 -2
- package/docs/en/packages/next-intlayer/useLocale.md +2 -2
- package/docs/en/packages/react-intlayer/index.md +2 -2
- package/docs/en/packages/react-intlayer/t.md +2 -2
- package/docs/en/packages/react-intlayer/useI18n.md +2 -2
- package/docs/en/packages/react-intlayer/useIntlayer.md +2 -2
- package/docs/en/packages/react-intlayer/useLocale.md +2 -2
- package/docs/en/packages/react-scripts-intlayer/index.md +2 -2
- package/docs/en/packages/solid-intlayer/index.md +2 -2
- package/docs/en/packages/vite-intlayer/index.md +2 -2
- package/docs/en-GB/formatters.md +402 -16
- package/docs/en-GB/how_works_intlayer.md +2 -4
- package/docs/en-GB/interest_of_intlayer.md +7 -10
- package/docs/en-GB/intlayer_with_tanstack.md +1 -1
- package/docs/en-GB/introduction.md +2 -2
- package/docs/es/formatters.md +438 -28
- package/docs/es/how_works_intlayer.md +2 -4
- package/docs/es/interest_of_intlayer.md +7 -10
- package/docs/es/intlayer_with_tanstack.md +1 -1
- package/docs/es/introduction.md +2 -2
- package/docs/fr/formatters.md +438 -28
- package/docs/fr/how_works_intlayer.md +2 -4
- package/docs/fr/interest_of_intlayer.md +7 -10
- package/docs/fr/intlayer_with_tanstack.md +1 -1
- package/docs/fr/introduction.md +2 -2
- package/docs/hi/formatters.md +430 -39
- package/docs/hi/how_works_intlayer.md +2 -4
- package/docs/hi/interest_of_intlayer.md +7 -10
- package/docs/hi/intlayer_with_tanstack.md +1 -1
- package/docs/hi/introduction.md +2 -2
- package/docs/it/formatters.md +438 -30
- package/docs/it/how_works_intlayer.md +2 -4
- package/docs/it/interest_of_intlayer.md +7 -10
- package/docs/it/intlayer_with_tanstack.md +1 -1
- package/docs/it/introduction.md +2 -2
- package/docs/ja/formatters.md +435 -47
- package/docs/ja/how_works_intlayer.md +2 -4
- package/docs/ja/interest_of_intlayer.md +7 -10
- package/docs/ja/intlayer_with_tanstack.md +1 -1
- package/docs/ja/introduction.md +2 -2
- package/docs/ko/formatters.md +432 -41
- package/docs/ko/how_works_intlayer.md +2 -4
- package/docs/ko/interest_of_intlayer.md +7 -10
- package/docs/ko/intlayer_with_tanstack.md +1 -1
- package/docs/ko/introduction.md +2 -2
- package/docs/pt/formatters.md +416 -30
- package/docs/pt/how_works_intlayer.md +2 -4
- package/docs/pt/intlayer_with_tanstack.md +1 -1
- package/docs/pt/introduction.md +2 -2
- package/docs/ru/autoFill.md +2 -2
- package/docs/ru/configuration.md +1 -40
- package/docs/ru/formatters.md +438 -28
- package/docs/ru/how_works_intlayer.md +5 -7
- package/docs/ru/index.md +1 -1
- package/docs/ru/interest_of_intlayer.md +8 -11
- package/docs/ru/intlayer_CMS.md +7 -8
- package/docs/ru/intlayer_cli.md +4 -7
- package/docs/ru/intlayer_visual_editor.md +5 -6
- package/docs/ru/intlayer_with_angular.md +1 -1
- package/docs/ru/intlayer_with_create_react_app.md +5 -5
- package/docs/ru/intlayer_with_lynx+react.md +1 -1
- package/docs/ru/intlayer_with_nextjs_15.md +3 -3
- package/docs/ru/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ru/intlayer_with_nuxt.md +1 -1
- package/docs/ru/intlayer_with_react_native+expo.md +2 -2
- package/docs/ru/intlayer_with_tanstack.md +3 -3
- package/docs/ru/intlayer_with_vite+preact.md +3 -3
- package/docs/ru/intlayer_with_vite+react.md +3 -3
- package/docs/ru/intlayer_with_vite+solid.md +1 -1
- package/docs/ru/intlayer_with_vite+svelte.md +1 -1
- package/docs/ru/intlayer_with_vite+vue.md +2 -2
- package/docs/ru/introduction.md +5 -5
- package/docs/ru/locale_mapper.md +1 -1
- package/docs/ru/packages/@intlayer/api/index.md +2 -2
- package/docs/ru/packages/@intlayer/chokidar/index.md +1 -1
- package/docs/ru/packages/@intlayer/cli/index.md +2 -2
- package/docs/ru/packages/@intlayer/config/index.md +2 -2
- package/docs/ru/packages/@intlayer/core/index.md +2 -2
- package/docs/ru/packages/@intlayer/design-system/index.md +2 -2
- package/docs/ru/packages/@intlayer/dictionary-entry/index.md +2 -2
- package/docs/ru/packages/@intlayer/editor/index.md +1 -1
- package/docs/ru/packages/@intlayer/editor-react/index.md +1 -1
- package/docs/ru/packages/@intlayer/webpack/index.md +1 -1
- package/docs/ru/packages/angular-intlayer/index.md +1 -1
- package/docs/ru/packages/express-intlayer/index.md +3 -3
- package/docs/ru/packages/express-intlayer/t.md +1 -1
- package/docs/ru/packages/intlayer/getEnumeration.md +3 -8
- package/docs/ru/packages/intlayer/getTranslation.md +3 -5
- package/docs/ru/packages/intlayer/getTranslationContent.md +1 -3
- package/docs/ru/packages/intlayer/index.md +3 -3
- package/docs/ru/packages/intlayer-cli/index.md +1 -1
- package/docs/ru/packages/intlayer-editor/index.md +2 -2
- package/docs/ru/packages/lynx-intlayer/index.md +1 -1
- package/docs/ru/packages/next-intlayer/index.md +4 -4
- package/docs/ru/packages/next-intlayer/t.md +4 -4
- package/docs/ru/packages/next-intlayer/useLocale.md +3 -3
- package/docs/ru/packages/nuxt-intlayer/index.md +1 -1
- package/docs/ru/packages/preact-intlayer/index.md +1 -1
- package/docs/ru/packages/react-intlayer/index.md +4 -4
- package/docs/ru/packages/react-intlayer/t.md +4 -4
- package/docs/ru/packages/react-native-intlayer/index.md +1 -1
- package/docs/ru/packages/react-scripts-intlayer/index.md +3 -3
- package/docs/ru/packages/solid-intlayer/index.md +3 -3
- package/docs/ru/packages/svelte-intlayer/index.md +1 -1
- package/docs/ru/packages/vite-intlayer/index.md +3 -3
- package/docs/ru/packages/vue-intlayer/index.md +1 -1
- package/docs/ru/per_locale_file.md +1 -1
- package/docs/ru/roadmap.md +3 -5
- package/docs/ru/vs_code_extension.md +1 -1
- package/docs/zh/formatters.md +446 -38
- package/docs/zh/how_works_intlayer.md +2 -4
- package/docs/zh/interest_of_intlayer.md +7 -10
- package/docs/zh/intlayer_with_tanstack.md +1 -1
- package/docs/zh/introduction.md +2 -2
- package/frequent_questions/ar/domain_routing.md +1 -1
- package/frequent_questions/en/domain_routing.md +1 -1
- package/frequent_questions/en-GB/domain_routing.md +1 -1
- package/frequent_questions/es/domain_routing.md +1 -1
- package/frequent_questions/fr/domain_routing.md +1 -1
- package/frequent_questions/hi/domain_routing.md +1 -1
- package/frequent_questions/it/domain_routing.md +1 -1
- package/frequent_questions/ko/domain_routing.md +1 -1
- package/frequent_questions/pt/domain_routing.md +1 -1
- package/frequent_questions/ru/domain_routing.md +1 -1
- package/frequent_questions/ru/get_locale_cookie.md +4 -4
- package/frequent_questions/ru/static_rendering.md +1 -2
- package/frequent_questions/zh/domain_routing.md +1 -1
- package/package.json +9 -11
- package/src/generated/blog.entry.ts +42 -1
|
@@ -197,25 +197,22 @@ const ComponentExample = () => {
|
|
|
197
197
|
- `.content.{{ts|mjs|cjs|json}}` फ़ाइलें VSCode एक्सटेंशन का उपयोग करके बनाई जा सकती हैं
|
|
198
198
|
- आपके IDE में ऑटो-कम्प्लीशन AI टूल्स (जैसे GitHub Copilot) आपकी सामग्री घोषित करने में मदद कर सकते हैं, जिससे कॉपी/पेस्ट कम हो जाता है
|
|
199
199
|
|
|
200
|
-
2. **अपने कोडबेस
|
|
200
|
+
2. **अपने कोडबेस को साफ़ करें**
|
|
201
|
+
- जटिलता को कम करें
|
|
202
|
+
- रखरखाव क्षमता बढ़ाएं
|
|
201
203
|
|
|
202
|
-
3. **अपने
|
|
203
|
-
|
|
204
|
-
4. **अपने कॉम्पोनेंट्स और उनके संबंधित कंटेंट को आसानी से डुप्लिकेट करें (उदाहरण: लॉगिन/रजिस्टर कॉम्पोनेंट्स, आदि)**
|
|
204
|
+
3. **अपने कॉम्पोनेंट्स और उनके संबंधित कंटेंट को आसानी से डुप्लिकेट करें (उदाहरण: लॉगिन/रजिस्टर कॉम्पोनेंट्स, आदि)**
|
|
205
205
|
- अन्य कॉम्पोनेंट्स की सामग्री को प्रभावित करने के जोखिम को सीमित करके
|
|
206
206
|
- अपनी सामग्री को एक एप्लिकेशन से दूसरे में बिना बाहरी निर्भरताओं के कॉपी/पेस्ट करके
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
- यदि आप
|
|
208
|
+
4. **अपने कोडबेस को अप्रयुक्त कॉम्पोनेंट्स के लिए अप्रयुक्त कुंजियों/मूल्यों से प्रदूषित होने से बचाएं**
|
|
209
|
+
- यदि आप कोई कॉम्पोनेंट नहीं उपयोग करते हैं, तो Intlayer संबंधित सामग्री को आयात नहीं करेगा
|
|
210
210
|
- यदि आप कोई कॉम्पोनेंट हटाते हैं, तो संबंधित सामग्री को हटाना आपको अधिक आसानी से याद रहेगा क्योंकि यह उसी फ़ोल्डर में मौजूद होगी
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
5. **अपने बहुभाषी कंटेंट को घोषित करने के लिए AI एजेंट्स की तर्क लागत कम करें**
|
|
213
213
|
- AI एजेंट को यह जानने के लिए आपके पूरे कोडबेस को स्कैन करने की आवश्यकता नहीं होगी कि आपकी सामग्री कहां लागू करनी है
|
|
214
214
|
- अनुवाद आसानी से आपके IDE में ऑटो-कम्प्लीशन AI टूल्स (जैसे GitHub Copilot) द्वारा किए जा सकते हैं
|
|
215
215
|
|
|
216
|
-
7. **लोडिंग प्रदर्शन को अनुकूलित करें**
|
|
217
|
-
- यदि कोई कॉम्पोनेंट लेज़ी-लोड होता है, तो उसकी संबंधित सामग्री भी उसी समय लोड होगी
|
|
218
|
-
|
|
219
216
|
## Intlayer की अतिरिक्त विशेषताएँ
|
|
220
217
|
|
|
221
218
|
| फीचर | विवरण |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2025-08-11
|
|
3
3
|
updatedAt: 2025-08-11
|
|
4
4
|
title: TanStack Start (React) में Intlayer के साथ शुरुआत करना
|
|
5
|
-
description: Intlayer का उपयोग करके अपने TanStack Start ऐप में i18n
|
|
5
|
+
description: Intlayer का उपयोग करके अपने TanStack Start ऐप में i18n जोड़ें-कंपोनेंट-स्तरीय शब्दकोश, स्थानीयकृत URL, और SEO-अनुकूल मेटाडेटा।
|
|
6
6
|
keywords:
|
|
7
7
|
- अंतरराष्ट्रीयकरण
|
|
8
8
|
- दस्तावेज़ीकरण
|
package/docs/hi/introduction.md
CHANGED
|
@@ -32,8 +32,8 @@ Intlayer एक वैकल्पिक दृश्य संपादक भ
|
|
|
32
32
|
.
|
|
33
33
|
└── Components
|
|
34
34
|
└── MyComponent
|
|
35
|
-
├── index.content.
|
|
36
|
-
└── index.
|
|
35
|
+
├── index.content.ts
|
|
36
|
+
└── index.tsx
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
```tsx fileName="src/components/MyComponent/index.content.ts" contentDeclarationFormat="typescript"
|
package/docs/it/formatters.md
CHANGED
|
@@ -13,6 +13,7 @@ keywords:
|
|
|
13
13
|
- Tempo Relativo
|
|
14
14
|
- Unità
|
|
15
15
|
- Compatto
|
|
16
|
+
- Lista
|
|
16
17
|
- Internazionalizzazione
|
|
17
18
|
slugs:
|
|
18
19
|
- doc
|
|
@@ -23,7 +24,7 @@ slugs:
|
|
|
23
24
|
|
|
24
25
|
## Panoramica
|
|
25
26
|
|
|
26
|
-
Intlayer fornisce un
|
|
27
|
+
Intlayer fornisce un set di helper leggeri costruiti sopra le API native `Intl`, oltre a un wrapper `Intl` con cache per evitare di costruire ripetutamente formattatori pesanti. Queste utilità sono completamente sensibili alla localizzazione e possono essere utilizzate dal pacchetto principale `intlayer`.
|
|
27
28
|
|
|
28
29
|
### Importazione
|
|
29
30
|
|
|
@@ -37,40 +38,302 @@ import {
|
|
|
37
38
|
relativeTime,
|
|
38
39
|
units,
|
|
39
40
|
compact,
|
|
40
|
-
|
|
41
|
+
list,
|
|
42
|
+
getLocaleName,
|
|
43
|
+
getLocaleLang,
|
|
44
|
+
getLocaleFromPath,
|
|
45
|
+
getPathWithoutLocale,
|
|
46
|
+
getLocalizedUrl,
|
|
47
|
+
getHTMLTextDir,
|
|
48
|
+
getContent,
|
|
49
|
+
getLocalisedContent,
|
|
50
|
+
getTranslation,
|
|
51
|
+
getIntlayer,
|
|
52
|
+
getIntlayerAsync,
|
|
53
|
+
} from "intlayer";
|
|
41
54
|
```
|
|
42
55
|
|
|
43
|
-
Se
|
|
56
|
+
Se stai usando React, sono disponibili anche gli hook; vedi `react-intlayer/format`.
|
|
44
57
|
|
|
45
58
|
## Intl con cache
|
|
46
59
|
|
|
47
|
-
L'`Intl` esportato è un sottile
|
|
60
|
+
L'`Intl` esportato è un wrapper sottile con cache attorno all'`Intl` globale. Memorizza in cache le istanze di `NumberFormat`, `DateTimeFormat`, `RelativeTimeFormat`, `ListFormat`, `DisplayNames`, `Collator` e `PluralRules`, evitando così di ricostruire ripetutamente lo stesso formattatore.
|
|
48
61
|
|
|
49
|
-
Poiché la costruzione del
|
|
62
|
+
Poiché la costruzione del formatter è relativamente costosa, questa cache migliora le prestazioni senza modificare il comportamento. Il wrapper espone la stessa API dell'`Intl` nativo, quindi l'uso è identico.
|
|
50
63
|
|
|
51
|
-
- La cache è per processo e trasparente per
|
|
64
|
+
- La cache è per processo e trasparente per i chiamanti.
|
|
52
65
|
|
|
53
|
-
> Se `Intl.DisplayNames` non è disponibile nell'ambiente, viene stampato un
|
|
66
|
+
> Se `Intl.DisplayNames` non è disponibile nell'ambiente, viene stampato un unico avviso solo per gli sviluppatori (considera un polyfill).
|
|
54
67
|
|
|
55
|
-
|
|
68
|
+
Esempi:
|
|
56
69
|
|
|
57
70
|
```ts
|
|
58
71
|
import { Intl } from "intlayer";
|
|
59
72
|
|
|
73
|
+
// Formattazione numerica
|
|
60
74
|
const numberFormat = new Intl.NumberFormat("en-GB", {
|
|
61
75
|
style: "currency",
|
|
62
76
|
currency: "GBP",
|
|
63
77
|
});
|
|
64
78
|
numberFormat.format(1234.5); // "£1,234.50"
|
|
79
|
+
|
|
80
|
+
// Nomi visualizzati per lingue, regioni, ecc.
|
|
81
|
+
const displayNames = new Intl.DisplayNames("fr", { type: "language" });
|
|
82
|
+
displayNames.of("en"); // "anglais"
|
|
83
|
+
|
|
84
|
+
// Ordinamento per confronto
|
|
85
|
+
const collator = new Intl.Collator("fr", { sensitivity: "base" });
|
|
86
|
+
collator.compare("é", "e"); // 0 (uguale)
|
|
87
|
+
|
|
88
|
+
// Regole plurali
|
|
89
|
+
const pluralRules = new Intl.PluralRules("fr");
|
|
90
|
+
pluralRules.select(1); // "one"
|
|
91
|
+
pluralRules.select(2); // "other"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Utilità aggiuntive di Intl
|
|
95
|
+
|
|
96
|
+
Oltre agli helper per i formatter, puoi anche utilizzare direttamente il wrapper Intl con cache per altre funzionalità Intl:
|
|
97
|
+
|
|
98
|
+
### `Intl.DisplayNames`
|
|
99
|
+
|
|
100
|
+
Per nomi localizzati di lingue, regioni, valute e script:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { Intl } from "intlayer";
|
|
104
|
+
|
|
105
|
+
const languageNames = new Intl.DisplayNames("en", { type: "language" });
|
|
106
|
+
languageNames.of("fr"); // "French"
|
|
107
|
+
|
|
108
|
+
const regionNames = new Intl.DisplayNames("fr", { type: "region" });
|
|
109
|
+
regionNames.of("US"); // "États-Unis"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### `Intl.Collator`
|
|
113
|
+
|
|
114
|
+
Per il confronto e l'ordinamento di stringhe sensibili alla localizzazione:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { Intl } from "intlayer";
|
|
118
|
+
|
|
119
|
+
const collator = new Intl.Collator("de", {
|
|
120
|
+
sensitivity: "base",
|
|
121
|
+
numeric: true,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const words = ["äpfel", "zebra", "100", "20"];
|
|
125
|
+
words.sort(collator.compare); // ["20", "100", "äpfel", "zebra"]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `Intl.PluralRules`
|
|
129
|
+
|
|
130
|
+
Per determinare le forme plurali in diverse localizzazioni:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { Intl } from "intlayer";
|
|
134
|
+
|
|
135
|
+
const pluralRules = new Intl.PluralRules("ar");
|
|
136
|
+
pluralRules.select(0); // "zero"
|
|
137
|
+
pluralRules.select(1); // "one"
|
|
138
|
+
pluralRules.select(2); // "two"
|
|
139
|
+
pluralRules.select(3); // "few"
|
|
140
|
+
pluralRules.select(11); // "many"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Utilità per le localizzazioni
|
|
144
|
+
|
|
145
|
+
### `getLocaleName(displayLocale, targetLocale?)`
|
|
146
|
+
|
|
147
|
+
Ottiene il nome localizzato di una localizzazione in un'altra localizzazione:
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { getLocaleName } from "intlayer";
|
|
151
|
+
|
|
152
|
+
getLocaleName("fr", "en"); // "French"
|
|
153
|
+
getLocaleName("en", "fr"); // "anglais"
|
|
154
|
+
getLocaleName("de", "es"); // "alemán"
|
|
65
155
|
```
|
|
66
156
|
|
|
67
|
-
|
|
157
|
+
- **displayLocale**: La localizzazione di cui ottenere il nome
|
|
158
|
+
- **targetLocale**: La localizzazione in cui visualizzare il nome (predefinita a displayLocale)
|
|
159
|
+
|
|
160
|
+
### `getLocaleLang(locale?)`
|
|
161
|
+
|
|
162
|
+
Estrae il codice della lingua da una stringa di localizzazione:
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import { getLocaleLang } from "intlayer";
|
|
166
|
+
|
|
167
|
+
getLocaleLang("en-US"); // "en"
|
|
168
|
+
getLocaleLang("fr-CA"); // "fr"
|
|
169
|
+
getLocaleLang("de"); // "de"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- **locale**: La localizzazione da cui estrarre la lingua (predefinita alla localizzazione corrente)
|
|
173
|
+
|
|
174
|
+
### `getLocaleFromPath(inputUrl)`
|
|
175
|
+
|
|
176
|
+
Estrae il segmento di localizzazione da un URL o pathname:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import { getLocaleFromPath } from "intlayer";
|
|
180
|
+
|
|
181
|
+
getLocaleFromPath("/en/dashboard"); // "en"
|
|
182
|
+
getLocaleFromPath("/fr/dashboard"); // "fr"
|
|
183
|
+
getLocaleFromPath("/dashboard"); // "en" (localizzazione predefinita)
|
|
184
|
+
getLocaleFromPath("https://example.com/es/about"); // "es"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
- **inputUrl**: La stringa URL completa o il percorso da elaborare
|
|
188
|
+
- **returns**: La localizzazione rilevata o la localizzazione predefinita se non viene trovata alcuna localizzazione
|
|
189
|
+
|
|
190
|
+
### `getPathWithoutLocale(inputUrl, locales?)`
|
|
191
|
+
|
|
192
|
+
Rimuove il segmento di localizzazione da un URL o percorso:
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import { getPathWithoutLocale } from "intlayer";
|
|
196
|
+
|
|
197
|
+
getPathWithoutLocale("/en/dashboard"); // "/dashboard"
|
|
198
|
+
getPathWithoutLocale("/fr/dashboard"); // "/dashboard"
|
|
199
|
+
getPathWithoutLocale("https://example.com/en/about"); // "https://example.com/about"
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
- **inputUrl**: La stringa URL completa o il percorso da elaborare
|
|
203
|
+
- **locales**: Array opzionale delle localizzazioni supportate (predefinito alle localizzazioni configurate)
|
|
204
|
+
- **returns**: L'URL senza il segmento della localizzazione
|
|
205
|
+
|
|
206
|
+
### `getLocalizedUrl(url, currentLocale, locales?, defaultLocale?, prefixDefault?)`
|
|
207
|
+
|
|
208
|
+
Genera un URL localizzato per la localizzazione corrente:
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
import { getLocalizedUrl } from "intlayer";
|
|
212
|
+
|
|
213
|
+
getLocalizedUrl("/about", "fr", ["en", "fr"], "en", false); // "/fr/about"
|
|
214
|
+
getLocalizedUrl("/about", "en", ["en", "fr"], "en", false); // "/about"
|
|
215
|
+
getLocalizedUrl("https://example.com/about", "fr", ["en", "fr"], "en", true); // "https://example.com/fr/about"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
- **url**: L'URL originale da localizzare
|
|
219
|
+
- **currentLocale**: La localizzazione corrente
|
|
220
|
+
- **locales**: Array opzionale delle localizzazioni supportate (predefinito alle localizzazioni configurate)
|
|
221
|
+
- **defaultLocale**: Localizzazione predefinita opzionale (predefinita alla localizzazione predefinita configurata)
|
|
222
|
+
- **prefixDefault**: Se aggiungere il prefisso alla localizzazione predefinita (predefinito al valore configurato)
|
|
223
|
+
|
|
224
|
+
### `getHTMLTextDir(locale?)`
|
|
225
|
+
|
|
226
|
+
Restituisce la direzione del testo per una localizzazione:
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
import { getHTMLTextDir } from "intlayer";
|
|
230
|
+
|
|
231
|
+
getHTMLTextDir("en-US"); // "ltr"
|
|
232
|
+
getHTMLTextDir("ar"); // "rtl"
|
|
233
|
+
getHTMLTextDir("he"); // "rtl"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
- **locale**: La localizzazione per cui ottenere la direzione del testo (predefinita alla localizzazione corrente)
|
|
237
|
+
- **returns**: `"ltr"`, `"rtl"`, o `"auto"`
|
|
238
|
+
|
|
239
|
+
## Utilità per la gestione dei contenuti
|
|
240
|
+
|
|
241
|
+
### `getContent(node, nodeProps, locale?)`
|
|
242
|
+
|
|
243
|
+
Trasforma un nodo di contenuto con tutti i plugin disponibili (traduzione, enumerazione, inserimento, ecc.):
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
import { getContent } from "intlayer";
|
|
247
|
+
|
|
248
|
+
const content = getContent(
|
|
249
|
+
contentNode,
|
|
250
|
+
{ dictionaryKey: "common", dictionaryPath: "/path/to/dict" },
|
|
251
|
+
"fr"
|
|
252
|
+
);
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
- **node**: Il nodo di contenuto da trasformare
|
|
256
|
+
- **nodeProps**: Proprietà per il contesto di trasformazione
|
|
257
|
+
- **locale**: Localizzazione opzionale (predefinita alla localizzazione predefinita configurata)
|
|
258
|
+
|
|
259
|
+
### `getLocalisedContent(node, locale, nodeProps, fallback?)`
|
|
260
|
+
|
|
261
|
+
Trasforma un nodo di contenuto utilizzando solo il plugin di traduzione:
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
import { getLocalisedContent } from "intlayer";
|
|
265
|
+
|
|
266
|
+
const content = getLocalisedContent(
|
|
267
|
+
contentNode,
|
|
268
|
+
"fr",
|
|
269
|
+
{ dictionaryKey: "common" },
|
|
270
|
+
true // fallback alla localizzazione predefinita se la traduzione manca
|
|
271
|
+
);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
- **node**: Il nodo di contenuto da trasformare
|
|
275
|
+
- **locale**: La localizzazione da usare per la traduzione
|
|
276
|
+
- **nodeProps**: Proprietà per il contesto di trasformazione
|
|
277
|
+
- **fallback**: Se effettuare il fallback alla lingua predefinita (default è false)
|
|
278
|
+
|
|
279
|
+
### `getTranslation(languageContent, locale?, fallback?)`
|
|
280
|
+
|
|
281
|
+
Estrae il contenuto per una specifica lingua da un oggetto contenente più lingue:
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
import { getTranslation } from "intlayer";
|
|
285
|
+
|
|
286
|
+
const content = getTranslation(
|
|
287
|
+
{
|
|
288
|
+
en: "Hello",
|
|
289
|
+
fr: "Bonjour",
|
|
290
|
+
de: "Hallo",
|
|
291
|
+
},
|
|
292
|
+
"fr",
|
|
293
|
+
true
|
|
294
|
+
); // "Bonjour"
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
- **languageContent**: Oggetto che mappa le lingue al contenuto
|
|
298
|
+
- **locale**: Lingua di destinazione (default è la lingua configurata come predefinita)
|
|
299
|
+
- **fallback**: Se effettuare il fallback alla lingua predefinita (default è true)
|
|
300
|
+
|
|
301
|
+
### `getIntlayer(dictionaryKey, locale?, plugins?)`
|
|
302
|
+
|
|
303
|
+
Recupera e trasforma il contenuto da un dizionario tramite la chiave:
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
import { getIntlayer } from "intlayer";
|
|
307
|
+
|
|
308
|
+
const content = getIntlayer("common", "fr");
|
|
309
|
+
const nestedContent = getIntlayer("common", "fr", customPlugins);
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
- **dictionaryKey**: La chiave del dizionario da recuperare
|
|
313
|
+
- **locale**: Locale opzionale (default è la locale configurata di default)
|
|
314
|
+
- **plugins**: Array opzionale di plugin di trasformazione personalizzati
|
|
315
|
+
|
|
316
|
+
### `getIntlayerAsync(dictionaryKey, locale?, plugins?)`
|
|
317
|
+
|
|
318
|
+
Recupera asincronamente contenuti da un dizionario remoto:
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
import { getIntlayerAsync } from "intlayer";
|
|
322
|
+
|
|
323
|
+
const content = await getIntlayerAsync("common", "fr");
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
- **dictionaryKey**: La chiave del dizionario da recuperare
|
|
327
|
+
- **locale**: Locale opzionale (default è la locale configurata di default)
|
|
328
|
+
- **plugins**: Array opzionale di plugin di trasformazione personalizzati
|
|
329
|
+
|
|
330
|
+
## Formatter
|
|
68
331
|
|
|
69
332
|
Tutti gli helper seguenti sono esportati da `intlayer`.
|
|
70
333
|
|
|
71
334
|
### `number(value, options?)`
|
|
72
335
|
|
|
73
|
-
Formatta un valore numerico utilizzando
|
|
336
|
+
Formatta un valore numerico utilizzando la separazione delle migliaia e i decimali in base alla localizzazione.
|
|
74
337
|
|
|
75
338
|
- **value**: `number | string`
|
|
76
339
|
- **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
|
|
@@ -81,7 +344,7 @@ Esempi:
|
|
|
81
344
|
import { number } from "intlayer";
|
|
82
345
|
|
|
83
346
|
number(123456.789); // "123,456.789" (in en-US)
|
|
84
|
-
number("1000000", { locale: "fr" }); // "1
|
|
347
|
+
number("1000000", { locale: "fr" }); // "1 000 000"
|
|
85
348
|
number(1234.5, { minimumFractionDigits: 2 }); // "1,234.50"
|
|
86
349
|
```
|
|
87
350
|
|
|
@@ -106,7 +369,7 @@ percentage(0.237, { minimumFractionDigits: 1 }); // "23.7%"
|
|
|
106
369
|
|
|
107
370
|
### `currency(value, options?)`
|
|
108
371
|
|
|
109
|
-
Formatta un valore come valuta localizzata. Il
|
|
372
|
+
Formatta un valore come valuta localizzata. Il valore predefinito è `USD` con due cifre decimali.
|
|
110
373
|
|
|
111
374
|
- **value**: `number | string`
|
|
112
375
|
- **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
|
|
@@ -117,8 +380,8 @@ Esempi:
|
|
|
117
380
|
```ts
|
|
118
381
|
import { currency } from "intlayer";
|
|
119
382
|
|
|
120
|
-
currency(1234.5, { currency: "EUR" }); // "€1.
|
|
121
|
-
currency("5000", { locale: "fr", currency: "CAD", currencyDisplay: "code" }); // "5
|
|
383
|
+
currency(1234.5, { currency: "EUR" }); // "€1,234.50"
|
|
384
|
+
currency("5000", { locale: "fr", currency: "CAD", currencyDisplay: "code" }); // "5 000,00 CAD"
|
|
122
385
|
```
|
|
123
386
|
|
|
124
387
|
### `date(date, optionsOrPreset?)`
|
|
@@ -142,11 +405,11 @@ date("2025-08-02T14:30:00Z", { locale: "fr", month: "long", day: "numeric" }); /
|
|
|
142
405
|
|
|
143
406
|
Formatta il tempo relativo tra due istanti con `Intl.RelativeTimeFormat`.
|
|
144
407
|
|
|
145
|
-
- Passa "now" come primo argomento e il target come secondo per ottenere una
|
|
408
|
+
- Passa "now" come primo argomento e il target come secondo per ottenere una frase naturale.
|
|
146
409
|
- **from**: `Date | string | number`
|
|
147
|
-
- **to**: `Date | string | number` (
|
|
410
|
+
- **to**: `Date | string | number` (default è `new Date()`)
|
|
148
411
|
- **options**: `{ locale?: LocalesValues; unit?: Intl.RelativeTimeFormatUnit; numeric?: Intl.RelativeTimeFormatNumeric; style?: Intl.RelativeTimeFormatStyle }`
|
|
149
|
-
- L'
|
|
412
|
+
- L'`unit` predefinita è `"second"`.
|
|
150
413
|
|
|
151
414
|
Esempi:
|
|
152
415
|
|
|
@@ -155,7 +418,7 @@ import { relativeTime } from "intlayer";
|
|
|
155
418
|
|
|
156
419
|
const now = new Date();
|
|
157
420
|
const in3Days = new Date(now.getTime() + 3 * 864e5);
|
|
158
|
-
relativeTime(now, in3Days, { unit: "day" }); // "
|
|
421
|
+
relativeTime(now, in3Days, { unit: "day" }); // "in 3 giorni"
|
|
159
422
|
|
|
160
423
|
const twoHoursAgo = new Date(now.getTime() - 2 * 3600e3);
|
|
161
424
|
relativeTime(now, twoHoursAgo, { unit: "hour", numeric: "auto" }); // "2 ore fa"
|
|
@@ -163,11 +426,11 @@ relativeTime(now, twoHoursAgo, { unit: "hour", numeric: "auto" }); // "2 ore fa"
|
|
|
163
426
|
|
|
164
427
|
### `units(value, options?)`
|
|
165
428
|
|
|
166
|
-
Formatta un valore numerico come stringa di unità localizzata
|
|
429
|
+
Formatta un valore numerico come stringa di unità localizzata usando `Intl.NumberFormat` con `style: 'unit'`.
|
|
167
430
|
|
|
168
431
|
- **value**: `number | string`
|
|
169
432
|
- **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }`
|
|
170
|
-
- Campi comuni: `unit` (es
|
|
433
|
+
- Campi comuni: `unit` (es., `"kilometer"`, `"byte"`), `unitDisplay` (`"short" | "narrow" | "long"`)
|
|
171
434
|
- Predefiniti: `unit: 'day'`, `unitDisplay: 'short'`, `useGrouping: false`
|
|
172
435
|
|
|
173
436
|
Esempi:
|
|
@@ -181,7 +444,7 @@ units(1024, { unit: "byte", unitDisplay: "narrow" }); // "1,024B" (dipendente da
|
|
|
181
444
|
|
|
182
445
|
### `compact(value, options?)`
|
|
183
446
|
|
|
184
|
-
Formatta un numero usando la notazione compatta (es
|
|
447
|
+
Formatta un numero usando la notazione compatta (es., `1.2K`, `1M`).
|
|
185
448
|
|
|
186
449
|
- **value**: `number | string`
|
|
187
450
|
- **options**: `Intl.NumberFormatOptions & { locale?: LocalesValues }` (usa internamente `notation: 'compact'`)
|
|
@@ -195,45 +458,190 @@ compact(1200); // "1.2K"
|
|
|
195
458
|
compact("1000000", { locale: "fr", compactDisplay: "long" }); // "1 million"
|
|
196
459
|
```
|
|
197
460
|
|
|
461
|
+
### `list(values, options?)`
|
|
462
|
+
|
|
463
|
+
Formatta un array di valori in una stringa di elenco localizzata utilizzando `Intl.ListFormat`.
|
|
464
|
+
|
|
465
|
+
- **values**: `(string | number)[]`
|
|
466
|
+
- **options**: `Intl.ListFormatOptions & { locale?: LocalesValues }`
|
|
467
|
+
- Campi comuni: `type` (`"conjunction" | "disjunction" | "unit"`), `style` (`"long" | "short" | "narrow"`)
|
|
468
|
+
- Predefiniti: `type: 'conjunction'`, `style: 'long'`
|
|
469
|
+
|
|
470
|
+
Esempi:
|
|
471
|
+
|
|
472
|
+
```ts
|
|
473
|
+
import { list } from "intlayer";
|
|
474
|
+
|
|
475
|
+
list(["apple", "banana", "orange"]); // "apple, banana, and orange"
|
|
476
|
+
list(["red", "green", "blue"], { locale: "fr", type: "disjunction" }); // "rouge, vert ou bleu"
|
|
477
|
+
list([1, 2, 3], { type: "unit" }); // "1, 2, 3"
|
|
478
|
+
```
|
|
479
|
+
|
|
198
480
|
## Note
|
|
199
481
|
|
|
200
482
|
- Tutti gli helper accettano input di tipo `string`; internamente vengono convertiti in numeri o date.
|
|
201
|
-
- La
|
|
202
|
-
- Queste utility sono semplici wrapper; per formattazioni avanzate,
|
|
483
|
+
- La localizzazione predefinita è quella configurata in `internationalization.defaultLocale` se non specificata.
|
|
484
|
+
- Queste utility sono dei semplici wrapper; per formattazioni avanzate, passare le opzioni standard di `Intl`.
|
|
203
485
|
|
|
204
486
|
## Punti di ingresso e re-export (`@index.ts`)
|
|
205
487
|
|
|
206
|
-
I formatter risiedono nel pacchetto core e
|
|
488
|
+
I formatter risiedono nel pacchetto core e vengono re-esportati da pacchetti di livello superiore per mantenere gli import ergonomici attraverso i runtime:
|
|
207
489
|
|
|
208
490
|
Esempi:
|
|
209
491
|
|
|
210
492
|
```ts
|
|
211
493
|
// Codice dell'app (consigliato)
|
|
212
|
-
import {
|
|
494
|
+
import {
|
|
495
|
+
number,
|
|
496
|
+
currency,
|
|
497
|
+
date,
|
|
498
|
+
relativeTime,
|
|
499
|
+
units,
|
|
500
|
+
compact,
|
|
501
|
+
list,
|
|
502
|
+
Intl,
|
|
503
|
+
getLocaleName,
|
|
504
|
+
getLocaleLang,
|
|
505
|
+
getLocaleFromPath,
|
|
506
|
+
getPathWithoutLocale,
|
|
507
|
+
getLocalizedUrl,
|
|
508
|
+
getHTMLTextDir,
|
|
509
|
+
getContent,
|
|
510
|
+
getLocalisedContent,
|
|
511
|
+
getTranslation,
|
|
512
|
+
getIntlayer,
|
|
513
|
+
getIntlayerAsync,
|
|
514
|
+
} da "intlayer";
|
|
213
515
|
```
|
|
214
516
|
|
|
215
517
|
### React
|
|
216
518
|
|
|
217
519
|
Componenti client:
|
|
218
520
|
|
|
219
|
-
```
|
|
220
|
-
import {
|
|
521
|
+
```tsx
|
|
522
|
+
import {
|
|
523
|
+
useNumber,
|
|
524
|
+
useCurrency,
|
|
525
|
+
useDate,
|
|
526
|
+
usePercentage,
|
|
527
|
+
useCompact,
|
|
528
|
+
useList,
|
|
529
|
+
useRelativeTime,
|
|
530
|
+
useUnit,
|
|
531
|
+
} da "react-intlayer/format";
|
|
221
532
|
// oppure nelle app Next.js
|
|
222
|
-
import {
|
|
533
|
+
import {
|
|
534
|
+
useNumber,
|
|
535
|
+
useCurrency,
|
|
536
|
+
useDate,
|
|
537
|
+
usePercentage,
|
|
538
|
+
useCompact,
|
|
539
|
+
useList,
|
|
540
|
+
useRelativeTime,
|
|
541
|
+
useUnit,
|
|
542
|
+
} da "next-intlayer/client/format";
|
|
543
|
+
|
|
544
|
+
const MyComponent = () => {
|
|
545
|
+
const number = useNumber();
|
|
546
|
+
const currency = useCurrency();
|
|
547
|
+
const date = useDate();
|
|
548
|
+
const percentage = usePercentage();
|
|
549
|
+
const compact = useCompact();
|
|
550
|
+
const list = useList();
|
|
551
|
+
const relativeTime = useRelativeTime();
|
|
552
|
+
const unit = useUnit();
|
|
553
|
+
|
|
554
|
+
return (
|
|
555
|
+
<div>
|
|
556
|
+
<p>{number(123456.789)}</p>
|
|
557
|
+
<p>{currency(1234.5, { currency: "EUR" })}</p>
|
|
558
|
+
<p>{date(new Date(), "short")}</p>
|
|
559
|
+
<p>{percentage(0.25)}</p>
|
|
560
|
+
<p>{compact(1200)}</p>
|
|
561
|
+
<p>{list(["apple", "banana", "orange"])}</p>
|
|
562
|
+
<p>{relativeTime(new Date(), new Date() + 1000)}</p>
|
|
563
|
+
<p>{unit(123456.789, { unit: "kilometer" })}</p>
|
|
564
|
+
</div>
|
|
565
|
+
);
|
|
566
|
+
};
|
|
223
567
|
```
|
|
224
568
|
|
|
225
569
|
Componenti server (o runtime React Server):
|
|
226
570
|
|
|
227
571
|
```ts
|
|
228
|
-
import {
|
|
572
|
+
import {
|
|
573
|
+
useNumber,
|
|
574
|
+
useCurrency,
|
|
575
|
+
useDate,
|
|
576
|
+
usePercentage,
|
|
577
|
+
useCompact,
|
|
578
|
+
useList,
|
|
579
|
+
useRelativeTime,
|
|
580
|
+
useUnit,
|
|
581
|
+
} from "react-intlayer/server/format";
|
|
229
582
|
// oppure nelle app Next.js
|
|
230
|
-
import {
|
|
583
|
+
import {
|
|
584
|
+
useNumber,
|
|
585
|
+
useCurrency,
|
|
586
|
+
useDate,
|
|
587
|
+
usePercentage,
|
|
588
|
+
useCompact,
|
|
589
|
+
useList,
|
|
590
|
+
useRelativeTime,
|
|
591
|
+
useUnit,
|
|
592
|
+
} from "next-intlayer/server/format";
|
|
231
593
|
```
|
|
232
594
|
|
|
233
595
|
> Questi hook considereranno la locale fornita da `IntlayerProvider` o `IntlayerServerProvider`
|
|
234
596
|
|
|
597
|
+
### Vue
|
|
598
|
+
|
|
599
|
+
Componenti client:
|
|
600
|
+
|
|
601
|
+
```ts
|
|
602
|
+
import {
|
|
603
|
+
useNumber,
|
|
604
|
+
useCurrency,
|
|
605
|
+
useDate,
|
|
606
|
+
usePercentage,
|
|
607
|
+
useCompact,
|
|
608
|
+
useList,
|
|
609
|
+
useRelativeTime,
|
|
610
|
+
useUnit,
|
|
611
|
+
} from "vue-intlayer/format";
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
> Questi composables considereranno la localizzazione dal `IntlayerProvider` iniettato
|
|
615
|
+
|
|
235
616
|
## Cronologia della documentazione
|
|
236
617
|
|
|
237
618
|
| Versione | Data | Modifiche |
|
|
238
619
|
| -------- | ---------- | ------------------------------------- |
|
|
620
|
+
| 5.8.0 | 2025-08-20 | Aggiunti formatter per Vue |
|
|
239
621
|
| 5.8.0 | 2025-08-18 | Aggiunta documentazione dei formatter |
|
|
622
|
+
|
|
623
|
+
Componenti client:
|
|
624
|
+
|
|
625
|
+
```ts
|
|
626
|
+
import {
|
|
627
|
+
useNumber,
|
|
628
|
+
useCurrency,
|
|
629
|
+
useDate,
|
|
630
|
+
usePercentage,
|
|
631
|
+
useCompact,
|
|
632
|
+
useList,
|
|
633
|
+
useRelativeTime,
|
|
634
|
+
useUnit,
|
|
635
|
+
} from "vue-intlayer/format";
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
> Questi composables considereranno la locale dal `IntlayerProvider` iniettato
|
|
639
|
+
|
|
640
|
+
## Cronologia della documentazione
|
|
641
|
+
|
|
642
|
+
| Versione | Data | Modifiche |
|
|
643
|
+
| -------- | ---------- | ----------------------------------------------------------------------------------------------------- |
|
|
644
|
+
| 5.8.0 | 2025-08-20 | Aggiunta documentazione del formatter per le liste |
|
|
645
|
+
| 5.8.0 | 2025-08-20 | Aggiunte ulteriori utility Intl (DisplayNames, Collator, PluralRules) |
|
|
646
|
+
| 5.8.0 | 2025-08-20 | Aggiunte utility per la gestione delle locale (getLocaleName, getLocaleLang, getLocaleFromPath, ecc.) |
|
|
647
|
+
| 5.8.0 | 2025-08-20 | Aggiunte utility per la gestione dei contenuti (getContent, getTranslation, getIntlayer, ecc.) |
|