next-intl-split
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
export declare const loadI18nTranslations: (dictionariesPath: string, locale: string) => any; | ||
export declare const loadI18nTranslations: (dictionariesPath: string, locale: string, enableTypeCheck?: boolean) => any; | ||
export declare const loadMessages: (dictionariesPath: string) => { | ||
@@ -3,0 +3,0 @@ [key: string]: any; |
{ | ||
"name": "next-intl-split", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "A loader for next-intl to split translation files properly.", | ||
@@ -23,3 +23,8 @@ "author": { | ||
"next-intl-split", | ||
"split" | ||
"split", | ||
"intl", | ||
"internationalization", | ||
"i18n", | ||
"next.js", | ||
"next" | ||
], | ||
@@ -26,0 +31,0 @@ "scripts": { |
@@ -10,2 +10,3 @@ # About | ||
- <a href="#how_to_use">How to use the package?</a> | ||
- <a href="#how_to_add_types">How to add types?</a> | ||
@@ -36,2 +37,4 @@ ## <a id="installation"></a> Installation | ||
- Cleaner `JSON` files. | ||
- Support for TypeScript. | ||
- Support for Next.Js Config file with `.ts/.js/.mjs` extensions. | ||
@@ -246,1 +249,29 @@ ## <a id="how_to_use"></a> How to use the package? | ||
``` | ||
## <a id="how_to_add_types"></a>Add Support for TypeScript | ||
Starting from `v1.2.4` you'll be able to enable type check. | ||
1. Add global type declaration as mentioned in `next-intl` documentation. [Check this](https://next-intl.dev/docs/workflows/typescript) | ||
2. Based on your default locale, ensure that there is a `.json` file for that in your messages (or translations) folder. | ||
As an example if your default locale is `en` and you have your messages in `./src/messages/`, make sure there is an `en.json` module in it, even an empty one or you can build your project once to have them merged automatically. | ||
3. Inside the `getRequestConfig`, add the `true` parameters to the `loadI18nTranslations` utitlity as the 3rd param. | ||
```ts | ||
// ./src/i18n/request.ts | ||
... | ||
export default getRequestConfig(async ({ locale }) => { | ||
... | ||
messages = loadI18nTranslations( | ||
'./src/messages', | ||
locale, | ||
true // This will enable type check | ||
); | ||
... | ||
}); | ||
... | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
34301
10.89%36
2.86%275
12.7%13
18.18%