@lingui/conf 4.0.0-next.1 → 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/build/makeConfig.d.ts +12 -2
- package/build/makeConfig.js +13 -3
- package/build/makeConfig.js.map +1 -1
- package/build/types.d.ts +102 -5
- package/package.json +2 -2
package/build/makeConfig.d.ts
CHANGED
|
@@ -18,14 +18,24 @@ export declare const exampleConfig: {
|
|
|
18
18
|
};
|
|
19
19
|
extractorParserOptions: {
|
|
20
20
|
flow: boolean;
|
|
21
|
-
|
|
21
|
+
tsExperimentalDecorators: boolean;
|
|
22
|
+
};
|
|
23
|
+
experimental: {
|
|
24
|
+
extractor: {
|
|
25
|
+
entries: any[];
|
|
26
|
+
includeDeps: any[];
|
|
27
|
+
excludeDeps: any[];
|
|
28
|
+
excludeExtensions: any[];
|
|
29
|
+
output: string;
|
|
30
|
+
resolveEsbuildOptions: FunctionConstructor;
|
|
31
|
+
};
|
|
22
32
|
};
|
|
23
33
|
catalogs?: import("./types").CatalogConfig[];
|
|
24
34
|
compileNamespace?: string;
|
|
25
35
|
compilerBabelOptions?: import("@babel/generator").GeneratorOptions;
|
|
26
36
|
prevFormat?: import("./types").CatalogFormat;
|
|
27
37
|
localeDir?: string;
|
|
28
|
-
format?: import("./types").CatalogFormat;
|
|
38
|
+
format?: import("./types").CatalogFormat | import("./types").CatalogFormatter;
|
|
29
39
|
formatOptions?: import("./types").CatalogFormatOptions;
|
|
30
40
|
locales: string[];
|
|
31
41
|
catalogsMergePath?: string;
|
package/build/makeConfig.js
CHANGED
|
@@ -44,13 +44,13 @@ exports.defaultConfig = {
|
|
|
44
44
|
},
|
|
45
45
|
extractorParserOptions: {
|
|
46
46
|
flow: false,
|
|
47
|
-
|
|
47
|
+
tsExperimentalDecorators: false,
|
|
48
48
|
},
|
|
49
49
|
fallbackLocales: {},
|
|
50
50
|
format: "po",
|
|
51
51
|
formatOptions: { origins: true, lineNumbers: true },
|
|
52
52
|
locales: [],
|
|
53
|
-
orderBy: "
|
|
53
|
+
orderBy: "message",
|
|
54
54
|
pseudoLocale: "",
|
|
55
55
|
rootDir: ".",
|
|
56
56
|
runtimeConfigModule: ["@lingui/core", "i18n"],
|
|
@@ -64,7 +64,17 @@ exports.exampleConfig = {
|
|
|
64
64
|
fallbackLocales: (0, jest_validate_1.multipleValidOptions)({}, { "en-US": "en" }, { "en-US": ["en"] }, { default: "en" }, false),
|
|
65
65
|
extractorParserOptions: {
|
|
66
66
|
flow: false,
|
|
67
|
-
|
|
67
|
+
tsExperimentalDecorators: false,
|
|
68
|
+
},
|
|
69
|
+
experimental: {
|
|
70
|
+
extractor: {
|
|
71
|
+
entries: [],
|
|
72
|
+
includeDeps: [],
|
|
73
|
+
excludeDeps: [],
|
|
74
|
+
excludeExtensions: [],
|
|
75
|
+
output: "",
|
|
76
|
+
resolveEsbuildOptions: Function,
|
|
77
|
+
},
|
|
68
78
|
},
|
|
69
79
|
};
|
|
70
80
|
/**
|
package/build/makeConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeConfig.js","sourceRoot":"","sources":["../src/makeConfig.ts"],"names":[],"mappings":";;;;;;AACA,kDAAyB;AACzB,2DAAuD;AACvD,iDAA8D;AAC9D,4EAAwE;AACxE,yDAAqD;AACrD,4FAAwF;AAExF,SAAgB,UAAU,CACxB,UAAiC,EACjC,OAEI,EAAE;IAEN,IAAI,MAAM,GAAiB;QACzB,GAAG,qBAAa;QAChB,GAAG,UAAU;KACd,CAAA;IAED,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;QACxB,IAAA,wBAAQ,EAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;QAClC,eAAe,CAAC,MAAM,CAAC,CAAA;KACxB;IAED,MAAM,GAAG,IAAI;IACX,+CAA+C;IAC/C,2CAAoB,EACpB,2DAA4B,CAC7B,CAAC,MAAM,CAAC,CAAA;IAET,6CAA6C;IAC7C,OAAO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ions } from "@babel/core";
|
|
2
2
|
export type CatalogFormat = "lingui" | "minimal" | "po" | "csv" | "po-gettext";
|
|
3
3
|
export type ExtractorCtx = {
|
|
4
4
|
/**
|
|
@@ -8,10 +8,46 @@ export type ExtractorCtx = {
|
|
|
8
8
|
sourceMaps?: any;
|
|
9
9
|
linguiConfig: LinguiConfigNormalized;
|
|
10
10
|
};
|
|
11
|
+
export type MessageOrigin = [filename: string, line?: number];
|
|
12
|
+
export type ExtractedMessageType = {
|
|
13
|
+
message?: string;
|
|
14
|
+
origin?: MessageOrigin[];
|
|
15
|
+
comments?: string[];
|
|
16
|
+
extractedComments?: string[];
|
|
17
|
+
obsolete?: boolean;
|
|
18
|
+
flags?: string[];
|
|
19
|
+
context?: string;
|
|
20
|
+
};
|
|
21
|
+
export type MessageType = ExtractedMessageType & {
|
|
22
|
+
translation: string;
|
|
23
|
+
};
|
|
24
|
+
export type ExtractedCatalogType = {
|
|
25
|
+
[msgId: string]: ExtractedMessageType;
|
|
26
|
+
};
|
|
27
|
+
export type CatalogType = {
|
|
28
|
+
[msgId: string]: MessageType;
|
|
29
|
+
};
|
|
11
30
|
export type ExtractorType = {
|
|
12
31
|
match(filename: string): boolean;
|
|
13
32
|
extract(filename: string, code: string, onMessageExtracted: (msg: ExtractedMessage) => void, ctx?: ExtractorCtx): Promise<void> | void;
|
|
14
33
|
};
|
|
34
|
+
export type CatalogFormatter = {
|
|
35
|
+
catalogExtension: string;
|
|
36
|
+
/**
|
|
37
|
+
* Set extension used when extract to template
|
|
38
|
+
* Omit if the extension is the same as catalogExtension
|
|
39
|
+
*/
|
|
40
|
+
templateExtension?: string;
|
|
41
|
+
parse(content: string, ctx: {
|
|
42
|
+
locale: string | null;
|
|
43
|
+
filename: string;
|
|
44
|
+
}): Promise<CatalogType> | CatalogType;
|
|
45
|
+
serialize(catalog: CatalogType, ctx: {
|
|
46
|
+
locale: string | null;
|
|
47
|
+
filename: string;
|
|
48
|
+
existing: string | null;
|
|
49
|
+
}): Promise<string> | string;
|
|
50
|
+
};
|
|
15
51
|
export type ExtractedMessage = {
|
|
16
52
|
id: string;
|
|
17
53
|
message?: string;
|
|
@@ -24,7 +60,7 @@ export type CatalogFormatOptions = {
|
|
|
24
60
|
lineNumbers?: boolean;
|
|
25
61
|
disableSelectWarning?: boolean;
|
|
26
62
|
};
|
|
27
|
-
export type OrderBy = "messageId" | "origin";
|
|
63
|
+
export type OrderBy = "messageId" | "message" | "origin";
|
|
28
64
|
export type CatalogConfig = {
|
|
29
65
|
name?: string;
|
|
30
66
|
path: string;
|
|
@@ -41,14 +77,72 @@ type CatalogService = {
|
|
|
41
77
|
name: string;
|
|
42
78
|
apiKey: string;
|
|
43
79
|
};
|
|
80
|
+
export type ExperimentalExtractorOptions = {
|
|
81
|
+
/**
|
|
82
|
+
* Entries to start extracting from.
|
|
83
|
+
* Each separate resolved entry would create a separate catalog.
|
|
84
|
+
*
|
|
85
|
+
* Example for MPA application like Next.js
|
|
86
|
+
* ```
|
|
87
|
+
* <rootDir>/pages/**\/*.ts
|
|
88
|
+
* <rootDir>/pages/**\/*.page.ts
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* With this config you would have a separate
|
|
92
|
+
* catalog for every page file in your app.
|
|
93
|
+
*/
|
|
94
|
+
entries: string[];
|
|
95
|
+
/**
|
|
96
|
+
* Explicitly include some dependency for extraction.
|
|
97
|
+
* For example, you can include all monorepo's packages as
|
|
98
|
+
* ["@mycompany/"]
|
|
99
|
+
*/
|
|
100
|
+
includeDeps?: string[];
|
|
101
|
+
/**
|
|
102
|
+
* By default all dependencies from package.json would be ecxluded from analyzing.
|
|
103
|
+
* If something was not properly discovered you can add it here.
|
|
104
|
+
*
|
|
105
|
+
* Note: it automatically matches also sub imports
|
|
106
|
+
*
|
|
107
|
+
* "next" would match "next" and "next/head"
|
|
108
|
+
*/
|
|
109
|
+
excludeDeps?: string[];
|
|
110
|
+
/**
|
|
111
|
+
* svg, jpg and other files which might be imported in application should be exluded from analysis.
|
|
112
|
+
* By default extractor provides a comprehensive list of extensions. If you feel like somthing is missing in this list please fill an issue on GitHub
|
|
113
|
+
*
|
|
114
|
+
* NOTE: changing this param will override default list of extensions.
|
|
115
|
+
*/
|
|
116
|
+
excludeExtensions?: string[];
|
|
117
|
+
/**
|
|
118
|
+
* output path for extracted catalogs.
|
|
119
|
+
*
|
|
120
|
+
* Supported placeholders for entry: /pages/about/index.page.ts
|
|
121
|
+
* - {entryName} = index.page
|
|
122
|
+
* - {locale} = en
|
|
123
|
+
* - {entryDir} = pages/about/
|
|
124
|
+
*
|
|
125
|
+
* Examples:
|
|
126
|
+
*
|
|
127
|
+
* ```
|
|
128
|
+
* <rootDir>/locales/{entryName}.{locale} -> /locales/index.page/en.po
|
|
129
|
+
* <rootDir>/{entryDir}/locales/{locale} -> /pages/about/locales/en.po
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
output: string;
|
|
133
|
+
resolveEsbuildOptions?: (options: any) => any;
|
|
134
|
+
};
|
|
44
135
|
export type LinguiConfig = {
|
|
45
136
|
catalogs?: CatalogConfig[];
|
|
46
137
|
compileNamespace?: "es" | "ts" | "cjs" | string;
|
|
47
138
|
extractorParserOptions?: {
|
|
48
139
|
/**
|
|
49
|
-
* default
|
|
140
|
+
* default false
|
|
141
|
+
*
|
|
142
|
+
* By default, standard decorators (Stage3) are applied for TS files
|
|
143
|
+
* Enable this if you want to use TypesScript's experimental decorators.
|
|
50
144
|
*/
|
|
51
|
-
|
|
145
|
+
tsExperimentalDecorators?: boolean;
|
|
52
146
|
/**
|
|
53
147
|
* Enable if you use flow. This will apply Flow syntax to js files
|
|
54
148
|
*/
|
|
@@ -59,7 +153,7 @@ export type LinguiConfig = {
|
|
|
59
153
|
extractors?: (string | ExtractorType)[];
|
|
60
154
|
prevFormat?: CatalogFormat;
|
|
61
155
|
localeDir?: string;
|
|
62
|
-
format?: CatalogFormat;
|
|
156
|
+
format?: CatalogFormat | CatalogFormatter;
|
|
63
157
|
formatOptions?: CatalogFormatOptions;
|
|
64
158
|
locales: string[];
|
|
65
159
|
catalogsMergePath?: string;
|
|
@@ -71,6 +165,9 @@ export type LinguiConfig = {
|
|
|
71
165
|
};
|
|
72
166
|
sourceLocale?: string;
|
|
73
167
|
service?: CatalogService;
|
|
168
|
+
experimental?: {
|
|
169
|
+
extractor?: ExperimentalExtractorOptions;
|
|
170
|
+
};
|
|
74
171
|
};
|
|
75
172
|
export type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
|
|
76
173
|
fallbackLocales?: FallbackLocales;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/conf",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "Get lingui configuration from package.json",
|
|
6
6
|
"keywords": [
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"@lingui/jest-mocks": "^3.0.3",
|
|
41
41
|
"tsd": "^0.26.1"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "556ab57e20c2ac9d384a22424c6a90c2ba0dd133"
|
|
44
44
|
}
|