lingo.dev 0.87.10 → 0.87.12

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
@@ -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
  },
@@ -1990,7 +1995,9 @@ function createPoDataLoader(params) {
1990
1995
  const csPo = _gettextparser2.default.po.parse(cs);
1991
1996
  const csContextKey = _lodash2.default.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 _gettextparser2.default.po.compile(updatedPo, { foldLength: params.multiline ? 76 : false }).toString().replace([`msgid ""`, `msgstr "Content-Type: text/plain\\n"`].join("\n"), "").trim();
2018
+ return _gettextparser2.default.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 = _lodash2.default.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 = _lodash2.default.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: [_optionalChain([data, 'access', _95 => _95[entry.msgid], 'optionalAccess', _96 => _96.singular]), _optionalChain([data, 'access', _97 => _97[entry.msgid], 'optionalAccess', _98 => _98.plural]) || null].filter(Boolean)
2051
+ msgstr: [
2052
+ _optionalChain([data, 'access', _95 => _95[entry.msgid], 'optionalAccess', _96 => _96.singular]),
2053
+ _optionalChain([data, 'access', _97 => _97[entry.msgid], 'optionalAccess', _98 => _98.plural]) || null
2054
+ ].filter(Boolean)
2037
2055
  }
2038
2056
  ]).fromPairs().value();
2039
2057
  return result;
@@ -3156,12 +3174,15 @@ function createMdxCodePlaceholderLoader() {
3156
3174
  const response = extractCodePlaceholders(input2);
3157
3175
  return response.content;
3158
3176
  },
3159
- async push(locale, data, originalInput) {
3160
- const response = extractCodePlaceholders(_nullishCoalesce(originalInput, () => ( "")));
3177
+ async push(locale, data, originalInput, originalLocale, pullInput) {
3178
+ const sourceInfo = extractCodePlaceholders(_nullishCoalesce(originalInput, () => ( "")));
3179
+ const currentInfo = extractCodePlaceholders(_nullishCoalesce(pullInput, () => ( "")));
3180
+ const codePlaceholders = _lodash2.default.merge(
3181
+ sourceInfo.codePlaceholders,
3182
+ currentInfo.codePlaceholders
3183
+ );
3161
3184
  let result = data;
3162
- for (const [placeholder, original] of Object.entries(
3163
- response.codePlaceholders
3164
- )) {
3185
+ for (const [placeholder, original] of Object.entries(codePlaceholders)) {
3165
3186
  const replacement = original.startsWith(">") ? _lodash2.default.trimStart(original, "> ") : original;
3166
3187
  result = result.replaceAll(placeholder, replacement);
3167
3188
  }
@@ -3279,11 +3300,11 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3279
3300
  case "mdx":
3280
3301
  return composeLoaders(
3281
3302
  createTextFileLoader(bucketPathPattern),
3282
- createMdxCodePlaceholderLoader(),
3283
3303
  createPrettierLoader({
3284
3304
  parser: "mdx",
3285
3305
  bucketPathPattern
3286
3306
  }),
3307
+ createMdxCodePlaceholderLoader(),
3287
3308
  createMdxFrontmatterSplitLoader(),
3288
3309
  createMdxSectionsSplit2Loader(),
3289
3310
  createLocalizableMdxDocumentLoader(),
@@ -5658,7 +5679,7 @@ function validateParams2(i18nConfig, flags) {
5658
5679
  // package.json
5659
5680
  var package_default = {
5660
5681
  name: "lingo.dev",
5661
- version: "0.87.10",
5682
+ version: "0.87.12",
5662
5683
  description: "Lingo.dev CLI",
5663
5684
  private: false,
5664
5685
  publishConfig: {