@lingui/vite-plugin 4.0.0-next.0 → 4.0.0-next.2
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 +5 -1
- package/build/index.js +13 -3
- package/build/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# @lingui/vite-plugin
|
|
6
6
|
|
|
7
|
-
> Vite plugin
|
|
7
|
+
> Vite plugin that compiles Lingui catalogs on the fly. In summary, the `lingui compile` command isn't needed when using this plugin.
|
|
8
8
|
|
|
9
9
|
`@lingui/vite-plugin` is part of [LinguiJS][linguijs]. See the [documentation][documentation] for all information, tutorials and examples.
|
|
10
10
|
|
|
@@ -31,7 +31,11 @@ const config: UserConfig = {
|
|
|
31
31
|
### Then in Vite-processed code:
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
|
+
// *.po files assigned to this loader by default
|
|
34
35
|
const { messages } = await import(`./locales/${language}.po`);
|
|
36
|
+
|
|
37
|
+
// for other extension you have to use `?lingui` suffix
|
|
38
|
+
const { messages } = await import(`./locales/${language}.json?lingui`);
|
|
35
39
|
```
|
|
36
40
|
> See Vite's official documentation for more info about Vite dynamic imports
|
|
37
41
|
> https://vitejs.dev/guide/features.html#dynamic-import
|
package/build/index.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.lingui = void 0;
|
|
|
7
7
|
const conf_1 = require("@lingui/conf");
|
|
8
8
|
const api_1 = require("@lingui/cli/api");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const fileRegex =
|
|
10
|
+
const fileRegex = /(\.po|\?lingui)$/;
|
|
11
11
|
function lingui(linguiConfig = {}) {
|
|
12
12
|
const config = (0, conf_1.getConfig)(linguiConfig);
|
|
13
13
|
return {
|
|
@@ -17,12 +17,22 @@ function lingui(linguiConfig = {}) {
|
|
|
17
17
|
config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
|
|
18
18
|
config.optimizeDeps.exclude.push("@lingui/macro");
|
|
19
19
|
},
|
|
20
|
-
transform(src, id) {
|
|
20
|
+
async transform(src, id) {
|
|
21
21
|
if (fileRegex.test(id)) {
|
|
22
|
+
id = id.split("?")[0];
|
|
22
23
|
const catalogRelativePath = path_1.default.relative(config.rootDir, id);
|
|
23
24
|
const fileCatalog = (0, api_1.getCatalogForFile)(catalogRelativePath, (0, api_1.getCatalogs)(config));
|
|
25
|
+
if (!fileCatalog) {
|
|
26
|
+
throw new Error(`Requested resource ${catalogRelativePath} is not matched to any of your catalogs paths specified in "lingui.config".
|
|
27
|
+
|
|
28
|
+
Resource: ${id}
|
|
29
|
+
|
|
30
|
+
Your catalogs:
|
|
31
|
+
${config.catalogs.map((c) => c.path).join("\n")}
|
|
32
|
+
Please check that catalogs.path is filled properly.\n`);
|
|
33
|
+
}
|
|
24
34
|
const { locale, catalog } = fileCatalog;
|
|
25
|
-
const messages = catalog.getTranslations(locale, {
|
|
35
|
+
const messages = await catalog.getTranslations(locale, {
|
|
26
36
|
fallbackLocales: config.fallbackLocales,
|
|
27
37
|
sourceLocale: config.sourceLocale,
|
|
28
38
|
});
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAwC;AACxC,yCAIwB;AACxB,gDAAuB;AAGvB,MAAM,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAwC;AACxC,yCAIwB;AACxB,gDAAuB;AAGvB,MAAM,SAAS,GAAG,kBAAkB,CAAA;AAQpC,SAAgB,MAAM,CAAC,eAAiC,EAAE;IACxD,MAAM,MAAM,GAAG,IAAA,gBAAS,EAAC,YAAY,CAAC,CAAA;IAEtC,OAAO;QACL,IAAI,EAAE,oBAAoB;QAE1B,MAAM,EAAE,CA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C,CAAA;gBAEF,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,GAAG,EAAE,IAAI,EAAE,kCAAkC;iBAC9C,CAAA;aACF;QACH,CAAC;KACF,CAAA;AACH,CAAC;AAvDD,wBAuDC;AAED,kBAAe,MAAM,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/vite-plugin",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.2",
|
|
4
4
|
"description": "Vite plugin for Lingui message catalogs",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"build/"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@lingui/cli": "^4.0.0-next.
|
|
39
|
-
"@lingui/conf": "^4.0.0-next.
|
|
38
|
+
"@lingui/cli": "^4.0.0-next.2",
|
|
39
|
+
"@lingui/conf": "^4.0.0-next.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"vite": "
|
|
42
|
+
"vite": "4.1.4"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "556ab57e20c2ac9d384a22424c6a90c2ba0dd133"
|
|
45
45
|
}
|