@intlayer/docs 8.4.5 → 8.4.6
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/dist/cjs/generated/docs.entry.cjs +20 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +20 -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/configuration.md +520 -722
- package/docs/ar/intlayer_with_storybook.md +521 -0
- package/docs/bn/configuration.md +922 -0
- package/docs/bn/intlayer_with_hono.md +428 -0
- package/docs/de/configuration.md +369 -743
- package/docs/de/intlayer_with_storybook.md +521 -0
- package/docs/en/configuration.md +181 -507
- package/docs/en/intlayer_with_storybook.md +521 -0
- package/docs/en-GB/configuration.md +456 -657
- package/docs/en-GB/intlayer_with_storybook.md +521 -0
- package/docs/es/configuration.md +379 -754
- package/docs/es/intlayer_with_storybook.md +521 -0
- package/docs/fr/configuration.md +376 -757
- package/docs/fr/intlayer_with_storybook.md +521 -0
- package/docs/hi/configuration.md +532 -728
- package/docs/hi/intlayer_with_storybook.md +521 -0
- package/docs/id/configuration.md +371 -684
- package/docs/id/intlayer_with_storybook.md +521 -0
- package/docs/it/configuration.md +397 -775
- package/docs/it/intlayer_with_storybook.md +521 -0
- package/docs/ja/configuration.md +525 -724
- package/docs/ja/intlayer_with_storybook.md +521 -0
- package/docs/ko/configuration.md +525 -724
- package/docs/ko/intlayer_with_storybook.md +521 -0
- package/docs/pl/configuration.md +430 -734
- package/docs/pl/intlayer_with_storybook.md +521 -0
- package/docs/pt/configuration.md +375 -746
- package/docs/pt/intlayer_with_storybook.md +521 -0
- package/docs/ru/configuration.md +532 -701
- package/docs/ru/intlayer_with_storybook.md +521 -0
- package/docs/tr/configuration.md +527 -719
- package/docs/tr/intlayer_with_storybook.md +521 -0
- package/docs/uk/configuration.md +425 -744
- package/docs/uk/intlayer_with_storybook.md +521 -0
- package/docs/ur/configuration.md +922 -0
- package/docs/ur/intlayer_with_hono.md +428 -0
- package/docs/vi/configuration.md +412 -753
- package/docs/vi/intlayer_with_storybook.md +521 -0
- package/docs/zh/configuration.md +521 -714
- package/docs/zh/intlayer_with_storybook.md +521 -0
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +20 -0
package/docs/en/configuration.md
CHANGED
|
@@ -14,6 +14,9 @@ slugs:
|
|
|
14
14
|
- concept
|
|
15
15
|
- configuration
|
|
16
16
|
history:
|
|
17
|
+
- version: 8.4.0
|
|
18
|
+
date: 2026-03-20
|
|
19
|
+
changes: Add object per-locale notation for 'compiler.output' and 'dictionary.fill'
|
|
17
20
|
- version: 8.3.0
|
|
18
21
|
date: 2026-03-11
|
|
19
22
|
changes: Move 'baseDir' from 'content' to 'system' config
|
|
@@ -560,35 +563,12 @@ The following sections describe the various configuration settings available for
|
|
|
560
563
|
|
|
561
564
|
Defines settings related to internationalization, including available locales and the default locale for the application.
|
|
562
565
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
- _Example_: `['en', 'fr', 'es']`
|
|
570
|
-
|
|
571
|
-
- **requiredLocales**:
|
|
572
|
-
- _Type_: `string[]`
|
|
573
|
-
- _Default_: `[]`
|
|
574
|
-
- _Description_: The list of required locales in the application.
|
|
575
|
-
- _Example_: `[]`
|
|
576
|
-
- _Note_: If empty, all locales are required in `strict` mode.
|
|
577
|
-
- _Note_: Ensure required locales are also defined in the `locales` field.
|
|
578
|
-
- **strictMode**:
|
|
579
|
-
- _Type_: `string`
|
|
580
|
-
- _Default_: `inclusive`
|
|
581
|
-
- _Description_: Ensure strong implementations of internationalized content using typescript.
|
|
582
|
-
- _Note_: If set to "strict", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.
|
|
583
|
-
- _Note_: If set to "inclusive", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exists.
|
|
584
|
-
- _Note_: If set to "loose", the translation `t` function will accept any existing locale.
|
|
585
|
-
|
|
586
|
-
- **defaultLocale**:
|
|
587
|
-
- _Type_: `string`
|
|
588
|
-
- _Default_: `Locales.ENGLISH`
|
|
589
|
-
- _Description_: The default locale used as a fallback if the requested locale is not found.
|
|
590
|
-
- _Example_: `'en'`
|
|
591
|
-
- _Note_: This is used to determine the locale when none is specified in the URL, cookie, or header.
|
|
566
|
+
| Field | Type | Description | Example | Note |
|
|
567
|
+
| ----------------- | ---------- | ------------------------------------------------------------------------------------------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
568
|
+
| `locales` | `string[]` | The list of supported locales in the application. Default: `[Locales.ENGLISH]` | `['en', 'fr', 'es']` | |
|
|
569
|
+
| `requiredLocales` | `string[]` | The list of required locales in the application. Default: `[]` | `[]` | If empty, all locales are required in `strict` mode. Ensure required locales are also defined in the `locales` field. |
|
|
570
|
+
| `strictMode` | `string` | Ensure strong implementations of internationalized content using TypeScript. Default: `inclusive` | | If `"strict"`: the `t` function requires each declared locale to be defined — throws an error if one is missing or undeclared. If `"inclusive"`: warns on missing locales but accepts undeclared ones that exist. If `"loose"`: accepts any existing locale. |
|
|
571
|
+
| `defaultLocale` | `string` | The default locale used as a fallback if the requested locale is not found. Default: `Locales.ENGLISH` | `'en'` | Used to determine the locale when none is specified in the URL, cookie, or header. |
|
|
592
572
|
|
|
593
573
|
---
|
|
594
574
|
|
|
@@ -596,198 +576,85 @@ Defines settings related to internationalization, including available locales an
|
|
|
596
576
|
|
|
597
577
|
Defines settings related to the integrated editor, including server port and active status.
|
|
598
578
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
- _Default_: `8000`
|
|
614
|
-
- _Description_: The port used by the visual editor server.
|
|
615
|
-
|
|
616
|
-
- **editorURL**:
|
|
617
|
-
- _Type_: `string`
|
|
618
|
-
- _Default_: `'http://localhost:8000'`
|
|
619
|
-
- _Description_: The URL of the editor server. Used to restrict the origin of the editor for security reasons.
|
|
620
|
-
- `'http://localhost:3000'`
|
|
621
|
-
- `'https://example.com'`
|
|
622
|
-
- `process.env.INTLAYER_EDITOR_URL`
|
|
623
|
-
- _Note_: The URL of the editor server to reach from the application. Used to restrict the origins that can interact with the application for security reasons. If set to `'*'`, the editor is accessible from any origin. Should be set if port is changed, or if the editor is hosted on a different domain.
|
|
624
|
-
|
|
625
|
-
- **cmsURL**:
|
|
626
|
-
- _Type_: `string`
|
|
627
|
-
- _Default_: `'https://intlayer.org'`
|
|
628
|
-
- _Description_: The URL of the Intlayer CMS.
|
|
629
|
-
- _Example_: `'https://intlayer.org'`
|
|
630
|
-
- _Note_: The URL of the Intlayer CMS.
|
|
631
|
-
|
|
632
|
-
- **backendURL**:
|
|
633
|
-
- _Type_: `string`
|
|
634
|
-
- _Default_: `https://back.intlayer.org`
|
|
635
|
-
- _Description_: The URL of the backend server.
|
|
636
|
-
- _Example_: `http://localhost:4000`
|
|
637
|
-
|
|
638
|
-
- **enabled**:
|
|
639
|
-
- _Type_: `boolean`
|
|
640
|
-
- _Default_: `true`
|
|
641
|
-
- _Description_: Indicates if the application interact with the visual editor.
|
|
642
|
-
- _Example_: `process.env.NODE_ENV !== 'production'`
|
|
643
|
-
- _Note_: If true, the editor will be able to interact with the application. If false, the editor will not be able to interact with the application. In any case, the editor can only be enabled by the visual editor. Disabling the editor for specific environments is a way to enforce the security.
|
|
644
|
-
|
|
645
|
-
- **clientId**:
|
|
646
|
-
- _Type_: `string` | `undefined`
|
|
647
|
-
- _Default_: `undefined`
|
|
648
|
-
- _Description_: clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication. An access token is used to authenticate the user related to the project. To get an access token, go to https://app.intlayer.org/project and create an account.
|
|
649
|
-
- _Example_: `true`
|
|
650
|
-
- _Note_: Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
|
|
651
|
-
|
|
652
|
-
- **clientSecret**:
|
|
653
|
-
- _Type_: `string` | `undefined`
|
|
654
|
-
- _Default_: `undefined`
|
|
655
|
-
- _Description_: clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication. An access token is used to authenticate the user related to the project. To get an access token, go to https://app.intlayer.org/project and create an account.
|
|
656
|
-
- _Example_: `true`
|
|
657
|
-
- _Note_: Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
|
|
658
|
-
|
|
659
|
-
- **dictionaryPriorityStrategy**:
|
|
660
|
-
- _Type_: `string`
|
|
661
|
-
- _Default_: `'local_first'`
|
|
662
|
-
- _Description_: The strategy to prioritize dictionaries in the case of both local and distant dictionaries being present. If set to `'distant_first'`, the application will prioritize distant dictionaries over local dictionaries. If set to `'local_first'`, the application will prioritize local dictionaries over distant dictionaries.
|
|
663
|
-
- _Example_: `'distant_first'`
|
|
664
|
-
|
|
665
|
-
- **liveSync**:
|
|
666
|
-
- _Type_: `boolean`
|
|
667
|
-
- _Default_: `true`
|
|
668
|
-
- _Description_: Indicates if the application server should hot reload the content of the application when a change is detected on the CMS / Visual Editor / Backend.
|
|
669
|
-
- _Example_: `true`
|
|
670
|
-
- _Note_: For example, when a new dictionary is added or updated, the application will update the content to display in the page.
|
|
671
|
-
- _Note_: Live sync need to externalize the content of the application to another server. That means that it can slightly impact the performance of the application. To limit this, we recommand to host the application and the live sync server on the same machine. Also, the combination of live sync and `optimize` can apply a consequent number of requests to the live sync server. Depending of your infrastructure, we recommand to test both options and their combination.
|
|
672
|
-
|
|
673
|
-
- **liveSyncPort**:
|
|
674
|
-
- _Type_: `number`
|
|
675
|
-
- _Default_: `4000`
|
|
676
|
-
- _Description_: The port of the live sync server.
|
|
677
|
-
- _Example_: `4000`
|
|
678
|
-
- _Note_: The port of the live sync server.
|
|
679
|
-
|
|
680
|
-
- **liveSyncURL**:
|
|
681
|
-
- _Type_: `string`
|
|
682
|
-
- _Default_: `'http://localhost:{liveSyncPort}'`
|
|
683
|
-
- _Description_: The URL of the live sync server.
|
|
684
|
-
- _Example_: `'https://example.com'`
|
|
685
|
-
- _Note_: Point to localhost by default but can be changed to any URL in the case of a remote live sync server.
|
|
579
|
+
| Field | Type | Description | Example | Note |
|
|
580
|
+
| ---------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
581
|
+
| `applicationURL` | `string` | The URL of the application. Default: `''` | `'http://localhost:3000'`, `'https://example.com'`, `process.env.INTLAYER_EDITOR_URL` | Used to restrict the origin of the editor for security reasons. If set to `'*'`, the editor is accessible from any origin. |
|
|
582
|
+
| `port` | `number` | The port used by the visual editor server. Default: `8000` | | |
|
|
583
|
+
| `editorURL` | `string` | The URL of the editor server. Default: `'http://localhost:8000'` | `'http://localhost:3000'`, `'https://example.com'`, `process.env.INTLAYER_EDITOR_URL` | Used to restrict the origins that can interact with the application. If set to `'*'`, accessible from any origin. Should be set if port is changed or editor is hosted on a different domain. |
|
|
584
|
+
| `cmsURL` | `string` | The URL of the Intlayer CMS. Default: `'https://intlayer.org'` | `'https://intlayer.org'` | |
|
|
585
|
+
| `backendURL` | `string` | The URL of the backend server. Default: `https://back.intlayer.org` | `http://localhost:4000` | |
|
|
586
|
+
| `enabled` | `boolean` | Indicates if the application interacts with the visual editor. Default: `true` | `process.env.NODE_ENV !== 'production'` | If `false`, the editor cannot interact with the application. Disabling for specific environments enforces security. |
|
|
587
|
+
| `clientId` | `string | undefined` | Allows intlayer packages to authenticate with the backend using oAuth2. To get an access token, go to [intlayer.org/project](https://app.intlayer.org/project). Default: `undefined` | | Keep secret; store in environment variables. |
|
|
588
|
+
| `clientSecret` | `string | undefined` | Allows intlayer packages to authenticate with the backend using oAuth2. To get an access token, go to [intlayer.org/project](https://app.intlayer.org/project). Default: `undefined` | | Keep secret; store in environment variables. |
|
|
589
|
+
| `dictionaryPriorityStrategy` | `string` | Strategy to prioritize dictionaries when both local and distant are present. Default: `'local_first'` | `'distant_first'` | `'distant_first'`: prioritizes distant over local. `'local_first'`: prioritizes local over distant. |
|
|
590
|
+
| `liveSync` | `boolean` | Indicates if the app server should hot reload content when a change is detected on the CMS / Visual Editor / Backend. Default: `true` | `true` | When a dictionary is added/updated, the app updates page content. Live sync externalizes content to another server, which may slightly impact performance. Recommend hosting both on the same machine. |
|
|
591
|
+
| `liveSyncPort` | `number` | The port of the live sync server. Default: `4000` | `4000` | |
|
|
592
|
+
| `liveSyncURL` | `string` | The URL of the live sync server. Default: `'http://localhost:{liveSyncPort}'` | `'https://example.com'` | Points to localhost by default; can be changed for a remote live sync server. |
|
|
686
593
|
|
|
687
594
|
### Routing Configuration
|
|
688
595
|
|
|
689
596
|
Settings that control routing behavior, including URL structure, locale storage, and middleware handling.
|
|
690
597
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
- _Note_: Useful in API calls for maintaining consistent language settings across requests.
|
|
729
|
-
- _Note_: Header is only accessible on the server side, the client side will not be able to access it.
|
|
730
|
-
- _Note_: Header name is customizable if set as StorageAttributes (`{ type: 'header', name: 'custom-locale' }`).
|
|
731
|
-
|
|
732
|
-
- **basePath**:
|
|
733
|
-
- _Type_: `string`
|
|
734
|
-
- _Default_: `''`
|
|
735
|
-
- _Description_: The base path for the application URLs.
|
|
736
|
-
- _Example_: `'/my-app'`
|
|
737
|
-
- _Note_:
|
|
738
|
-
- If the application is hosted at `https://example.com/my-app`
|
|
739
|
-
- The base path is `'/my-app'`
|
|
740
|
-
- The URL will be `https://example.com/my-app/en`
|
|
741
|
-
- If the base path is not set, the URL will be `https://example.com/en`
|
|
742
|
-
|
|
743
|
-
- **rewrite**:
|
|
744
|
-
- _Type_: `Record<string, StrictModeLocaleMap<string>>`
|
|
745
|
-
- _Default_: `undefined`
|
|
746
|
-
- _Description_: Custom URL rewriting rules that override the default routing mode for specific paths. Allows you to define locale-specific paths that differ from the standard routing behavior. Supports dynamic route parameters using `[param]` syntax.
|
|
747
|
-
- _Example_:
|
|
748
|
-
```typescript
|
|
749
|
-
routing: {
|
|
750
|
-
mode: "prefix-no-default", // Fallback strategy
|
|
751
|
-
rewrite: nextjsRewrite({
|
|
752
|
-
"/about": {
|
|
753
|
-
en: "/about",
|
|
754
|
-
fr: "/a-propos",
|
|
755
|
-
},
|
|
756
|
-
"/product/[slug]": {
|
|
757
|
-
en: "/product/[slug]",
|
|
758
|
-
fr: "/produit/[slug]",
|
|
759
|
-
},
|
|
760
|
-
"/blog/[category]/[id]": {
|
|
761
|
-
en: "/blog/[category]/[id]",
|
|
762
|
-
fr: "/journal/[category]/[id]",
|
|
763
|
-
},
|
|
764
|
-
}),
|
|
765
|
-
}
|
|
766
|
-
```
|
|
767
|
-
- _Note_: The rewrite rules take precedence over the default `mode` behavior. If a path matches a rewrite rule, the localized path from the rewrite configuration will be used instead of the standard locale prefixing.
|
|
768
|
-
- _Note_: Dynamic route parameters are supported using bracket notation (e.g., `[slug]`, `[id]`). The parameter values are automatically extracted from the URL and interpolated into the rewritten path.
|
|
769
|
-
- _Note_: Works with both Next.js and Vite applications. The middleware/proxy will automatically rewrite incoming requests to match the internal route structure.
|
|
770
|
-
- _Note_: When generating URLs with `getLocalizedUrl()`, the rewrite rules are automatically applied if they match the provided path.
|
|
771
|
-
- _Reference_: For more information, see [Custom URL Rewrites](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/custom_url_rewrites.md).
|
|
598
|
+
| Field | Type | Description | Example | Note |
|
|
599
|
+
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
600
|
+
| `mode` | `'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params'` | URL routing mode for locale handling. Default: `'prefix-no-default'` | `'prefix-no-default'`: `/dashboard` (en) or `/fr/dashboard` (fr). `'prefix-all'`: `/en/dashboard`. `'no-prefix'`: locale handled via other means. `'search-params'`: `/dashboard?locale=fr` | Does not impact cookie or locale storage management. |
|
|
601
|
+
| `storage` | `false | 'cookie' | 'localStorage' | 'sessionStorage' | 'header' | CookiesAttributes | StorageAttributes | Array` | Configuration for storing the locale in the client. Default: `['cookie', 'header']` | `'localStorage'`, `[{ type: 'cookie', name: 'custom-locale', secure: true }]` | See Storage Options table below. |
|
|
602
|
+
| `basePath` | `string` | The base path for the application URLs. Default: `''` | `'/my-app'` | If app is at `https://example.com/my-app`, basePath is `'/my-app'` and URLs become `https://example.com/my-app/en`. |
|
|
603
|
+
| `rewrite` | `Record<string, StrictModeLocaleMap<string>>` | Custom URL rewriting rules that override the default routing mode for specific paths. Supports `[param]` dynamic parameters. Default: `undefined` | See example below | Rewrite rules take precedence over `mode`. Works with Next.js and Vite. `getLocalizedUrl()` automatically applies matching rules. See [Custom URL Rewrites](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/custom_url_rewrites.md). |
|
|
604
|
+
|
|
605
|
+
**`rewrite` example**:
|
|
606
|
+
|
|
607
|
+
```typescript
|
|
608
|
+
routing: {
|
|
609
|
+
mode: "prefix-no-default", // Fallback strategy
|
|
610
|
+
rewrite: nextjsRewrite({
|
|
611
|
+
"/about": {
|
|
612
|
+
en: "/about",
|
|
613
|
+
fr: "/a-propos",
|
|
614
|
+
},
|
|
615
|
+
"/product/[slug]": {
|
|
616
|
+
en: "/product/[slug]",
|
|
617
|
+
fr: "/produit/[slug]",
|
|
618
|
+
},
|
|
619
|
+
"/blog/[category]/[id]": {
|
|
620
|
+
en: "/blog/[category]/[id]",
|
|
621
|
+
fr: "/journal/[category]/[id]",
|
|
622
|
+
},
|
|
623
|
+
}),
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
#### Storage Options
|
|
628
|
+
|
|
629
|
+
| Value | Description | Note |
|
|
630
|
+
| ------------------ | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
631
|
+
| `'cookie'` | Stores locale in cookies — accessible on both client and server side. | For GDPR compliance, ensure proper user consent. Customizable via `CookiesAttributes` (`{ type: 'cookie', name: 'custom-locale', secure: true, httpOnly: false }`). |
|
|
632
|
+
| `'localStorage'` | Stores locale in the browser without expiration — client side only. | No expiration unless explicitly cleared. Intlayer proxy cannot access it. Customizable via `StorageAttributes` (`{ type: 'localStorage', name: 'custom-locale' }`). |
|
|
633
|
+
| `'sessionStorage'` | Stores locale for the duration of the page session — client side only. | Cleared when tab/window is closed. Intlayer proxy cannot access it. Customizable via `StorageAttributes` (`{ type: 'sessionStorage', name: 'custom-locale' }`). |
|
|
634
|
+
| `'header'` | Stores or transmits locale via HTTP headers — server side only. | Useful for API calls. Client side cannot access it. Customizable via `StorageAttributes` (`{ type: 'header', name: 'custom-locale' }`). |
|
|
772
635
|
|
|
773
636
|
#### Cookie Attributes
|
|
774
637
|
|
|
775
638
|
When using cookie storage, you can configure additional cookie attributes:
|
|
776
639
|
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
640
|
+
| Field | Type | Description |
|
|
641
|
+
| ---------- | ------------------------------------- | --------------------------------------------- |
|
|
642
|
+
| `name` | `string` | Cookie name. Default: `'INTLAYER_LOCALE'` |
|
|
643
|
+
| `domain` | `string` | Cookie domain. Default: `undefined` |
|
|
644
|
+
| `path` | `string` | Cookie path. Default: `undefined` |
|
|
645
|
+
| `secure` | `boolean` | Require HTTPS. Default: `undefined` |
|
|
646
|
+
| `httpOnly` | `boolean` | HTTP-only flag. Default: `undefined` |
|
|
647
|
+
| `sameSite` | `'strict' | 'lax' | 'none'` | SameSite policy. |
|
|
648
|
+
| `expires` | `Date | number` | Expiration date or days. Default: `undefined` |
|
|
784
649
|
|
|
785
650
|
#### Locale Storage Attributes
|
|
786
651
|
|
|
787
652
|
When using localStorage or sessionStorage:
|
|
788
653
|
|
|
789
|
-
|
|
790
|
-
|
|
654
|
+
| Field | Type | Description |
|
|
655
|
+
| ------ | ---------------------------------------- | ---------------------------------------------- |
|
|
656
|
+
| `type` | `'localStorage' | 'sessionStorage'` | Storage type. |
|
|
657
|
+
| `name` | `string` | Storage key name. Default: `'INTLAYER_LOCALE'` |
|
|
791
658
|
|
|
792
659
|
#### Configuration Examples
|
|
793
660
|
|
|
@@ -928,49 +795,14 @@ export default config;
|
|
|
928
795
|
|
|
929
796
|
Settings related to content handling within the application, including directory names, file extensions, and derived configurations.
|
|
930
797
|
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
-
|
|
939
|
-
- _Type_: `string[]`
|
|
940
|
-
- _Default_: `['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.json5', '.content.jsonc', '.content.tsx', '.content.jsx']`
|
|
941
|
-
- _Description_: File extensions to look for when building dictionaries.
|
|
942
|
-
- _Example_: `['.data.ts', '.data.js', '.data.json']`
|
|
943
|
-
- _Note_: Customizing file extensions can help avoid conflicts.
|
|
944
|
-
|
|
945
|
-
- **contentDir**:
|
|
946
|
-
- _Type_: `string[]`
|
|
947
|
-
- _Default_: `['.']`
|
|
948
|
-
- _Example_: `['src', '../../ui-library', require.resolve("@my-package/content")]`
|
|
949
|
-
- _Description_: The directory path where content definition files (`.content.*`) are stored.
|
|
950
|
-
- _Note_: This is used to watch for content files to rebuild dictionaries.
|
|
951
|
-
|
|
952
|
-
- **codeDir**:
|
|
953
|
-
- _Type_: `string[]`
|
|
954
|
-
- _Default_: `['.']`
|
|
955
|
-
- _Example_: `['src', '../../ui-library']`
|
|
956
|
-
- _Description_: The directory path where the code is stored, relative to the base directory.
|
|
957
|
-
- _Note_: This is used to watch for code files to transform (prune, optimize). Keeping this separate from `contentDir` can improve build performance by avoiding unnecessary scans of content files.
|
|
958
|
-
|
|
959
|
-
- **excludedPath**:
|
|
960
|
-
- _Type_: `string[]`
|
|
961
|
-
- _Default_: `['**/node_modules/**', '**/dist/**', '**/build/**', '**/.intlayer/**', '**/.next/**', '**/.nuxt/**', '**/.expo/**', '**/.vercel/**', '**/.turbo/**', '**/.tanstack/**']`
|
|
962
|
-
- _Description_: Directories excluded from content search.
|
|
963
|
-
- _Note_: This setting is not yet used, but planned for future implementation.
|
|
964
|
-
|
|
965
|
-
- **formatCommand**:
|
|
966
|
-
- _Type_: `string`
|
|
967
|
-
- _Default_: `undefined`
|
|
968
|
-
- _Description_: The command to format the content. When intlayer write your .content files locally, this command will be used to format the content.
|
|
969
|
-
- _Example_: `'npx prettier --write "{{file}}" --log-level silent'` Using Prettier
|
|
970
|
-
- _Example_: `'npx biome format "{{file}}" --write --log-level none'` Using Biome
|
|
971
|
-
- _Example_: `'npx eslint --fix "{{file}}" --quiet'` Using ESLint
|
|
972
|
-
- _Note_: Intlayer will replace the {{file}} with the path of the file to format.
|
|
973
|
-
- _Note_: If not set, Intlayer will try to detect the format command automatically. By trying to resolve the following commands: prettier, biome, eslint.
|
|
798
|
+
| Field | Type | Description | Example | Note |
|
|
799
|
+
| ---------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
800
|
+
| `watch` | `boolean` | Indicates if Intlayer should watch for changes in content declaration files to rebuild dictionaries. Default: `process.env.NODE_ENV === 'development'` | | |
|
|
801
|
+
| `fileExtensions` | `string[]` | File extensions to look for when building dictionaries. Default: `['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.json5', '.content.jsonc', '.content.tsx', '.content.jsx']` | `['.data.ts', '.data.js', '.data.json']` | Customizing can help avoid conflicts. |
|
|
802
|
+
| `contentDir` | `string[]` | Directory path where content definition files (`.content.*`) are stored. Default: `['.']` | `['src', '../../ui-library', require.resolve("@my-package/content")]` | Used to watch for content files to rebuild dictionaries. |
|
|
803
|
+
| `codeDir` | `string[]` | Directory path where the code is stored, relative to the base directory. Default: `['.']` | `['src', '../../ui-library']` | Used to watch for code files to transform (prune, optimize). Keeping separate from `contentDir` can improve build performance. |
|
|
804
|
+
| `excludedPath` | `string[]` | Directories excluded from content search. Default: `['**/node_modules/**', '**/dist/**', '**/build/**', '**/.intlayer/**', '**/.next/**', '**/.nuxt/**', '**/.expo/**', '**/.vercel/**', '**/.turbo/**', '**/.tanstack/**']` | | Not yet used; planned for future implementation. |
|
|
805
|
+
| `formatCommand` | `string` | Command to format content files when Intlayer writes them locally. Default: `undefined` | `'npx prettier --write "{{file}}" --log-level silent'` (Prettier), `'npx biome format "{{file}}" --write --log-level none'` (Biome), `'npx eslint --fix "{{file}}" --quiet'` (ESLint) | `{{file}}` is replaced with the file path. If not set, Intlayer auto-detects (tries prettier, biome, eslint). |
|
|
974
806
|
|
|
975
807
|
---
|
|
976
808
|
|
|
@@ -978,51 +810,16 @@ Settings related to content handling within the application, including directory
|
|
|
978
810
|
|
|
979
811
|
Settings related to internal paths and output results of Intlayer. These settings are typically internal and should not need to be modified by the user.
|
|
980
812
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
- _Type_: `string`
|
|
992
|
-
- _Default_: `'.intlayer/dictionary'`
|
|
993
|
-
- _Description_: The directory path for storing localization dictionaries.
|
|
994
|
-
|
|
995
|
-
- **moduleAugmentationDir**:
|
|
996
|
-
- _Type_: `string`
|
|
997
|
-
- _Default_: `'.intlayer/types'`
|
|
998
|
-
- _Description_: Directory for module augmentation, allowing better IDE suggestions and type checking.
|
|
999
|
-
- _Example_: `'intlayer-types'`
|
|
1000
|
-
- _Note_: Be sure to include this in `tsconfig.json`.
|
|
1001
|
-
|
|
1002
|
-
- **unmergedDictionariesDir**:
|
|
1003
|
-
- _Type_: `string`
|
|
1004
|
-
- _Default_: `'.intlayer/unmerged_dictionary'`
|
|
1005
|
-
- _Description_: The directory for storing unmerged dictionaries.
|
|
1006
|
-
|
|
1007
|
-
- **typesDir**:
|
|
1008
|
-
- _Type_: `string`
|
|
1009
|
-
- _Default_: `'.intlayer/types'`
|
|
1010
|
-
- _Description_: The directory for storing dictionary types.
|
|
1011
|
-
|
|
1012
|
-
- **mainDir**:
|
|
1013
|
-
- _Type_: `string`
|
|
1014
|
-
- _Default_: `'.intlayer/main'`
|
|
1015
|
-
- _Description_: The directory where main application files are stored.
|
|
1016
|
-
|
|
1017
|
-
- **configDir**:
|
|
1018
|
-
- _Type_: `string`
|
|
1019
|
-
- _Default_: `'.intlayer/config'`
|
|
1020
|
-
- _Description_: The directory where the configuration files are stored.
|
|
1021
|
-
|
|
1022
|
-
- **cacheDir**:
|
|
1023
|
-
- _Type_: `string`
|
|
1024
|
-
- _Default_: `'.intlayer/cache'`
|
|
1025
|
-
- _Description_: The directory where the cache files are stored.
|
|
813
|
+
| Field | Type | Description | Example | Note |
|
|
814
|
+
| ------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------ | -------------------- | ------------------------------------------------- |
|
|
815
|
+
| `baseDir` | `string` | The base directory for the project. Default: `process.cwd()` | `'/path/to/project'` | Used to resolve all Intlayer-related directories. |
|
|
816
|
+
| `dictionariesDir` | `string` | The directory path for storing localization dictionaries. Default: `'.intlayer/dictionary'` | | |
|
|
817
|
+
| `moduleAugmentationDir` | `string` | Directory for module augmentation, allowing better IDE suggestions and type checking. Default: `'.intlayer/types'` | `'intlayer-types'` | Be sure to include this in `tsconfig.json`. |
|
|
818
|
+
| `unmergedDictionariesDir` | `string` | The directory for storing unmerged dictionaries. Default: `'.intlayer/unmerged_dictionary'` | | |
|
|
819
|
+
| `typesDir` | `string` | The directory for storing dictionary types. Default: `'.intlayer/types'` | | |
|
|
820
|
+
| `mainDir` | `string` | The directory where main application files are stored. Default: `'.intlayer/main'` | | |
|
|
821
|
+
| `configDir` | `string` | The directory where configuration files are stored. Default: `'.intlayer/config'` | | |
|
|
822
|
+
| `cacheDir` | `string` | The directory where cache files are stored. Default: `'.intlayer/cache'` | | |
|
|
1026
823
|
|
|
1027
824
|
### Dictionary Configuration
|
|
1028
825
|
|
|
@@ -1035,36 +832,32 @@ This dictionary configuration serves two main purposes:
|
|
|
1035
832
|
|
|
1036
833
|
For more information about content declaration files and how configuration values are applied, see the [Content File Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md).
|
|
1037
834
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
- **schema**
|
|
1065
|
-
- **title**
|
|
1066
|
-
- **tags**
|
|
1067
|
-
- **version**
|
|
835
|
+
| Field | Type | Description | Example | Note |
|
|
836
|
+
| --------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
837
|
+
| `fill` | `boolean | FilePathPattern | Partial<Record<Locale, boolean | FilePathPattern>>` | Controls how auto-fill (AI translation) output files are generated. Default: `true` | See example below | `true`: default path (same file as source). `false`: disable. String/function template generates per-locale files. Object per-locale: each locale maps to its own pattern; `false` skips that locale. Including `{{locale}}` triggers per-locale generation. Dictionary-level `fill` always takes priority over this global config. |
|
|
838
|
+
| `description` | | | | |
|
|
839
|
+
| `locale` | | | | |
|
|
840
|
+
| `contentAutoTransformation` | | | | |
|
|
841
|
+
| `location` | | | | |
|
|
842
|
+
| `importMode` | `'static' | 'dynamic' | 'fetch'` | Controls how dictionaries are imported. Default: `'static'` | `'dynamic'` | `'static'`: imported statically (replaces `useIntlayer` with `useDictionary`). `'dynamic'`: imported dynamically via Suspense (replaces with `useDictionaryDynamic`). `'fetch'`: fetched via live sync API; falls back to `'dynamic'` on failure. Relies on `@intlayer/babel` and `@intlayer/swc` plugins. Keys must be declared statically. Ignored if `optimize` is disabled. Does not affect `getIntlayer`, `getDictionary`, `useDictionary`, etc. |
|
|
843
|
+
| `priority` | | | | |
|
|
844
|
+
| `live` | | | | |
|
|
845
|
+
| `schema` | | | | |
|
|
846
|
+
| `title` | | | | |
|
|
847
|
+
| `tags` | | | | |
|
|
848
|
+
| `version` | | | | |
|
|
849
|
+
|
|
850
|
+
**`fill` example**:
|
|
851
|
+
|
|
852
|
+
```ts
|
|
853
|
+
dictionary: {
|
|
854
|
+
fill: {
|
|
855
|
+
en: '/locales/en/{{key}}.content.json',
|
|
856
|
+
fr: ({ key }) => `/locales/fr/${key}.content.json`,
|
|
857
|
+
es: false,
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
```
|
|
1068
861
|
|
|
1069
862
|
---
|
|
1070
863
|
|
|
@@ -1072,22 +865,10 @@ For more information about content declaration files and how configuration value
|
|
|
1072
865
|
|
|
1073
866
|
Settings that control the logger, including the prefix to use.
|
|
1074
867
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
- _Default_: `default`
|
|
1080
|
-
- _Description_: Indicates the mode of the logger.
|
|
1081
|
-
- _Options_: `default`, `verbose`, `disabled`
|
|
1082
|
-
- _Example_: `default`
|
|
1083
|
-
- _Note_: The mode of the logger. Verbose mode will log more information, but can be used for debugging purposes. Disabled mode will disable the logger.
|
|
1084
|
-
|
|
1085
|
-
- **prefix**:
|
|
1086
|
-
- _Type_: `string`
|
|
1087
|
-
- _Default_: `'[intlayer] '`
|
|
1088
|
-
- _Description_: The prefix of the logger.
|
|
1089
|
-
- _Example_: `'[my custom prefix] '`
|
|
1090
|
-
- _Note_: The prefix of the logger.
|
|
868
|
+
| Field | Type | Description | Example | Note |
|
|
869
|
+
| -------- | ---------------------------------------------- | ------------------------------------------------------ | ----------------------- | -------------------------------------------------------------------------------------- |
|
|
870
|
+
| `mode` | `'default' | 'verbose' | 'disabled'` | Indicates the mode of the logger. Default: `'default'` | `'verbose'` | `'verbose'`: logs more info for debugging. `'disabled'`: disables the logger entirely. |
|
|
871
|
+
| `prefix` | `string` | The prefix of the logger. Default: `'[intlayer] '` | `'[my custom prefix] '` | |
|
|
1091
872
|
|
|
1092
873
|
### AI Configuration
|
|
1093
874
|
|
|
@@ -1118,59 +899,15 @@ Intlayer supports multiple AI providers for enhanced flexibility and choice. Cur
|
|
|
1118
899
|
- **Together.ai**
|
|
1119
900
|
- **ollama**
|
|
1120
901
|
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
- **model**:
|
|
1132
|
-
- _Type_: `string`
|
|
1133
|
-
- _Default_: None
|
|
1134
|
-
- _Description_: The model to use for the AI features of Intlayer.
|
|
1135
|
-
- _Example_: `'gpt-4o-2024-11-20'`
|
|
1136
|
-
- _Note_: The specific model to use varies by provider.
|
|
1137
|
-
|
|
1138
|
-
- **temperature**:
|
|
1139
|
-
- _Type_: `number`
|
|
1140
|
-
- _Default_: None
|
|
1141
|
-
- _Description_: The temperature controls the randomness of the AI's responses.
|
|
1142
|
-
- _Example_: `0.1`
|
|
1143
|
-
- _Note_: A higher temperature will make the AI more creative and less predictable.
|
|
1144
|
-
|
|
1145
|
-
- **apiKey**:
|
|
1146
|
-
- _Type_: `string`
|
|
1147
|
-
- _Default_: None
|
|
1148
|
-
- _Description_: Your API key for the selected provider.
|
|
1149
|
-
- _Example_: `process.env.OPENAI_API_KEY`
|
|
1150
|
-
- _Note_: Important: API keys should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
|
|
1151
|
-
|
|
1152
|
-
- **applicationContext**:
|
|
1153
|
-
- _Type_: `string`
|
|
1154
|
-
- _Default_: None
|
|
1155
|
-
- _Description_: Provides additional context about your application to the AI model, helping it generate more accurate and contextually appropriate translations. This can include information about your app's domain, target audience, tone, or specific terminology.
|
|
1156
|
-
- _Note_: You can use it to add more rules to the AI model (e.g. "You should not transform urls").
|
|
1157
|
-
- _Example_: `'My application context'`
|
|
1158
|
-
|
|
1159
|
-
- **baseURL**:
|
|
1160
|
-
- _Type_: `string`
|
|
1161
|
-
- _Default_: None
|
|
1162
|
-
- _Description_: The base URL for the AI API.
|
|
1163
|
-
- _Example_: `'https://api.openai.com/v1'`
|
|
1164
|
-
- _Example_: `'http://localhost:5000'`
|
|
1165
|
-
- _Note_: Can be used to point to a local, or custom AI API endpoint.
|
|
1166
|
-
|
|
1167
|
-
- **dataSerialization**:
|
|
1168
|
-
- _Type_: `'json' | 'toon'`
|
|
1169
|
-
- _Default_: `'json'`
|
|
1170
|
-
- _Description_: The data serialization format to use for the AI features of Intlayer.
|
|
1171
|
-
- _Example_: `'toon'`
|
|
1172
|
-
- _Note_: `json`: Standard, reliable; uses more tokens. `toon`: Fewer tokens, less consistent than JSON.
|
|
1173
|
-
> If you provide additional parameters, Intlayer will pass them to the AI model as context. It can be used to customize the reasoning effort, text verbosity, etc
|
|
902
|
+
| Field | Type | Description | Example | Note |
|
|
903
|
+
| -------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
904
|
+
| `provider` | `string` | The provider to use for the AI features of Intlayer. Default: `'openai'` | `'anthropic'` | Options: `'openai'`, `'anthropic'`, `'mistral'`, `'deepseek'`, `'gemini'`, `'ollama'`, `'openrouter'`, `'alibaba'`, `'fireworks'`, `'groq'`, `'huggingface'`, `'bedrock'`, `'googleaistudio'`, `'googlevertex'`, `'togetherai'`. Different providers require different API keys and have different pricing. |
|
|
905
|
+
| `model` | `string` | The model to use for AI features. Default: None | `'gpt-4o-2024-11-20'` | Specific model varies by provider. |
|
|
906
|
+
| `temperature` | `number` | Controls the randomness of AI responses. Default: None | `0.1` | Higher temperature = more creative and less predictable. |
|
|
907
|
+
| `apiKey` | `string` | Your API key for the selected provider. Default: None | `process.env.OPENAI_API_KEY` | Keep secret; store in environment variables. |
|
|
908
|
+
| `applicationContext` | `string` | Additional context about your application to help the AI generate more accurate translations (domain, audience, tone, terminology). Default: None | `'My application context'` | Can be used to add rules (e.g. `"You should not transform urls"`). |
|
|
909
|
+
| `baseURL` | `string` | The base URL for the AI API. Default: None | `'https://api.openai.com/v1'`, `'http://localhost:5000'` | Can point to a local or custom AI API endpoint. |
|
|
910
|
+
| `dataSerialization` | `'json' | 'toon'` | Data serialization format for AI features. Default: `'json'` | `'toon'` | `'json'`: standard, reliable; uses more tokens. `'toon'`: fewer tokens, less consistent. Additional parameters are passed to the AI model as context (reasoning effort, verbosity, etc.). |
|
|
1174
911
|
|
|
1175
912
|
### Build Configuration
|
|
1176
913
|
|
|
@@ -1182,49 +919,13 @@ Build options apply to the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
|
1182
919
|
|
|
1183
920
|
> When optimized, Intlayer will replace dictionary calls to optimize chunking, so the final bundle only imports dictionaries that are actually used.
|
|
1184
921
|
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
- _Note_: If 'auto', the build will be enabled automatically when the application is built.
|
|
1193
|
-
- _Note_: If 'manual', the build will be set only when the build command is executed.
|
|
1194
|
-
- _Note_: Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.
|
|
1195
|
-
|
|
1196
|
-
- **optimize**:
|
|
1197
|
-
- _Type_: `boolean`
|
|
1198
|
-
- _Default_: `undefined`
|
|
1199
|
-
- _Description_: Controls whether the build should be optimized.
|
|
1200
|
-
- _Example_: `process.env.NODE_ENV === 'production'`
|
|
1201
|
-
- _Note_: By default, the build optimization is not fixed. If not set, Intlayer will trigger the build optimization on the build of your application (vite / nextjs / etc). Setting it to `true` will force the build optimization, including during dev mode. Setting it to `false` will disable the build optimization.
|
|
1202
|
-
- _Note_: When enabled, Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used. All imports will stay as static import to avoid async processing when loading the dictionaries.
|
|
1203
|
-
- _Note_: Intlayer will replace all calls of `useIntlayer` with the defined mode by the `importMode` option and `getIntlayer` with `getDictionary`.
|
|
1204
|
-
- _Note_: This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
1205
|
-
- _Note_: Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
|
|
1206
|
-
|
|
1207
|
-
- **checkTypes**:
|
|
1208
|
-
- _Type_: `boolean`
|
|
1209
|
-
- _Default_: `false`
|
|
1210
|
-
- _Description_: Indicates if the build should check TypeScript types and log errors.
|
|
1211
|
-
- _Note_: This can slow down the build.
|
|
1212
|
-
|
|
1213
|
-
- **outputFormat**:
|
|
1214
|
-
- _Type_: `('esm' | 'cjs')[]`
|
|
1215
|
-
- _Default_: `['cjs', 'esm']`
|
|
1216
|
-
- _Description_: Controls the output format of the dictionaries.
|
|
1217
|
-
- _Example_: `'cjs'`
|
|
1218
|
-
- _Note_: The output format of the dictionaries.
|
|
1219
|
-
|
|
1220
|
-
- **traversePattern**:
|
|
1221
|
-
- _Type_: `string[]`
|
|
1222
|
-
- _Default_: `['**\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\/node_modules/**']`
|
|
1223
|
-
- _Description_: Patterns that define which files should be traversed during optimization.
|
|
1224
|
-
- _Example_: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}', '!**/node_modules/**']`
|
|
1225
|
-
- _Note_: Use this to limit optimization to relevant code files and improve build performance.
|
|
1226
|
-
- _Note_: This option will be ignored if `optimize` is disabled.
|
|
1227
|
-
- _Note_: Use glob pattern.
|
|
922
|
+
| Field | Type | Description | Example | Note |
|
|
923
|
+
| ----------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
924
|
+
| `mode` | `'auto' | 'manual'` | Controls the mode of the build. Default: `'auto'` | `'manual'` | `'auto'`: build enabled automatically when the application is built. `'manual'`: only runs when the build command is executed. Can be used to disable dictionary builds (e.g. to avoid running in Node.js environments). |
|
|
925
|
+
| `optimize` | `boolean` | Controls whether the build should be optimized. Default: `undefined` | `process.env.NODE_ENV === 'production'` | If unset, optimization is triggered on framework build (Vite/Next.js). `true` forces optimization including dev mode. `false` disables it. When enabled, replaces dictionary calls to optimize chunking — only used dictionaries are imported. Relies on `@intlayer/babel` and `@intlayer/swc` plugins. Keys must be declared statically. |
|
|
926
|
+
| `checkTypes` | `boolean` | Indicates if the build should check TypeScript types and log errors. Default: `false` | | Can slow down the build. |
|
|
927
|
+
| `outputFormat` | `('esm' | 'cjs')[]` | Controls the output format of the dictionaries. Default: `['cjs', 'esm']` | `['cjs']` | |
|
|
928
|
+
| `traversePattern` | `string[]` | Patterns defining which files to traverse during optimization. Default: `['**/*.{js,ts,mjs,cjs,jsx,tsx}', '!**/node_modules/**']` | `['src/**/*.{ts,tsx}', '../ui-library/**/*.{ts,tsx}', '!**/node_modules/**']` | Limit optimization to relevant files to improve build performance. Ignored if `optimize` is disabled. Uses glob pattern. |
|
|
1228
929
|
|
|
1229
930
|
---
|
|
1230
931
|
|
|
@@ -1232,74 +933,47 @@ Build options apply to the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
|
1232
933
|
|
|
1233
934
|
Settings that control the Intlayer compiler, which extracts dictionaries straight from your components.
|
|
1234
935
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
- Function: `({ fileName, extension }) => \`./${fileName}${extension}``
|
|
1280
|
-
|
|
1281
|
-
- **Centralized per-locale JSON**:
|
|
1282
|
-
- String: `'/locales/{{locale}}/{{key}}.content.json'`
|
|
1283
|
-
- Function: `({ key, locale }) => \`/locales/${locale}/${key}.content.json``
|
|
1284
|
-
|
|
1285
|
-
- **noMetadata**:
|
|
1286
|
-
- _Type_: `boolean`
|
|
1287
|
-
- _Default_: `false`
|
|
1288
|
-
- _Description_: Indicates if the metadata should be saved in the file. If true, the compiler will not save the metadata of the dictionaries (key, content wrapper). Useful for per-locale i18next or ICU MessageFormat JSON outputs.
|
|
1289
|
-
- _Note_: Useful if used with `loadJSON` plugin.
|
|
1290
|
-
- _Example_:
|
|
1291
|
-
If `true`:
|
|
1292
|
-
```json
|
|
1293
|
-
{
|
|
1294
|
-
"key": "value"
|
|
1295
|
-
}
|
|
1296
|
-
```
|
|
1297
|
-
If `false`:
|
|
1298
|
-
```json
|
|
1299
|
-
{
|
|
1300
|
-
"key": "value",
|
|
1301
|
-
"content": {
|
|
1302
|
-
"key": "value"
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
```
|
|
936
|
+
| Field | Type | Description | Example | Note |
|
|
937
|
+
| --------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
938
|
+
| `enabled` | `boolean | 'build-only'` | Indicates if the compiler should be enabled to extract dictionaries. Default: `true` | `'build-only'` | `'build-only'` skips the compiler during development to speed up builds; only runs on build commands. |
|
|
939
|
+
| `dictionaryKeyPrefix` | `string` | Prefix for the extracted dictionary keys. Default: `''` | `'my-key-'` | Added to the generated key (based on file name) to prevent conflicts. |
|
|
940
|
+
| `saveComponents` | `boolean` | Indicates if components should be saved after being transformed. Default: `false` | | If `true`, replaces original files with transformed files. The compiler can then be removed after one run. |
|
|
941
|
+
| `transformPattern` | `string | string[]` | Patterns defining which files to traverse during optimization. Default: `['**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**/node_modules/**']` | `['src/**/*.{ts,tsx}', '!**/node_modules/**']` | Limit to relevant code files to improve build performance. |
|
|
942
|
+
| `excludePattern` | `string | string[]` | Patterns defining which files to exclude during optimization. Default: `['**/node_modules/**']` | `['**/node_modules/**', '!**/node_modules/react/**']` | |
|
|
943
|
+
| `output` | `boolean | FilePathPattern | Partial<Record<Locale, boolean | FilePathPattern>>` | Defines the output file path. Replaces `outputDir`. Supports template variables: `{{fileName}}`, `{{key}}`, `{{locale}}`, `{{extension}}`, `{{componentFileName}}`, `{{componentExtension}}`, `{{format}}`, `{{componentFormat}}`, `{{componentDirPath}}`. Default: `undefined` | See examples below | `./` paths resolve relative to the component directory. `/` paths resolve relative to the project root. Including `{{locale}}` generates separate per-locale dictionaries. Supports per-locale object notation; `false` skips that locale. |
|
|
944
|
+
| `noMetadata` | `boolean` | If `true`, the compiler omits dictionary metadata (key, content wrapper) from the output. Default: `false` | | Useful for i18next or ICU MessageFormat JSON outputs. Works well with `loadJSON` plugin. |
|
|
945
|
+
|
|
946
|
+
**`output` examples**:
|
|
947
|
+
|
|
948
|
+
- Multilingual file near component: `'./{{fileName}}{{extension}}'` or `({ fileName, extension }) => \`./${fileName}${extension}\``
|
|
949
|
+
- Centralized per-locale JSON: `'/locales/{{locale}}/{{key}}.content.json'` or `({ key, locale }) => \`/locales/${locale}/${key}.content.json\``
|
|
950
|
+
- Object per-locale (different pattern per locale, skip some):
|
|
951
|
+
|
|
952
|
+
```ts
|
|
953
|
+
output: {
|
|
954
|
+
en: ({ key }) => `./locales/en/${key}.json`,
|
|
955
|
+
fr: '/locales/fr/{{key}}.content.json',
|
|
956
|
+
es: false, // skip Spanish
|
|
957
|
+
}
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
**`noMetadata` example**:
|
|
961
|
+
|
|
962
|
+
If `true`:
|
|
963
|
+
|
|
964
|
+
```json
|
|
965
|
+
{
|
|
966
|
+
"key": "value"
|
|
967
|
+
}
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
If `false`:
|
|
971
|
+
|
|
972
|
+
```json
|
|
973
|
+
{
|
|
974
|
+
"key": "value",
|
|
975
|
+
"content": {
|
|
976
|
+
"key": "value"
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
```
|