@el-j/google-sheet-translations 2.0.0 → 2.0.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"action-entrypoint.d.ts","sourceRoot":"","sources":["../src/action-entrypoint.ts"],"names":[],"mappings":"AAKA,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CA4DzC"}
1
+ {"version":3,"file":"action-entrypoint.d.ts","sourceRoot":"","sources":["../src/action-entrypoint.ts"],"names":[],"mappings":"AAKA,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CA6DzC"}
@@ -3,4 +3,9 @@
3
3
  */
4
4
  /** Default wait time between Google Sheets API calls (in seconds) */
5
5
  export declare const DEFAULT_WAIT_SECONDS = 1;
6
+ /**
7
+ * Name of the reserved i18n metadata sheet.
8
+ * This sheet stores locale display names and must never receive translation key pushes.
9
+ */
10
+ export declare const I18N_SHEET_NAME = "i18n";
6
11
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,IAAI,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,eAAe,SAAS,CAAC"}
package/dist/esm/index.js CHANGED
@@ -59,6 +59,7 @@ import path from "node:path";
59
59
 
60
60
  // src/constants.ts
61
61
  var DEFAULT_WAIT_SECONDS = 1;
62
+ var I18N_SHEET_NAME = "i18n";
62
63
 
63
64
  // src/utils/configurationHandler.ts
