@gjsify/vite-plugin-gettext 0.2.2 → 0.2.4
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 +11 -0
- package/dist/types.d.ts +14 -0
- package/dist/xgettext.js +118 -6
- package/dist/xgettext.js.map +1 -1
- package/package.json +11 -3
- package/src/types.ts +14 -0
- package/src/xgettext.ts +150 -6
package/README.md
CHANGED
|
@@ -44,6 +44,11 @@ export default defineConfig({
|
|
|
44
44
|
output: "po/messages.pot",
|
|
45
45
|
domain: "myapp",
|
|
46
46
|
keywords: ["_", "gettext", "ngettext"],
|
|
47
|
+
// Stabilize POT output for CI and avoid noisy diffs
|
|
48
|
+
noLocation: true,
|
|
49
|
+
deterministic: true,
|
|
50
|
+
sourceDateEpoch: 0,
|
|
51
|
+
sortOutput: true,
|
|
47
52
|
verbose: true,
|
|
48
53
|
}),
|
|
49
54
|
// Compile PO files to MO format (standard approach)
|
|
@@ -94,6 +99,12 @@ export default defineConfig({
|
|
|
94
99
|
- `keywords`: Keywords to look for when extracting strings (defaults to ['_', 'gettext', 'ngettext'])
|
|
95
100
|
- `xgettextOptions`: Additional options to pass to xgettext command
|
|
96
101
|
- `verbose`: Enable verbose logging
|
|
102
|
+
- `msgcatOptions`: Additional options to pass to msgcat when combining POT files
|
|
103
|
+
- `noLocation`: If true, omit source reference locations from POT/PO (passes `--no-location`)
|
|
104
|
+
- `deterministic`: If true, enable reproducible output (sets `SOURCE_DATE_EPOCH` and stable headers)
|
|
105
|
+
- `sourceDateEpoch`: Epoch seconds for reproducible timestamps (default: 0)
|
|
106
|
+
- `fixedCreationDate`: Force a fixed `POT-Creation-Date` header string
|
|
107
|
+
- `sortOutput`: Sort output messages for stable diffs (passes `--sort-output` to msgcat)
|
|
97
108
|
|
|
98
109
|
### gettextPlugin Options
|
|
99
110
|
|
package/dist/types.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface XGettextPluginOptions {
|
|
|
13
13
|
keywords?: string[];
|
|
14
14
|
/** Additional options to pass to xgettext command */
|
|
15
15
|
xgettextOptions?: string[];
|
|
16
|
+
/** Additional options to pass to msgcat when combining POT files */
|
|
17
|
+
msgcatOptions?: string[];
|
|
16
18
|
/** Enable verbose logging */
|
|
17
19
|
verbose?: boolean;
|
|
18
20
|
/** Automatically update PO files after POT changes */
|
|
@@ -25,6 +27,18 @@ export interface XGettextPluginOptions {
|
|
|
25
27
|
msgidBugsAddress?: string;
|
|
26
28
|
/** Copyright holder to set in the POT file */
|
|
27
29
|
copyrightHolder?: string;
|
|
30
|
+
/** If true, do not include source reference locations in POT/PO files */
|
|
31
|
+
noLocation?: boolean;
|
|
32
|
+
/** If true, attempt to make output reproducible (stable timestamps/order) */
|
|
33
|
+
deterministic?: boolean;
|
|
34
|
+
/** When deterministic is true, use this SOURCE_DATE_EPOCH (seconds since epoch). Defaults to 0. */
|
|
35
|
+
sourceDateEpoch?: number;
|
|
36
|
+
/** Optionally force a fixed POT-Creation-Date header value (e.g. '1970-01-01 00:00+0000') */
|
|
37
|
+
fixedCreationDate?: string;
|
|
38
|
+
/** If true, preserve the existing POT-Creation-Date from the current POT file if present */
|
|
39
|
+
preserveCreationDate?: boolean;
|
|
40
|
+
/** If true, sort the output messages for stable diffs (passed to msgcat) */
|
|
41
|
+
sortOutput?: boolean;
|
|
28
42
|
}
|
|
29
43
|
/**
|
|
30
44
|
* Configuration options for the gettext plugin
|
package/dist/xgettext.js
CHANGED
|
@@ -122,6 +122,21 @@ async function extractStrings(files, options, pluginName) {
|
|
|
122
122
|
try {
|
|
123
123
|
const outputDir = path.dirname(output);
|
|
124
124
|
await ensureDirectory(outputDir);
|
|
125
|
+
// Read existing POT-Creation-Date from previous POT if present (for preservation)
|
|
126
|
+
let prevPotCreationDate;
|
|
127
|
+
try {
|
|
128
|
+
const existingPot = await fs.readFile(output, "utf-8");
|
|
129
|
+
const m = existingPot.match(/"POT-Creation-Date:\s*([^\n]+)\\n"/);
|
|
130
|
+
if (m && m[1]) {
|
|
131
|
+
prevPotCreationDate = m[1];
|
|
132
|
+
if (verbose) {
|
|
133
|
+
console.log(`[${pluginName}] Found previous POT-Creation-Date '${prevPotCreationDate}'`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// No previous POT available
|
|
139
|
+
}
|
|
125
140
|
// Generate grouped POTFILES
|
|
126
141
|
const potFiles = await generatePotfiles(files, outputDir, pluginName, verbose);
|
|
127
142
|
// Create temporary POT files for each group
|
|
@@ -138,6 +153,9 @@ async function extractStrings(files, options, pluginName) {
|
|
|
138
153
|
"--from-code=UTF-8",
|
|
139
154
|
"--add-comments",
|
|
140
155
|
];
|
|
156
|
+
if (options.noLocation) {
|
|
157
|
+
args.push("--no-location");
|
|
158
|
+
}
|
|
141
159
|
// Add bug report address if specified
|
|
142
160
|
if (options.msgidBugsAddress) {
|
|
143
161
|
args.push("--msgid-bugs-address=" + options.msgidBugsAddress);
|
|
@@ -174,10 +192,22 @@ async function extractStrings(files, options, pluginName) {
|
|
|
174
192
|
args.push("--language=Desktop");
|
|
175
193
|
break;
|
|
176
194
|
}
|
|
195
|
+
// Allow custom xgettext options
|
|
196
|
+
if (options.xgettextOptions && options.xgettextOptions.length > 0) {
|
|
197
|
+
args.push(...options.xgettextOptions);
|
|
198
|
+
}
|
|
177
199
|
if (verbose) {
|
|
178
200
|
console.log(`[${pluginName}] Running xgettext for ${group}:`, args.join(" "));
|
|
179
201
|
}
|
|
180
|
-
|
|
202
|
+
// Enforce deterministic timestamps if requested
|
|
203
|
+
const env = { ...process.env };
|
|
204
|
+
if (options.deterministic) {
|
|
205
|
+
const epoch = typeof options.sourceDateEpoch === "number"
|
|
206
|
+
? options.sourceDateEpoch
|
|
207
|
+
: 0;
|
|
208
|
+
env.SOURCE_DATE_EPOCH = String(epoch);
|
|
209
|
+
}
|
|
210
|
+
await execa("xgettext", args, { env });
|
|
181
211
|
// Check if file exists before adding to tempPotFiles
|
|
182
212
|
try {
|
|
183
213
|
await fs.access(tempOutput);
|
|
@@ -192,8 +222,25 @@ async function extractStrings(files, options, pluginName) {
|
|
|
192
222
|
}
|
|
193
223
|
// Combine all temporary POT files using msgcat
|
|
194
224
|
if (tempPotFiles.length > 0) {
|
|
195
|
-
const msgcatArgs = ["--use-first"
|
|
196
|
-
|
|
225
|
+
const msgcatArgs = ["--use-first"];
|
|
226
|
+
if (options.noLocation) {
|
|
227
|
+
msgcatArgs.push("--no-location");
|
|
228
|
+
}
|
|
229
|
+
if (options.sortOutput) {
|
|
230
|
+
msgcatArgs.push("--sort-output");
|
|
231
|
+
}
|
|
232
|
+
if (options.msgcatOptions && options.msgcatOptions.length > 0) {
|
|
233
|
+
msgcatArgs.push(...options.msgcatOptions);
|
|
234
|
+
}
|
|
235
|
+
msgcatArgs.push("-o", output, ...tempPotFiles);
|
|
236
|
+
const env = { ...process.env };
|
|
237
|
+
if (options.deterministic) {
|
|
238
|
+
const epoch = typeof options.sourceDateEpoch === "number"
|
|
239
|
+
? options.sourceDateEpoch
|
|
240
|
+
: 0;
|
|
241
|
+
env.SOURCE_DATE_EPOCH = String(epoch);
|
|
242
|
+
}
|
|
243
|
+
await execa("msgcat", msgcatArgs, { env });
|
|
197
244
|
// Clean up temporary files
|
|
198
245
|
for (const tempFile of tempPotFiles) {
|
|
199
246
|
await fs.unlink(tempFile);
|
|
@@ -202,15 +249,55 @@ async function extractStrings(files, options, pluginName) {
|
|
|
202
249
|
await fs.unlink(potFile);
|
|
203
250
|
}
|
|
204
251
|
}
|
|
252
|
+
// Optionally normalize POT-Creation-Date header to a fixed or preserved value
|
|
253
|
+
if (options.fixedCreationDate || options.preserveCreationDate || options.deterministic) {
|
|
254
|
+
try {
|
|
255
|
+
let normalizedDate = undefined;
|
|
256
|
+
if (options.fixedCreationDate) {
|
|
257
|
+
normalizedDate = options.fixedCreationDate;
|
|
258
|
+
}
|
|
259
|
+
else if (options.preserveCreationDate) {
|
|
260
|
+
try {
|
|
261
|
+
const existing = await fs.readFile(output, "utf-8");
|
|
262
|
+
const match = existing.match(/"POT-Creation-Date:\s*([^\n]+)\\n"/);
|
|
263
|
+
if (match && match[1]) {
|
|
264
|
+
normalizedDate = match[1];
|
|
265
|
+
if (verbose) {
|
|
266
|
+
console.log(`[${pluginName}] Preserving existing POT-Creation-Date '${normalizedDate}'`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
// If file doesn't exist yet, fall back below
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (!normalizedDate && options.deterministic) {
|
|
275
|
+
normalizedDate = formatSourceDateEpoch(typeof options.sourceDateEpoch === "number" ? options.sourceDateEpoch : 0);
|
|
276
|
+
}
|
|
277
|
+
if (normalizedDate) {
|
|
278
|
+
const content = await fs.readFile(output, "utf-8");
|
|
279
|
+
const replaced = content.replace(/^"POT-Creation-Date: .*\\n"$/m, `"POT-Creation-Date: ${normalizedDate}\\n"`);
|
|
280
|
+
if (replaced !== content) {
|
|
281
|
+
await fs.writeFile(output, replaced);
|
|
282
|
+
if (verbose) {
|
|
283
|
+
console.log(`[${pluginName}] Normalized POT-Creation-Date to '${normalizedDate}'`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
catch (e) {
|
|
289
|
+
console.warn(`[${pluginName}] Failed to normalize POT-Creation-Date header:`, e);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
205
292
|
if (options.autoUpdatePo) {
|
|
206
|
-
await updatePoFiles(options.output, pluginName, options.verbose || false);
|
|
293
|
+
await updatePoFiles(options.output, pluginName, options.verbose || false, options);
|
|
207
294
|
}
|
|
208
295
|
}
|
|
209
296
|
catch (error) {
|
|
210
297
|
throw new Error(`Failed to extract translations: ${error}`);
|
|
211
298
|
}
|
|
212
299
|
}
|
|
213
|
-
async function updatePoFiles(potFile, pluginName, verbose) {
|
|
300
|
+
async function updatePoFiles(potFile, pluginName, verbose, options) {
|
|
214
301
|
try {
|
|
215
302
|
const linguasPath = path.join(path.dirname(potFile), "LINGUAS");
|
|
216
303
|
const languages = (await fs.readFile(linguasPath, "utf-8"))
|
|
@@ -221,13 +308,38 @@ async function updatePoFiles(potFile, pluginName, verbose) {
|
|
|
221
308
|
if (verbose) {
|
|
222
309
|
console.log(`[${pluginName}] Updating ${poFile}`);
|
|
223
310
|
}
|
|
224
|
-
|
|
311
|
+
const args = ["--update", "--backup=none"];
|
|
312
|
+
if (options.noLocation) {
|
|
313
|
+
args.push("--no-location");
|
|
314
|
+
}
|
|
315
|
+
const env = { ...process.env };
|
|
316
|
+
if (options.deterministic) {
|
|
317
|
+
const epoch = typeof options.sourceDateEpoch === "number"
|
|
318
|
+
? options.sourceDateEpoch
|
|
319
|
+
: 0;
|
|
320
|
+
env.SOURCE_DATE_EPOCH = String(epoch);
|
|
321
|
+
}
|
|
322
|
+
await execa("msgmerge", [...args, poFile, potFile], { env });
|
|
225
323
|
}
|
|
226
324
|
}
|
|
227
325
|
catch (error) {
|
|
228
326
|
console.error(`[${pluginName}] Error updating PO files:`, error);
|
|
229
327
|
}
|
|
230
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Formats a date in gettext header format using an epoch (seconds) in UTC timezone
|
|
331
|
+
* Example output: 1970-01-01 00:00+0000
|
|
332
|
+
*/
|
|
333
|
+
function formatSourceDateEpoch(epochSeconds) {
|
|
334
|
+
const date = new Date(epochSeconds * 1000);
|
|
335
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
336
|
+
const year = date.getUTCFullYear();
|
|
337
|
+
const month = pad(date.getUTCMonth() + 1);
|
|
338
|
+
const day = pad(date.getUTCDate());
|
|
339
|
+
const hours = pad(date.getUTCHours());
|
|
340
|
+
const minutes = pad(date.getUTCMinutes());
|
|
341
|
+
return `${year}-${month}-${day} ${hours}:${minutes}+0000`;
|
|
342
|
+
}
|
|
231
343
|
/**
|
|
232
344
|
* Finds the first existing metainfo.its file from installed gettext versions
|
|
233
345
|
* @returns The path to the metainfo.its file if found, otherwise undefined
|
package/dist/xgettext.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xgettext.js","sourceRoot":"","sources":["../src/xgettext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,4BAA4B;AAC5B,oHAAoH;AACpH,MAAM,gBAAgB,GAAG;IACvB,mBAAmB;IACnB,gBAAgB;IAChB,yDAAyD;IACzD,aAAa;IACb,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,yBAAyB;IACzB,2BAA2B;IAC3B,6BAA6B;IAC7B,2BAA2B;IAC3B,2BAA2B;IAC3B,4BAA4B;IAC5B,oCAAoC;IACpC,mCAAmC;IACnC,mCAAmC;IACnC,0CAA0C;IAC1C,+BAA+B;IAC/B,+BAA+B;IAC/B,2CAA2C;IAC3C,yBAAyB;IACzB,2BAA2B;IAC3B,8BAA8B;IAC9B,4BAA4B;IAC5B,6BAA6B;IAC7B,6BAA6B;IAC7B,8BAA8B;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC3D,MAAM,UAAU,GAAG,sBAAsB,CAAC;IAE1C,OAAO;QACL,IAAI,EAAE,UAAU;QAEhB,KAAK,CAAC,UAAU;YACd,MAAM,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;YAC1E,MAAM,KAAK,GAAG,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package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/vite-plugin-gettext",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Vite plugin for compiling Gettext PO files",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,11 +12,19 @@
|
|
|
12
12
|
},
|
|
13
13
|
"author": "Pascal Garber <pascal@mailfreun.de>",
|
|
14
14
|
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/gjsify/vite.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/gjsify/vite/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/gjsify/vite/tree/main/packages/vite-plugin-gettext",
|
|
15
23
|
"devDependencies": {
|
|
16
24
|
"@types/gettext-parser": "^8.0.0",
|
|
17
|
-
"@types/node": "^24.3.
|
|
25
|
+
"@types/node": "^24.3.1",
|
|
18
26
|
"typescript": "^5.9.2",
|
|
19
|
-
"vite": "^7.1.
|
|
27
|
+
"vite": "^7.1.5"
|
|
20
28
|
},
|
|
21
29
|
"peerDependencies": {
|
|
22
30
|
"vite": "*"
|
package/src/types.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface XGettextPluginOptions {
|
|
|
13
13
|
keywords?: string[];
|
|
14
14
|
/** Additional options to pass to xgettext command */
|
|
15
15
|
xgettextOptions?: string[];
|
|
16
|
+
/** Additional options to pass to msgcat when combining POT files */
|
|
17
|
+
msgcatOptions?: string[];
|
|
16
18
|
/** Enable verbose logging */
|
|
17
19
|
verbose?: boolean;
|
|
18
20
|
/** Automatically update PO files after POT changes */
|
|
@@ -25,6 +27,18 @@ export interface XGettextPluginOptions {
|
|
|
25
27
|
msgidBugsAddress?: string;
|
|
26
28
|
/** Copyright holder to set in the POT file */
|
|
27
29
|
copyrightHolder?: string;
|
|
30
|
+
/** If true, do not include source reference locations in POT/PO files */
|
|
31
|
+
noLocation?: boolean;
|
|
32
|
+
/** If true, attempt to make output reproducible (stable timestamps/order) */
|
|
33
|
+
deterministic?: boolean;
|
|
34
|
+
/** When deterministic is true, use this SOURCE_DATE_EPOCH (seconds since epoch). Defaults to 0. */
|
|
35
|
+
sourceDateEpoch?: number;
|
|
36
|
+
/** Optionally force a fixed POT-Creation-Date header value (e.g. '1970-01-01 00:00+0000') */
|
|
37
|
+
fixedCreationDate?: string;
|
|
38
|
+
/** If true, preserve the existing POT-Creation-Date from the current POT file if present */
|
|
39
|
+
preserveCreationDate?: boolean;
|
|
40
|
+
/** If true, sort the output messages for stable diffs (passed to msgcat) */
|
|
41
|
+
sortOutput?: boolean;
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
/**
|
package/src/xgettext.ts
CHANGED
|
@@ -163,6 +163,23 @@ async function extractStrings(
|
|
|
163
163
|
const outputDir = path.dirname(output);
|
|
164
164
|
await ensureDirectory(outputDir);
|
|
165
165
|
|
|
166
|
+
// Read existing POT-Creation-Date from previous POT if present (for preservation)
|
|
167
|
+
let prevPotCreationDate: string | undefined;
|
|
168
|
+
try {
|
|
169
|
+
const existingPot = await fs.readFile(output, "utf-8");
|
|
170
|
+
const m = existingPot.match(/"POT-Creation-Date:\s*([^\n]+)\\n"/);
|
|
171
|
+
if (m && m[1]) {
|
|
172
|
+
prevPotCreationDate = m[1];
|
|
173
|
+
if (verbose) {
|
|
174
|
+
console.log(
|
|
175
|
+
`[${pluginName}] Found previous POT-Creation-Date '${prevPotCreationDate}'`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} catch {
|
|
180
|
+
// No previous POT available
|
|
181
|
+
}
|
|
182
|
+
|
|
166
183
|
// Generate grouped POTFILES
|
|
167
184
|
const potFiles = await generatePotfiles(
|
|
168
185
|
files,
|
|
@@ -188,6 +205,10 @@ async function extractStrings(
|
|
|
188
205
|
"--add-comments",
|
|
189
206
|
];
|
|
190
207
|
|
|
208
|
+
if (options.noLocation) {
|
|
209
|
+
args.push("--no-location");
|
|
210
|
+
}
|
|
211
|
+
|
|
191
212
|
// Add bug report address if specified
|
|
192
213
|
if (options.msgidBugsAddress) {
|
|
193
214
|
args.push("--msgid-bugs-address=" + options.msgidBugsAddress);
|
|
@@ -229,6 +250,11 @@ async function extractStrings(
|
|
|
229
250
|
break;
|
|
230
251
|
}
|
|
231
252
|
|
|
253
|
+
// Allow custom xgettext options
|
|
254
|
+
if (options.xgettextOptions && options.xgettextOptions.length > 0) {
|
|
255
|
+
args.push(...options.xgettextOptions);
|
|
256
|
+
}
|
|
257
|
+
|
|
232
258
|
if (verbose) {
|
|
233
259
|
console.log(
|
|
234
260
|
`[${pluginName}] Running xgettext for ${group}:`,
|
|
@@ -236,7 +262,17 @@ async function extractStrings(
|
|
|
236
262
|
);
|
|
237
263
|
}
|
|
238
264
|
|
|
239
|
-
|
|
265
|
+
// Enforce deterministic timestamps if requested
|
|
266
|
+
const env = { ...process.env };
|
|
267
|
+
if (options.deterministic) {
|
|
268
|
+
const epoch =
|
|
269
|
+
typeof options.sourceDateEpoch === "number"
|
|
270
|
+
? options.sourceDateEpoch
|
|
271
|
+
: 0;
|
|
272
|
+
env.SOURCE_DATE_EPOCH = String(epoch);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
await execa("xgettext", args, { env });
|
|
240
276
|
|
|
241
277
|
// Check if file exists before adding to tempPotFiles
|
|
242
278
|
try {
|
|
@@ -256,8 +292,28 @@ async function extractStrings(
|
|
|
256
292
|
|
|
257
293
|
// Combine all temporary POT files using msgcat
|
|
258
294
|
if (tempPotFiles.length > 0) {
|
|
259
|
-
const msgcatArgs = ["--use-first"
|
|
260
|
-
|
|
295
|
+
const msgcatArgs = ["--use-first"];
|
|
296
|
+
if (options.noLocation) {
|
|
297
|
+
msgcatArgs.push("--no-location");
|
|
298
|
+
}
|
|
299
|
+
if (options.sortOutput) {
|
|
300
|
+
msgcatArgs.push("--sort-output");
|
|
301
|
+
}
|
|
302
|
+
if (options.msgcatOptions && options.msgcatOptions.length > 0) {
|
|
303
|
+
msgcatArgs.push(...options.msgcatOptions);
|
|
304
|
+
}
|
|
305
|
+
msgcatArgs.push("-o", output, ...tempPotFiles);
|
|
306
|
+
|
|
307
|
+
const env = { ...process.env };
|
|
308
|
+
if (options.deterministic) {
|
|
309
|
+
const epoch =
|
|
310
|
+
typeof options.sourceDateEpoch === "number"
|
|
311
|
+
? options.sourceDateEpoch
|
|
312
|
+
: 0;
|
|
313
|
+
env.SOURCE_DATE_EPOCH = String(epoch);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
await execa("msgcat", msgcatArgs, { env });
|
|
261
317
|
|
|
262
318
|
// Clean up temporary files
|
|
263
319
|
for (const tempFile of tempPotFiles) {
|
|
@@ -268,8 +324,66 @@ async function extractStrings(
|
|
|
268
324
|
}
|
|
269
325
|
}
|
|
270
326
|
|
|
327
|
+
// Optionally normalize POT-Creation-Date header to a fixed or preserved value
|
|
328
|
+
if (options.fixedCreationDate || options.preserveCreationDate || options.deterministic) {
|
|
329
|
+
try {
|
|
330
|
+
let normalizedDate: string | undefined = undefined;
|
|
331
|
+
|
|
332
|
+
if (options.fixedCreationDate) {
|
|
333
|
+
normalizedDate = options.fixedCreationDate;
|
|
334
|
+
} else if (options.preserveCreationDate) {
|
|
335
|
+
try {
|
|
336
|
+
const existing = await fs.readFile(output, "utf-8");
|
|
337
|
+
const match = existing.match(/"POT-Creation-Date:\s*([^\n]+)\\n"/);
|
|
338
|
+
if (match && match[1]) {
|
|
339
|
+
normalizedDate = match[1];
|
|
340
|
+
if (verbose) {
|
|
341
|
+
console.log(
|
|
342
|
+
`[${pluginName}] Preserving existing POT-Creation-Date '${normalizedDate}'`
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
} catch {
|
|
347
|
+
// If file doesn't exist yet, fall back below
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (!normalizedDate && options.deterministic) {
|
|
352
|
+
normalizedDate = formatSourceDateEpoch(
|
|
353
|
+
typeof options.sourceDateEpoch === "number" ? options.sourceDateEpoch : 0
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (normalizedDate) {
|
|
358
|
+
const content = await fs.readFile(output, "utf-8");
|
|
359
|
+
const replaced = content.replace(
|
|
360
|
+
/^"POT-Creation-Date: .*\\n"$/m,
|
|
361
|
+
`"POT-Creation-Date: ${normalizedDate}\\n"`
|
|
362
|
+
);
|
|
363
|
+
if (replaced !== content) {
|
|
364
|
+
await fs.writeFile(output, replaced);
|
|
365
|
+
if (verbose) {
|
|
366
|
+
console.log(
|
|
367
|
+
`[${pluginName}] Normalized POT-Creation-Date to '${normalizedDate}'`
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
} catch (e) {
|
|
373
|
+
console.warn(
|
|
374
|
+
`[${pluginName}] Failed to normalize POT-Creation-Date header:`,
|
|
375
|
+
e
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
271
380
|
if (options.autoUpdatePo) {
|
|
272
|
-
await updatePoFiles(
|
|
381
|
+
await updatePoFiles(
|
|
382
|
+
options.output,
|
|
383
|
+
pluginName,
|
|
384
|
+
options.verbose || false,
|
|
385
|
+
options
|
|
386
|
+
);
|
|
273
387
|
}
|
|
274
388
|
} catch (error) {
|
|
275
389
|
throw new Error(`Failed to extract translations: ${error}`);
|
|
@@ -279,7 +393,8 @@ async function extractStrings(
|
|
|
279
393
|
async function updatePoFiles(
|
|
280
394
|
potFile: string,
|
|
281
395
|
pluginName: string,
|
|
282
|
-
verbose: boolean
|
|
396
|
+
verbose: boolean,
|
|
397
|
+
options: XGettextPluginOptions
|
|
283
398
|
) {
|
|
284
399
|
try {
|
|
285
400
|
const linguasPath = path.join(path.dirname(potFile), "LINGUAS");
|
|
@@ -292,13 +407,42 @@ async function updatePoFiles(
|
|
|
292
407
|
if (verbose) {
|
|
293
408
|
console.log(`[${pluginName}] Updating ${poFile}`);
|
|
294
409
|
}
|
|
295
|
-
|
|
410
|
+
const args = ["--update", "--backup=none"] as string[];
|
|
411
|
+
if (options.noLocation) {
|
|
412
|
+
args.push("--no-location");
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const env = { ...process.env };
|
|
416
|
+
if (options.deterministic) {
|
|
417
|
+
const epoch =
|
|
418
|
+
typeof options.sourceDateEpoch === "number"
|
|
419
|
+
? options.sourceDateEpoch
|
|
420
|
+
: 0;
|
|
421
|
+
env.SOURCE_DATE_EPOCH = String(epoch);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
await execa("msgmerge", [...args, poFile, potFile], { env });
|
|
296
425
|
}
|
|
297
426
|
} catch (error) {
|
|
298
427
|
console.error(`[${pluginName}] Error updating PO files:`, error);
|
|
299
428
|
}
|
|
300
429
|
}
|
|
301
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Formats a date in gettext header format using an epoch (seconds) in UTC timezone
|
|
433
|
+
* Example output: 1970-01-01 00:00+0000
|
|
434
|
+
*/
|
|
435
|
+
function formatSourceDateEpoch(epochSeconds: number): string {
|
|
436
|
+
const date = new Date(epochSeconds * 1000);
|
|
437
|
+
const pad = (n: number) => String(n).padStart(2, "0");
|
|
438
|
+
const year = date.getUTCFullYear();
|
|
439
|
+
const month = pad(date.getUTCMonth() + 1);
|
|
440
|
+
const day = pad(date.getUTCDate());
|
|
441
|
+
const hours = pad(date.getUTCHours());
|
|
442
|
+
const minutes = pad(date.getUTCMinutes());
|
|
443
|
+
return `${year}-${month}-${day} ${hours}:${minutes}+0000`;
|
|
444
|
+
}
|
|
445
|
+
|
|
302
446
|
/**
|
|
303
447
|
* Finds the first existing metainfo.its file from installed gettext versions
|
|
304
448
|
* @returns The path to the metainfo.its file if found, otherwise undefined
|