lingo.dev 0.85.5 → 0.85.7

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
@@ -1032,6 +1032,8 @@ function createLoader(lDefinition) {
1032
1032
  const state = {
1033
1033
  defaultLocale: void 0,
1034
1034
  originalInput: void 0,
1035
+ pullInput: void 0,
1036
+ pullOutput: void 0,
1035
1037
  initCtx: void 0
1036
1038
  };
1037
1039
  return {
@@ -1059,7 +1061,10 @@ function createLoader(lDefinition) {
1059
1061
  if (locale === state.defaultLocale) {
1060
1062
  state.originalInput = input2 || null;
1061
1063
  }
1062
- return lDefinition.pull(locale, input2, state.initCtx);
1064
+ state.pullInput = input2;
1065
+ const result = await lDefinition.pull(locale, input2, state.initCtx);
1066
+ state.pullOutput = result;
1067
+ return result;
1063
1068
  },
1064
1069
  async push(locale, data) {
1065
1070
  if (!state.defaultLocale) {
@@ -1068,7 +1073,14 @@ function createLoader(lDefinition) {
1068
1073
  if (state.originalInput === void 0) {
1069
1074
  throw new Error("Cannot push data without pulling first");
1070
1075
  }
1071
- const pushResult = await lDefinition.push(locale, data, state.originalInput, state.defaultLocale);
1076
+ const pushResult = await lDefinition.push(
1077
+ locale,
1078
+ data,
1079
+ state.originalInput,
1080
+ state.defaultLocale,
1081
+ state.pullInput,
1082
+ state.pullOutput
1083
+ );
1072
1084
  return pushResult;
1073
1085
  }
1074
1086
  };
@@ -1996,14 +2008,27 @@ function createPoDataLoader(params) {
1996
2008
  }
1997
2009
  return result;
1998
2010
  },
1999
- async push(locale, data, originalInput) {
2000
- const sections = originalInput?.split("\n\n").filter(Boolean) || [];
2001
- const result = sections.map((section) => {
2011
+ async push(locale, data, originalInput, originalLocale, pullInput) {
2012
+ const currentSections = pullInput?.split("\n\n").filter(Boolean) || [];
2013
+ const originalSections = originalInput?.split("\n\n").filter(Boolean) || [];
2014
+ const result = originalSections.map((section) => {
2002
2015
  const sectionPo = gettextParser.po.parse(section);
2003
2016
  const contextKey = _12.keys(sectionPo.translations)[0];
2004
2017
  const entries = sectionPo.translations[contextKey];
2005
2018
  const msgid = Object.keys(entries).find((key) => entries[key].msgid);
2006
- if (!msgid) return section;
2019
+ if (!msgid) {
2020
+ const currentSection = currentSections.find((cs) => {
2021
+ const csPo = gettextParser.po.parse(cs);
2022
+ const csContextKey = _12.keys(csPo.translations)[0];
2023
+ const csEntries = csPo.translations[csContextKey];
2024
+ const csMsgid = Object.keys(csEntries).find((key) => csEntries[key].msgid);
2025
+ return csMsgid === msgid;
2026
+ });
2027
+ if (currentSection) {
2028
+ return currentSection;
2029
+ }
2030
+ return section;
2031
+ }
2007
2032
  if (data[msgid]) {
2008
2033
  const updatedPo = _12.merge({}, sectionPo, {
2009
2034
  translations: {
@@ -3658,7 +3683,9 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
3658
3683
  ora.succeed("Buckets retrieved");
3659
3684
  if (flags.file?.length) {
3660
3685
  buckets = buckets.map((bucket) => {
3661
- const paths = bucket.paths.filter((path18) => flags.file.find((file) => path18.pathPattern?.match(file)));
3686
+ const paths = bucket.paths.filter(
3687
+ (path18) => flags.file.find((file) => path18.pathPattern?.includes(file))
3688
+ );
3662
3689
  return { ...bucket, paths };
3663
3690
  }).filter((bucket) => bucket.paths.length > 0);
3664
3691
  if (buckets.length === 0) {
@@ -5458,7 +5485,7 @@ function validateParams2(i18nConfig, flags) {
5458
5485
  // package.json
5459
5486
  var package_default = {
5460
5487
  name: "lingo.dev",
5461
- version: "0.85.5",
5488
+ version: "0.85.7",
5462
5489
  description: "Lingo.dev CLI",
5463
5490
  private: false,
5464
5491
  publishConfig: {