lingo.dev 0.87.11 → 0.87.13

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.mjs CHANGED
@@ -1066,7 +1066,12 @@ function createLoader(lDefinition) {
1066
1066
  state.originalInput = input2 || null;
1067
1067
  }
1068
1068
  state.pullInput = input2;
1069
- const result = await lDefinition.pull(locale, input2, state.initCtx);
1069
+ const result = await lDefinition.pull(
1070
+ locale,
1071
+ input2,
1072
+ state.initCtx,
1073
+ state.defaultLocale
1074
+ );
1070
1075
  state.pullOutput = result;
1071
1076
  return result;
1072
1077
  },
@@ -1185,7 +1190,7 @@ function denormalizeObjectKeys(obj) {
1185
1190
  obj,
1186
1191
  (result, value, key) => {
1187
1192
  const newKey = !isNaN(Number(key)) ? `${OBJECT_NUMERIC_KEY_PREFIX}${key}` : key;
1188
- result[newKey] = _6.isObject(value) ? denormalizeObjectKeys(value) : value;
1193
+ result[newKey] = _6.isObject(value) && !_6.isDate(value) ? denormalizeObjectKeys(value) : value;
1189
1194
  },
1190
1195
  {}
1191
1196
  );
@@ -1199,7 +1204,7 @@ function normalizeObjectKeys(obj) {
1199
1204
  obj,
1200
1205
  (result, value, key) => {
1201
1206
  const newKey = `${key}`.replace(OBJECT_NUMERIC_KEY_PREFIX, "");
1202
- result[newKey] = _6.isObject(value) ? normalizeObjectKeys(value) : value;
1207
+ result[newKey] = _6.isObject(value) && !_6.isDate(value) ? normalizeObjectKeys(value) : value;
1203
1208
  },
1204
1209
  {}
1205
1210
  );
@@ -1990,7 +1995,9 @@ function createPoDataLoader(params) {
1990
1995
  const csPo = gettextParser.po.parse(cs);
1991
1996
  const csContextKey = _11.keys(csPo.translations)[0];
1992
1997
  const csEntries = csPo.translations[csContextKey];
1993
- const csMsgid = Object.keys(csEntries).find((key) => csEntries[key].msgid);
1998
+ const csMsgid = Object.keys(csEntries).find(
1999
+ (key) => csEntries[key].msgid
2000
+ );
1994
2001
  return csMsgid === msgid;
1995
2002
  });
1996
2003
  if (currentSection) {
@@ -2008,7 +2015,10 @@ function createPoDataLoader(params) {
2008
2015
  }
2009
2016
  }
2010
2017
  });
2011
- return gettextParser.po.compile(updatedPo, { foldLength: params.multiline ? 76 : false }).toString().replace([`msgid ""`, `msgstr "Content-Type: text/plain\\n"`].join("\n"), "").trim();
2018
+ return gettextParser.po.compile(updatedPo, { foldLength: params.multiline ? 76 : false }).toString().replace(
2019
+ [`msgid ""`, `msgstr "Content-Type: text/plain\\n"`].join("\n"),
2020
+ ""
2021
+ ).trim();
2012
2022
  }
2013
2023
  return section.trim();
2014
2024
  }).join("\n\n");
@@ -2018,14 +2028,19 @@ function createPoDataLoader(params) {
2018
2028
  }
