lingo.dev 0.92.17 → 0.92.19

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/cli.cjs CHANGED
@@ -2258,6 +2258,9 @@ function createPoDataLoader(params) {
2258
2258
  const sections = input2.split("\n\n").filter(Boolean);
2259
2259
  for (const section of sections) {
2260
2260
  const sectionPo = _gettextparser2.default.po.parse(section);
2261
+ if (Object.keys(sectionPo.translations).length === 0) {
2262
+ continue;
2263
+ }
2261
2264
  const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
2262
2265
  const entries = sectionPo.translations[contextKey];
2263
2266
  Object.entries(entries).forEach(([msgid, entry]) => {
@@ -2277,6 +2280,9 @@ function createPoDataLoader(params) {
2277
2280
  const originalSections = _optionalChain([originalInput, 'optionalAccess', _110 => _110.split, 'call', _111 => _111("\n\n"), 'access', _112 => _112.filter, 'call', _113 => _113(Boolean)]) || [];
2278
2281
  const result = originalSections.map((section) => {
2279
2282
  const sectionPo = _gettextparser2.default.po.parse(section);
2283
+ if (Object.keys(sectionPo.translations).length === 0) {
2284
+ return null;
2285
+ }
2280
2286
  const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
2281
2287
  const entries = sectionPo.translations[contextKey];
2282
2288
  const msgid = Object.keys(entries).find((key) => entries[key].msgid);
@@ -2305,13 +2311,14 @@ function createPoDataLoader(params) {
2305
2311
  }
2306
2312
  }
2307
2313
  });
2308
- return _gettextparser2.default.po.compile(updatedPo, { foldLength: params.multiline ? 76 : false }).toString().replace(
2314
+ const updatedSection = _gettextparser2.default.po.compile(updatedPo, { foldLength: params.multiline ? 76 : false }).toString().replace(
2309
2315
  [`msgid ""`, `msgstr "Content-Type: text/plain\\n"`].join("\n"),
2310
2316
  ""
2311
2317
  ).trim();
2318
+ return preserveCommentOrder(updatedSection, section);
2312
2319
  }
2313
2320
  return section.trim();
2314
- }).join("\n\n");
2321
+ }).filter(Boolean).join("\n\n");
2315
2322
  return result;
2316
2323
  }
2317
2324
  });
@@ -2348,6 +2355,35 @@ function createPoContentLoader() {
2348
2355
  }
2349
2356
  });
2350
2357
  }
2358
+ function preserveCommentOrder(section, originalSection) {
2359
+ const sectionLines = section.split(/\r?\n/);
2360
+ const originalLines = originalSection.split(/\r?\n/);
2361
+ const isComment = (line) => line.trim().startsWith("#");
2362
+ const sectionComments = sectionLines.filter(isComment);
2363
+ const nonCommentLines = sectionLines.filter((line) => !isComment(line));
2364
+ if (sectionComments.length <= 1) {
2365
+ return section;
2366
+ }
2367
+ const originalCommentOrder = originalLines.filter(isComment);
2368
+ const commentMap = /* @__PURE__ */ new Map();
2369
+ for (const line of sectionComments) {
2370
+ commentMap.set(line.trim(), line);
2371
+ }
2372
+ const reorderedComments = [];
2373
+ for (const orig of originalCommentOrder) {
2374
+ const trimmed = orig.trim();
2375
+ if (commentMap.has(trimmed)) {
2376
+ reorderedComments.push(commentMap.get(trimmed));
2377
+ commentMap.delete(trimmed);
2378
+ }
2379
+ }
2380
+ for (const line of sectionComments) {
2381
+ if (!originalCommentOrder.some((orig) => orig.trim() === line.trim())) {
2382
+ reorderedComments.push(line);
2383
+ }
2384
+ }
2385
+ return [...reorderedComments, ...nonCommentLines].join("\n").replace(/\n{3,}/g, "\n\n").trim();
2386
+ }
2351
2387
 
2352
2388
  // src/cli/loaders/xliff.ts
2353
2389
  var _xliff = require('xliff'); var _xliff2 = _interopRequireDefault(_xliff);
@@ -6544,7 +6580,7 @@ async function renderHero() {
6544
6580
  // package.json
6545
6581
  var package_default = {
6546
6582
  name: "lingo.dev",
6547
- version: "0.92.17",
6583
+ version: "0.92.19",
6548
6584
  description: "Lingo.dev CLI",
6549
6585
  private: false,
6550
6586
  publishConfig: {