@i18n-micro/node 1.2.0 → 1.2.1
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/index.d.cts +83 -0
- package/package.json +43 -15
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { BaseI18n } from '@i18n-micro/core';
|
|
2
|
+
import { CleanTranslation } from '@i18n-micro/types';
|
|
3
|
+
import { FormatService } from '@i18n-micro/core';
|
|
4
|
+
import { Getter } from '@i18n-micro/types';
|
|
5
|
+
import { interpolate } from '@i18n-micro/core';
|
|
6
|
+
import { Locale } from '@i18n-micro/types';
|
|
7
|
+
import { LocaleCode } from '@i18n-micro/types';
|
|
8
|
+
import { Params } from '@i18n-micro/types';
|
|
9
|
+
import { PluralFunc } from '@i18n-micro/types';
|
|
10
|
+
import { TranslationKey } from '@i18n-micro/types';
|
|
11
|
+
import { Translations } from '@i18n-micro/types';
|
|
12
|
+
|
|
13
|
+
export { CleanTranslation }
|
|
14
|
+
|
|
15
|
+
export declare function createI18n(options: I18nOptions): I18n;
|
|
16
|
+
|
|
17
|
+
export { FormatService }
|
|
18
|
+
|
|
19
|
+
export { Getter }
|
|
20
|
+
|
|
21
|
+
export declare class I18n extends BaseI18n {
|
|
22
|
+
locale: string;
|
|
23
|
+
fallbackLocale: string;
|
|
24
|
+
translationDir?: string;
|
|
25
|
+
private disablePageLocales;
|
|
26
|
+
currentRoute: string;
|
|
27
|
+
constructor(options: I18nOptions);
|
|
28
|
+
setRoute(routeName: string): void;
|
|
29
|
+
getLocale(): string;
|
|
30
|
+
getFallbackLocale(): string;
|
|
31
|
+
getRoute(): string;
|
|
32
|
+
loadTranslations(dir?: string): Promise<void>;
|
|
33
|
+
reload(): Promise<void>;
|
|
34
|
+
addTranslations(locale: string, translations: Translations, merge?: boolean): void;
|
|
35
|
+
addRouteTranslations(locale: string, routeName: string, translations: Translations, merge?: boolean): void;
|
|
36
|
+
hasTranslation(key: TranslationKey): boolean;
|
|
37
|
+
clear(): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare interface I18nOptions {
|
|
41
|
+
locale: string;
|
|
42
|
+
fallbackLocale?: string;
|
|
43
|
+
translationDir?: string;
|
|
44
|
+
plural?: PluralFunc;
|
|
45
|
+
missingWarn?: boolean;
|
|
46
|
+
missingHandler?: (locale: string, key: string, routeName: string) => void;
|
|
47
|
+
disablePageLocales?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { interpolate }
|
|
51
|
+
|
|
52
|
+
export declare interface LoadedTranslations {
|
|
53
|
+
root: Record<string, Translations>;
|
|
54
|
+
routes: Record<string, Record<string, Translations>>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Load only root-level translations from a directory
|
|
59
|
+
* @param dir - Directory path containing translation files
|
|
60
|
+
* @param disablePageLocales - If true, ignores pages/ folder and treats all files as root translations
|
|
61
|
+
*/
|
|
62
|
+
export declare function loadRootTranslations(dir: string, disablePageLocales?: boolean): Promise<Record<string, Translations>>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Load translations from a directory
|
|
66
|
+
* Supports both flat structure (locales/{lang}.json) and nested structure (locales/pages/{page}/{lang}.json)
|
|
67
|
+
* @param dir - Directory path containing translation files
|
|
68
|
+
* @param disablePageLocales - If true, ignores pages/ folder and treats all files as global translations
|
|
69
|
+
* @returns Object with global and route-specific translations
|
|
70
|
+
*/
|
|
71
|
+
export declare function loadTranslations(dir: string, disablePageLocales?: boolean): Promise<LoadedTranslations>;
|
|
72
|
+
|
|
73
|
+
export { Locale }
|
|
74
|
+
|
|
75
|
+
export { LocaleCode }
|
|
76
|
+
|
|
77
|
+
export { Params }
|
|
78
|
+
|
|
79
|
+
export { PluralFunc }
|
|
80
|
+
|
|
81
|
+
export { Translations }
|
|
82
|
+
|
|
83
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,40 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i18n-micro/node",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "Node.js utilities for loading translations and locale data in Nuxt I18n Micro.",
|
|
4
5
|
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/s00d/nuxt-i18n-micro.git",
|
|
11
|
+
"directory": "packages/node"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/s00d/nuxt-i18n-micro/tree/main/packages/node#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/s00d/nuxt-i18n-micro/issues"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20.0.0"
|
|
19
|
+
},
|
|
5
20
|
"main": "./dist/index.cjs",
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
7
21
|
"types": "./dist/index.d.ts",
|
|
8
22
|
"exports": {
|
|
9
23
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.mjs"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/index.d.cts",
|
|
30
|
+
"default": "./dist/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
14
35
|
},
|
|
15
36
|
"files": [
|
|
16
|
-
"dist"
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
17
40
|
],
|
|
18
|
-
"engines": {
|
|
19
|
-
"node": ">=20.0.0"
|
|
20
|
-
},
|
|
21
41
|
"publishConfig": {
|
|
22
42
|
"access": "public"
|
|
23
43
|
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"nuxt",
|
|
46
|
+
"i18n",
|
|
47
|
+
"node",
|
|
48
|
+
"translations"
|
|
49
|
+
],
|
|
24
50
|
"dependencies": {
|
|
25
|
-
"@i18n-micro/core": "1.
|
|
26
|
-
"@i18n-micro/types": "1.
|
|
51
|
+
"@i18n-micro/core": "1.3.1",
|
|
52
|
+
"@i18n-micro/types": "1.2.2"
|
|
27
53
|
},
|
|
28
54
|
"devDependencies": {
|
|
55
|
+
"@types/jest": "^29.5.14",
|
|
29
56
|
"@types/node": "^20.19.26",
|
|
30
|
-
"vite": "^7.3.1",
|
|
31
|
-
"vite-plugin-dts": "^4.5.4",
|
|
32
57
|
"jest": "^29.7.0",
|
|
58
|
+
"publint": "^0.3.17",
|
|
33
59
|
"ts-jest": "^29.4.6",
|
|
34
|
-
"
|
|
60
|
+
"vite": "^7.3.1",
|
|
61
|
+
"vite-plugin-dts": "^4.5.4"
|
|
35
62
|
},
|
|
36
63
|
"scripts": {
|
|
37
64
|
"build": "vite build",
|
|
65
|
+
"check:package": "publint",
|
|
38
66
|
"dev": "cd playground && npm run dev",
|
|
39
67
|
"test": "jest",
|
|
40
68
|
"typecheck": "tsc --noEmit"
|