@genrwork/laravel-i18next 0.1.0 → 0.1.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/README.md +110 -28
- package/dist/index.cjs +125 -3
- package/dist/index.mjs +124 -1
- package/dist/react.cjs +7 -5
- package/dist/react.mjs +7 -5
- package/dist/shared/{create-i18n-WsDK4Z8L.cjs → create-i18n-DI7Eog6O.cjs} +83 -333
- package/dist/shared/{create-i18n-BSEwKsCX.mjs → create-i18n-DaZzs1DJ.mjs} +78 -333
- package/dist/shared/demand-6YnTqSM4.mjs +92 -0
- package/dist/shared/demand-sbjTXVnl.cjs +101 -0
- package/dist/svelte.cjs +7 -1
- package/dist/svelte.mjs +7 -1
- package/dist/types/contrib/get-plural-index.d.ts +1 -1
- package/dist/types/defaults.d.ts +18 -0
- package/dist/types/demand.d.ts +51 -0
- package/dist/types/index.d.ts +5 -3
- package/dist/types/plugin/convert.d.ts +10 -0
- package/dist/types/plugin/namespaces.d.ts +20 -0
- package/dist/types/plugin/parser.d.ts +3 -0
- package/dist/types/plugin/sources.d.ts +5 -5
- package/dist/types/preload.d.ts +99 -0
- package/dist/types/react/i18n-provider-props.d.ts +5 -0
- package/dist/types/react/provider.d.ts +4 -3
- package/dist/types/shared/create-i18n.d.ts +9 -3
- package/dist/types/utils/cache.d.ts +3 -0
- package/dist/types/vite.d.ts +18 -1
- package/dist/vite.cjs +408 -6
- package/dist/vite.mjs +408 -6
- package/dist/vue.cjs +2 -1
- package/dist/vue.mjs +2 -1
- package/package.json +155 -155
- package/dist/types/format.d.ts +0 -43
- package/dist/types/interfaces/replacements.d.ts +0 -6
- package/dist/types/utils/replacer.d.ts +0 -9
- /package/dist/types/{utils → plugin}/pluralization.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@genrwork/laravel-i18next",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Use your Laravel translation files with i18next in React, Vue 3 or Svelte: i18next
|
|
5
|
-
"keywords": [
|
|
6
|
-
"laravel",
|
|
7
|
-
"react",
|
|
8
|
-
"vue",
|
|
9
|
-
"svelte",
|
|
10
|
-
"i18n",
|
|
11
|
-
"i18next",
|
|
12
|
-
"i18next-backend",
|
|
13
|
-
"react-i18next",
|
|
14
|
-
"i18next-vue",
|
|
15
|
-
"inertiajs",
|
|
16
|
-
"vite-plugin",
|
|
17
|
-
"vite-plugin-laravel"
|
|
18
|
-
],
|
|
19
|
-
"sideEffects": false,
|
|
20
|
-
"main": "./dist/index.cjs",
|
|
21
|
-
"module": "./dist/index.mjs",
|
|
22
|
-
"types": "./dist/types/index.d.ts",
|
|
23
|
-
"exports": {
|
|
24
|
-
".": {
|
|
25
|
-
"types": "./dist/types/index.d.ts",
|
|
26
|
-
"import": "./dist/index.mjs",
|
|
27
|
-
"require": "./dist/index.cjs"
|
|
28
|
-
},
|
|
29
|
-
"./react": {
|
|
30
|
-
"types": "./dist/types/react/index.d.ts",
|
|
31
|
-
"import": "./dist/react.mjs",
|
|
32
|
-
"require": "./dist/react.cjs"
|
|
33
|
-
},
|
|
34
|
-
"./vue": {
|
|
35
|
-
"types": "./dist/types/vue/index.d.ts",
|
|
36
|
-
"import": "./dist/vue.mjs",
|
|
37
|
-
"require": "./dist/vue.cjs"
|
|
38
|
-
},
|
|
39
|
-
"./svelte": {
|
|
40
|
-
"types": "./dist/types/svelte/index.d.ts",
|
|
41
|
-
"import": "./dist/svelte.mjs",
|
|
42
|
-
"require": "./dist/svelte.cjs"
|
|
43
|
-
},
|
|
44
|
-
"./vite": {
|
|
45
|
-
"types": "./dist/types/vite.d.ts",
|
|
46
|
-
"import": "./dist/vite.mjs",
|
|
47
|
-
"require": "./dist/vite.cjs"
|
|
48
|
-
},
|
|
49
|
-
"./client": {
|
|
50
|
-
"types": "./client.d.ts"
|
|
51
|
-
},
|
|
52
|
-
"./package.json": "./package.json"
|
|
53
|
-
},
|
|
54
|
-
"typesVersions": {
|
|
55
|
-
"*": {
|
|
56
|
-
"react": [
|
|
57
|
-
"./dist/types/react/index.d.ts"
|
|
58
|
-
],
|
|
59
|
-
"vue": [
|
|
60
|
-
"./dist/types/vue/index.d.ts"
|
|
61
|
-
],
|
|
62
|
-
"svelte": [
|
|
63
|
-
"./dist/types/svelte/index.d.ts"
|
|
64
|
-
],
|
|
65
|
-
"vite": [
|
|
66
|
-
"./dist/types/vite.d.ts"
|
|
67
|
-
],
|
|
68
|
-
"client": [
|
|
69
|
-
"./client.d.ts"
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
"repository": "genrwork/js-modules",
|
|
74
|
-
"bugs": {
|
|
75
|
-
"url": "https://github.com/genrwork/js-modules/issues"
|
|
76
|
-
},
|
|
77
|
-
"author": {
|
|
78
|
-
"name": "genrwork",
|
|
79
|
-
"email": "contact@genrwork.com"
|
|
80
|
-
},
|
|
81
|
-
"license": "MIT",
|
|
82
|
-
"files": [
|
|
83
|
-
"dist",
|
|
84
|
-
"client.d.ts"
|
|
85
|
-
],
|
|
86
|
-
"scripts": {
|
|
87
|
-
"build": "rollup -c",
|
|
88
|
-
"dev": "rollup -c -w",
|
|
89
|
-
"test": "vitest run",
|
|
90
|
-
"typecheck": "tsc -p tsconfig.test.json",
|
|
91
|
-
"prepack": "npm run typecheck && npm test && npm run build"
|
|
92
|
-
},
|
|
93
|
-
"engines": {
|
|
94
|
-
"node": ">=18"
|
|
95
|
-
},
|
|
96
|
-
"dependencies": {
|
|
97
|
-
"php-array-reader": "^2.1.4"
|
|
98
|
-
},
|
|
99
|
-
"peerDependencies": {
|
|
100
|
-
"i18next": ">=24.0.0",
|
|
101
|
-
"i18next-vue": ">=5.0.0",
|
|
102
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
103
|
-
"react-i18next": ">=15.0.0",
|
|
104
|
-
"svelte": "^4.0.0 || ^5.0.0",
|
|
105
|
-
"vite": ">=5.0.0",
|
|
106
|
-
"vue": "^3.4.38"
|
|
107
|
-
},
|
|
108
|
-
"peerDependenciesMeta": {
|
|
109
|
-
"i18next-vue": {
|
|
110
|
-
"optional": true
|
|
111
|
-
},
|
|
112
|
-
"react": {
|
|
113
|
-
"optional": true
|
|
114
|
-
},
|
|
115
|
-
"react-i18next": {
|
|
116
|
-
"optional": true
|
|
117
|
-
},
|
|
118
|
-
"svelte": {
|
|
119
|
-
"optional": true
|
|
120
|
-
},
|
|
121
|
-
"vite": {
|
|
122
|
-
"optional": true
|
|
123
|
-
},
|
|
124
|
-
"vue": {
|
|
125
|
-
"optional": true
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
"devDependencies": {
|
|
129
|
-
"@inertiajs/react": "^3.7.1",
|
|
130
|
-
"@rollup/plugin-swc": "^0.4.1",
|
|
131
|
-
"@rollup/plugin-typescript": "^12.3.0",
|
|
132
|
-
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
133
|
-
"@swc/core": "^1.16.2",
|
|
134
|
-
"@testing-library/react": "^16.3.3",
|
|
135
|
-
"@testing-library/svelte": "^5.4.2",
|
|
136
|
-
"@types/node": "^22.20.3",
|
|
137
|
-
"@types/react": "^19.3.0",
|
|
138
|
-
"@types/react-dom": "^19.3.0",
|
|
139
|
-
"@vitejs/plugin-vue": "^6.0.9",
|
|
140
|
-
"@vue/test-utils": "^2.5.1",
|
|
141
|
-
"i18next": "^26.4.2",
|
|
142
|
-
"i18next-vue": "^5.4.0",
|
|
143
|
-
"inertia-react-v2": "npm:@inertiajs/react@^2.3.28",
|
|
144
|
-
"jsdom": "^29.1.1",
|
|
145
|
-
"react": "^19.3.0",
|
|
146
|
-
"react-dom": "^19.3.0",
|
|
147
|
-
"react-i18next": "^17.0.14",
|
|
148
|
-
"rollup": "^4.63.3",
|
|
149
|
-
"svelte": "^5.57.0",
|
|
150
|
-
"typescript": "~5.9",
|
|
151
|
-
"vite": "^8.3.0",
|
|
152
|
-
"vitest": "^5.0.1",
|
|
153
|
-
"vue": "^3.5.42"
|
|
154
|
-
}
|
|
155
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@genrwork/laravel-i18next",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Use your Laravel translation files with i18next in React, Vue 3 or Svelte: PHP files are converted to i18next JSON at build time, one namespace per language file.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"laravel",
|
|
7
|
+
"react",
|
|
8
|
+
"vue",
|
|
9
|
+
"svelte",
|
|
10
|
+
"i18n",
|
|
11
|
+
"i18next",
|
|
12
|
+
"i18next-backend",
|
|
13
|
+
"react-i18next",
|
|
14
|
+
"i18next-vue",
|
|
15
|
+
"inertiajs",
|
|
16
|
+
"vite-plugin",
|
|
17
|
+
"vite-plugin-laravel"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"module": "./dist/index.mjs",
|
|
22
|
+
"types": "./dist/types/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/types/index.d.ts",
|
|
26
|
+
"import": "./dist/index.mjs",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
|
+
},
|
|
29
|
+
"./react": {
|
|
30
|
+
"types": "./dist/types/react/index.d.ts",
|
|
31
|
+
"import": "./dist/react.mjs",
|
|
32
|
+
"require": "./dist/react.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./vue": {
|
|
35
|
+
"types": "./dist/types/vue/index.d.ts",
|
|
36
|
+
"import": "./dist/vue.mjs",
|
|
37
|
+
"require": "./dist/vue.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./svelte": {
|
|
40
|
+
"types": "./dist/types/svelte/index.d.ts",
|
|
41
|
+
"import": "./dist/svelte.mjs",
|
|
42
|
+
"require": "./dist/svelte.cjs"
|
|
43
|
+
},
|
|
44
|
+
"./vite": {
|
|
45
|
+
"types": "./dist/types/vite.d.ts",
|
|
46
|
+
"import": "./dist/vite.mjs",
|
|
47
|
+
"require": "./dist/vite.cjs"
|
|
48
|
+
},
|
|
49
|
+
"./client": {
|
|
50
|
+
"types": "./client.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./package.json": "./package.json"
|
|
53
|
+
},
|
|
54
|
+
"typesVersions": {
|
|
55
|
+
"*": {
|
|
56
|
+
"react": [
|
|
57
|
+
"./dist/types/react/index.d.ts"
|
|
58
|
+
],
|
|
59
|
+
"vue": [
|
|
60
|
+
"./dist/types/vue/index.d.ts"
|
|
61
|
+
],
|
|
62
|
+
"svelte": [
|
|
63
|
+
"./dist/types/svelte/index.d.ts"
|
|
64
|
+
],
|
|
65
|
+
"vite": [
|
|
66
|
+
"./dist/types/vite.d.ts"
|
|
67
|
+
],
|
|
68
|
+
"client": [
|
|
69
|
+
"./client.d.ts"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"repository": "genrwork/js-modules",
|
|
74
|
+
"bugs": {
|
|
75
|
+
"url": "https://github.com/genrwork/js-modules/issues"
|
|
76
|
+
},
|
|
77
|
+
"author": {
|
|
78
|
+
"name": "genrwork",
|
|
79
|
+
"email": "contact@genrwork.com"
|
|
80
|
+
},
|
|
81
|
+
"license": "MIT",
|
|
82
|
+
"files": [
|
|
83
|
+
"dist",
|
|
84
|
+
"client.d.ts"
|
|
85
|
+
],
|
|
86
|
+
"scripts": {
|
|
87
|
+
"build": "rollup -c",
|
|
88
|
+
"dev": "rollup -c -w",
|
|
89
|
+
"test": "vitest run",
|
|
90
|
+
"typecheck": "tsc -p tsconfig.test.json",
|
|
91
|
+
"prepack": "npm run typecheck && npm test && npm run build"
|
|
92
|
+
},
|
|
93
|
+
"engines": {
|
|
94
|
+
"node": ">=18"
|
|
95
|
+
},
|
|
96
|
+
"dependencies": {
|
|
97
|
+
"php-array-reader": "^2.1.4"
|
|
98
|
+
},
|
|
99
|
+
"peerDependencies": {
|
|
100
|
+
"i18next": ">=24.0.0",
|
|
101
|
+
"i18next-vue": ">=5.0.0",
|
|
102
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
103
|
+
"react-i18next": ">=15.0.0",
|
|
104
|
+
"svelte": "^4.0.0 || ^5.0.0",
|
|
105
|
+
"vite": ">=5.0.0",
|
|
106
|
+
"vue": "^3.4.38"
|
|
107
|
+
},
|
|
108
|
+
"peerDependenciesMeta": {
|
|
109
|
+
"i18next-vue": {
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
112
|
+
"react": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
115
|
+
"react-i18next": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"svelte": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
121
|
+
"vite": {
|
|
122
|
+
"optional": true
|
|
123
|
+
},
|
|
124
|
+
"vue": {
|
|
125
|
+
"optional": true
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"devDependencies": {
|
|
129
|
+
"@inertiajs/react": "^3.7.1",
|
|
130
|
+
"@rollup/plugin-swc": "^0.4.1",
|
|
131
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
132
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
133
|
+
"@swc/core": "^1.16.2",
|
|
134
|
+
"@testing-library/react": "^16.3.3",
|
|
135
|
+
"@testing-library/svelte": "^5.4.2",
|
|
136
|
+
"@types/node": "^22.20.3",
|
|
137
|
+
"@types/react": "^19.3.0",
|
|
138
|
+
"@types/react-dom": "^19.3.0",
|
|
139
|
+
"@vitejs/plugin-vue": "^6.0.9",
|
|
140
|
+
"@vue/test-utils": "^2.5.1",
|
|
141
|
+
"i18next": "^26.4.2",
|
|
142
|
+
"i18next-vue": "^5.4.0",
|
|
143
|
+
"inertia-react-v2": "npm:@inertiajs/react@^2.3.28",
|
|
144
|
+
"jsdom": "^29.1.1",
|
|
145
|
+
"react": "^19.3.0",
|
|
146
|
+
"react-dom": "^19.3.0",
|
|
147
|
+
"react-i18next": "^17.0.14",
|
|
148
|
+
"rollup": "^4.63.3",
|
|
149
|
+
"svelte": "^5.57.0",
|
|
150
|
+
"typescript": "~5.9",
|
|
151
|
+
"vite": "^8.3.0",
|
|
152
|
+
"vitest": "^5.0.1",
|
|
153
|
+
"vue": "^3.5.42"
|
|
154
|
+
}
|
|
155
|
+
}
|
package/dist/types/format.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { i18n, TOptions } from 'i18next';
|
|
2
|
-
/**
|
|
3
|
-
* i18next format plugin translating the way Laravel does:
|
|
4
|
-
*
|
|
5
|
-
* - flat keys (`auth.failed`, `Welcome, :name!`), no key or namespace separators;
|
|
6
|
-
* - `:name`, `:NAME` and `:Name` replacements instead of `{{name}}` interpolation and `$t()` nesting;
|
|
7
|
-
* - a numeric `count` selects the message with Laravel's `trans_choice()` rules
|
|
8
|
-
* (`one|many`, `{0} none|[1,19] some|[20,*] many`) instead of `_one`/`_other` suffixed keys;
|
|
9
|
-
* - empty messages fall back to the next language.
|
|
10
|
-
*/
|
|
11
|
-
export default class LaravelFormat {
|
|
12
|
-
static type: "i18nFormat";
|
|
13
|
-
type: "i18nFormat";
|
|
14
|
-
/**
|
|
15
|
-
* Non-string translations (e.g. an empty PHP array) are returned as is.
|
|
16
|
-
*/
|
|
17
|
-
handleAsObject: boolean;
|
|
18
|
-
private i18next?;
|
|
19
|
-
init(i18next: i18n): void;
|
|
20
|
-
getResource(language: string, namespace: string, key: string): any;
|
|
21
|
-
addLookupKeys(finalKeys: string[]): string[];
|
|
22
|
-
parse(message: unknown, options: TOptions, language: string, namespace: string, _key?: string, info?: {
|
|
23
|
-
resolved?: {
|
|
24
|
-
usedLng?: string;
|
|
25
|
-
};
|
|
26
|
-
}): unknown;
|
|
27
|
-
/**
|
|
28
|
-
* The language the message actually resolved in, so pluralization always
|
|
29
|
-
* matches the text being pluralized -- never merely a language that has
|
|
30
|
-
* translations for the namespace, which is not the same thing once several
|
|
31
|
-
* sources can contribute to one namespace (see LaravelBackend): a single
|
|
32
|
-
* unrelated key from a higher-priority source is enough to make
|
|
33
|
-
* `hasResourceBundle(language, namespace)` true for a namespace whose
|
|
34
|
-
* actual message still came from the fallback language.
|
|
35
|
-
*
|
|
36
|
-
* i18next passes the language the lookup succeeded at as `resolved.usedLng`
|
|
37
|
-
* in `parse()`'s 6th argument (`extendTranslation()` in i18next's own
|
|
38
|
-
* `translator.js`); prefer it. Older i18next in the `>=24` peer range that
|
|
39
|
-
* does not pass it falls back to a heuristic: the current language when it
|
|
40
|
-
* has translations for the namespace, else the fallback language.
|
|
41
|
-
*/
|
|
42
|
-
private getPluralLocale;
|
|
43
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type ReplacementsInterface from '../interfaces/replacements';
|
|
2
|
-
/**
|
|
3
|
-
* Make the place-holder replacements on a line, the Laravel way:
|
|
4
|
-
* `:name` as is, `:NAME` upper-cased and `:Name` capitalized.
|
|
5
|
-
*
|
|
6
|
-
* @param message
|
|
7
|
-
* @param replacements
|
|
8
|
-
*/
|
|
9
|
-
export default function replacer(message: string, replacements?: ReplacementsInterface): string;
|
|
File without changes
|