64
65
  function normalizeConfig(options = {}) {
@@ -504,6 +505,7 @@ function findLocalChanges(localData, spreadsheetData) {
504
505
  const resolvedLocale = resolveLocaleWithFallback(locale, Object.keys(spreadsheetData));
505
506
  for (const sheet of Object.keys(localData[locale])) {
506
507
  if (!localData[locale][sheet]) continue;
508
+ if (sheet === I18N_SHEET_NAME) continue;
507
509
  for (const key of Object.keys(localData[locale][sheet])) {
508
510
  const isNewKey = !resolvedLocale || !spreadsheetData[resolvedLocale]?.[sheet] || !spreadsheetData[resolvedLocale][sheet][key];
509
511
  if (isNewKey) {
@@ -533,6 +535,10 @@ async function updateSpreadsheetWithLocalChanges(doc, changes, waitSeconds, auto
533
535
  for (const sheetTitle of new Set(
534
536
  Object.values(changes).flatMap((locale) => Object.keys(locale))
535
537
  )) {
538
+ if (sheetTitle === I18N_SHEET_NAME) {
539
+ console.log(`Skipping reserved metadata sheet "${sheetTitle}" \u2013 its content is managed separately.`);
540
+ continue;
541
+ }
536
542
  console.log(`Processing sheet: ${sheetTitle}`);
537
543
  let sheet = doc.sheetsByTitle[sheetTitle];
538
544
  if (!sheet) {
@@ -654,12 +660,12 @@ async function updateSpreadsheetWithLocalChanges(doc, changes, waitSeconds, auto
654
660
  if (localesWithValues.has(localeLower) || rowDataKey && rowData[rowDataKey]) {
655
661
  continue;
656
662
  }
657
- const exactHeaderName = headerRow.find(
663
+ const exactHeaderName = originalHeaders.find(
658
664
  (h) => h.toLowerCase() === localeLower
659
665
  );
660
666
  if (exactHeaderName) {
661
667
  const sourceHeaderIndex = headerRow.indexOf(sourceHeader.toLowerCase());
662
- const targetHeaderIndex = headerRow.indexOf(exactHeaderName);
668
+ const targetHeaderIndex = headerRow.indexOf(exactHeaderName.toLowerCase());
663
669
  if (sourceHeaderIndex < 0 || targetHeaderIndex < 0) {
664
670
  continue;
665
671
  }
package/dist/index.js CHANGED
@@ -124,6 +124,7 @@ var import_node_path = __toESM(require("node:path"));
124
124
 
125
125
  // src/constants.ts
126
126
  var DEFAULT_WAIT_SECONDS = 1;
127
+ var I18N_SHEET_NAME = "i18n";
127
128
 
128
129
  // src/utils/configurationHandler.ts
129
130
  function normalizeConfig(options = {}) {
@@ -569,6 +570,7 @@ function findLocalChanges(localData, spreadsheetData) {
569
570
  const resolvedLocale = resolveLocaleWithFallback(locale, Object.keys(spreadsheetData));
570
571
  for (const sheet of Object.keys(localData[locale])) {
571
572
  if (!localData[locale][sheet]) continue;
573
+ if (sheet === I18N_SHEET_NAME) continue;
572
574
  for (const key of Object.keys(localData[locale][sheet])) {
573
575
  const isNewKey = !resolvedLocale || !spreadsheetData[resolvedLocale]?.[sheet] || !spreadsheetData[resolvedLocale][sheet][key];
574
576
  if (isNewKey) {
@@ -598,6 +600,10 @@ async function updateSpreadsheetWithLocalChanges(doc, changes, waitSeconds, auto
598
600
  for (const sheetTitle of new Set(
599
601
  Object.values(changes).flatMap((locale) => Object.keys(locale))
600
602
  )) {
603
+ if (sheetTitle === I18N_SHEET_NAME) {
604
+ console.log(`Skipping reserved metadata sheet "${sheetTitle}" \u2013 its content is managed separately.`);
605
+ continue;
606
+ }
601
607
  console.log(`Processing sheet: ${sheetTitle}`);
602
608
  let sheet = doc.sheetsByTitle[sheetTitle];
603
609
  if (!sheet) {
@@ -719,12 +725,12 @@ async function updateSpreadsheetWithLocalChanges(doc, changes, waitSeconds, auto
719
725
  if (localesWithValues.has(localeLower) || rowDataKey && rowData[rowDataKey]) {
720
726
  continue;
721
727
  }
722
- const exactHeaderName = headerRow.find(
728
+ const exactHeaderName = originalHeaders.find(
723
729
  (h) => h.toLowerCase() === localeLower
724
730
  );
725
731
  if (exactHeaderName) {
726
732
  const sourceHeaderIndex = headerRow.indexOf(sourceHeader.toLowerCase());
727
- const targetHeaderIndex = headerRow.indexOf(exactHeaderName);
733
+ const targetHeaderIndex = headerRow.indexOf(exactHeaderName.toLowerCase());
728
734
  if (sourceHeaderIndex < 0 || targetHeaderIndex < 0) {
729
735
  continue;
730
736
  }
@@ -1 +1 @@
1
- {"version":3,"file":"findLocalChanges.d.ts","sourceRoot":"","sources":["../../../src/utils/dataConverter/findLocalChanges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC/B,SAAS,EAAE,eAAe,EAC1B,eAAe,EAAE,eAAe,GAC9B,eAAe,CAgCjB"}
1
+ {"version":3,"file":"findLocalChanges.d.ts","sourceRoot":"","sources":["../../../src/utils/dataConverter/findLocalChanges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC/B,SAAS,EAAE,eAAe,EAC1B,eAAe,EAAE,eAAe,GAC9B,eAAe,CAoCjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"spreadsheetUpdater.d.ts","sourceRoot":"","sources":["../../src/utils/spreadsheetUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA8B,MAAM,oBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAehD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,iCAAiC,CACnD,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,MAAM,EACnB,aAAa,UAAQ,EACrB,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC3C,OAAO,CAAC,IAAI,CAAC,CAqPf"}
1
+ {"version":3,"file":"spreadsheetUpdater.d.ts","sourceRoot":"","sources":["../../src/utils/spreadsheetUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA8B,MAAM,oBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAgBhD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,iCAAiC,CACnD,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,MAAM,EACnB,aAAa,UAAQ,EACrB,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC3C,OAAO,CAAC,IAAI,CAAC,CA4Pf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@el-j/google-sheet-translations",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A package to manage translations stored in Google Spreadsheets",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",