2019
2029
  function createPoContentLoader() {
2020
2030
  return createLoader({
2021
- async pull(locale, input2) {
2022
- const result = _11.chain(input2).entries().filter(([, entry]) => !!entry.msgid).map(([, entry]) => [
2023
- entry.msgid,
2024
- {
2025
- singular: entry.msgstr[0] || entry.msgid,
2026
- plural: entry.msgstr[1] || entry.msgid_plural || null
2027
- }
2028
- ]).fromPairs().value();
2031
+ async pull(locale, input2, initCtx, originalLocale) {
2032
+ const result = _11.chain(input2).entries().filter(([, entry]) => !!entry.msgid).map(([, entry]) => {
2033
+ const singularFallback = locale === originalLocale ? entry.msgid : null;
2034
+ const pluralFallback = locale === originalLocale ? entry.msgid_plural || entry.msgid : null;
2035
+ const hasPlural = entry.msgstr.length > 1;
2036
+ return [
2037
+ entry.msgid,
2038
+ {
2039
+ singular: entry.msgstr[0] || singularFallback,
2040
+ plural: hasPlural ? entry.msgstr[1] || pluralFallback : null
2041
+ }
2042
+ ];
2043
+ }).fromPairs().value();
2029
2044
  return result;
2030
2045
  },
2031
2046
  async push(locale, data, originalInput) {
@@ -2033,7 +2048,10 @@ function createPoContentLoader() {
2033
2048
  entry.msgid,
2034
2049
  {
2035
2050
  ...entry,
2036
- msgstr: [data[entry.msgid]?.singular, data[entry.msgid]?.plural || null].filter(Boolean)
2051
+ msgstr: [
2052
+ data[entry.msgid]?.singular,
2053
+ data[entry.msgid]?.plural || null
2054
+ ].filter(Boolean)
2037
2055
  }
2038
2056
  ]).fromPairs().value();
2039
2057
  return result;
@@ -3073,11 +3091,13 @@ function createLockedKeysLoader(lockedKeys, isCacheRestore = false) {
3073
3091
 
3074
3092
  // src/cli/loaders/mdx2/frontmatter-split.ts
3075
3093
  import matter2 from "gray-matter";
3094
+ import YAML3 from "yaml";
3076
3095
  function createMdxFrontmatterSplitLoader() {
3096
+ const fmEngine = createFmEngine();
3077
3097
  return createLoader({
3078
3098
  async pull(locale, input2) {
3079
3099
  const source = input2 || "";
3080
- const { data: frontmatter, content } = matter2(source);
3100
+ const { data: frontmatter, content } = fmEngine.parse(source);
3081
3101
  return {
3082
3102
  frontmatter,
3083
3103
  content
@@ -3085,11 +3105,29 @@ function createMdxFrontmatterSplitLoader() {
3085
3105
  },
3086
3106
  async push(locale, data) {
3087
3107
  const { frontmatter = {}, content = "" } = data || {};
3088
- const result = matter2.stringify(content, frontmatter).trim();
3108
+ const result = fmEngine.stringify(content, frontmatter).trim();
3089
3109
  return result;
3090
3110
  }
3091
3111
  });
3092
3112
  }
3113
+ function createFmEngine() {
3114
+ const yamlEngine2 = {
3115
+ parse: (str) => YAML3.parse(str),
3116
+ stringify: (obj) => YAML3.stringify(obj, { defaultStringType: "PLAIN" })
3117
+ };
3118
+ return {
3119
+ parse: (input2) => matter2(input2, {
3120
+ engines: {
3121
+ yaml: yamlEngine2
3122
+ }
3123
+ }),
3124
+ stringify: (content, frontmatter) => matter2.stringify(content, frontmatter, {
3125
+ engines: {
3126
+ yaml: yamlEngine2
3127
+ }
3128
+ })
3129
+ };
3130
+ }
3093
3131
 
3094
3132
  // src/cli/utils/md5.ts
3095
3133
  import { MD5 } from "object-hash";
@@ -3282,15 +3320,16 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3282
3320
  case "mdx":
3283
3321
  return composeLoaders(
3284
3322
  createTextFileLoader(bucketPathPattern),
3285
- createMdxCodePlaceholderLoader(),
3286
3323
  createPrettierLoader({
3287
3324
  parser: "mdx",
3288
3325
  bucketPathPattern
3289
3326
  }),
3327
+ createMdxCodePlaceholderLoader(),
3290
3328
  createMdxFrontmatterSplitLoader(),
3291
3329
  createMdxSectionsSplit2Loader(),
3292
3330
  createLocalizableMdxDocumentLoader(),
3293
3331
  createFlatLoader(),
3332
+ createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
3294
3333
  createSyncLoader(),
3295
3334
  createUnlocalizableLoader(
3296
3335
  options.isCacheRestore,
@@ -3668,7 +3707,7 @@ function checkIfFileExists(filePath) {
3668
3707
 
3669
3708
  // src/cli/utils/delta.ts
3670
3709
  import * as path13 from "path";
3671
- import YAML3 from "yaml";
3710
+ import YAML4 from "yaml";
3672
3711
  var LockSchema = z.object({
3673
3712
  version: z.literal(1).default(1),
3674
3713
  checksums: z.record(
@@ -3718,7 +3757,7 @@ function createDeltaProcessor(fileKey) {
3718
3757
  },
3719
3758
  async loadLock() {
3720
3759
  const lockfileContent = tryReadFile(lockfilePath, null);
3721
- const lockfileYaml = lockfileContent ? YAML3.parse(lockfileContent) : null;
3760
+ const lockfileYaml = lockfileContent ? YAML4.parse(lockfileContent) : null;
3722
3761
  const lockfileData = lockfileYaml ? LockSchema.parse(lockfileYaml) : {
3723
3762
  version: 1,
3724
3763
  checksums: {}
@@ -3726,7 +3765,7 @@ function createDeltaProcessor(fileKey) {
3726
3765
  return lockfileData;
3727
3766
  },
3728
3767
  async saveLock(lockData) {
3729
- const lockfileYaml = YAML3.stringify(lockData);
3768
+ const lockfileYaml = YAML4.stringify(lockData);
3730
3769
  writeFile(lockfilePath, lockfileYaml);
3731
3770
  },
3732
3771
  async loadChecksums() {
@@ -4382,7 +4421,7 @@ import Ora6 from "ora";
4382
4421
  import fs11 from "fs";
4383
4422
  import path15 from "path";
4384
4423
  import Z4 from "zod";
4385
- import YAML4 from "yaml";
4424
+ import YAML5 from "yaml";
4386
4425
  import { MD5 as MD52 } from "object-hash";
4387
4426
  import _24 from "lodash";
4388
4427
  function createLockfileHelper() {
@@ -4420,12 +4459,12 @@ function createLockfileHelper() {
4420
4459
  return LockfileSchema.parse({});
4421
4460
  }
4422
4461
  const content = fs11.readFileSync(lockfilePath, "utf-8");
4423
- const result = LockfileSchema.parse(YAML4.parse(content));
4462
+ const result = LockfileSchema.parse(YAML5.parse(content));
4424
4463
  return result;
4425
4464
  }
4426
4465
  function _saveLockfile(lockfile) {
4427
4466
  const lockfilePath = _getLockfilePath();
4428
- const content = YAML4.stringify(lockfile);
4467
+ const content = YAML5.stringify(lockfile);
4429
4468
  fs11.writeFileSync(lockfilePath, content);
4430
4469
  }
4431
4470
  function _getLockfilePath() {
@@ -5661,7 +5700,7 @@ function validateParams2(i18nConfig, flags) {
5661
5700
  // package.json
5662
5701
  var package_default = {
5663
5702
  name: "lingo.dev",
5664
- version: "0.87.11",
5703
+ version: "0.87.13",
5665
5704
  description: "Lingo.dev CLI",
5666
5705
  private: false,
5667
5706
  publishConfig: {