shopify-accelerate-app 1.0.49 → 1.0.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopify-accelerate-app",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "Shopify App development with full Typescript Support",
5
5
  "author": "Felix Tellmann",
6
6
  "license": "MIT",
@@ -267,8 +267,38 @@ export const generateLiquidFiles = (final?: boolean, cssOutput?: string) => {
267
267
  }
268
268
  };
269
269
 
270
+ function mergeLocales(base, overrides) {
271
+ const result = { ...base };
272
+
273
+ for (const key of Object.keys(overrides)) {
274
+ if (
275
+ key in result &&
276
+ typeof result[key] === "object" &&
277
+ result[key] !== null &&
278
+ typeof overrides[key] === "object" &&
279
+ overrides[key] !== null
280
+ ) {
281
+ result[key] = mergeLocales(result[key], overrides[key]);
282
+ } else {
283
+ result[key] = overrides[key];
284
+ }
285
+ }
286
+
287
+ return result;
288
+ }
289
+
290
+ const defaultSourceTranslations = JSON.parse(
291
+ fs.readFileSync(path.join(config.extension_path, `locales/en.default.json`), {
292
+ encoding: "utf-8",
293
+ }) ?? "{}"
294
+ );
295
+
270
296
  const translationsJs = `<script>
271
- window.__listify_translations = ${JSON.stringify(transformTranslations(translations), undefined, 2)};
297
+ window.__listify_translations = ${JSON.stringify(
298
+ mergeLocales(transformTranslations(translations), defaultSourceTranslations),
299
+ undefined,
300
+ 2
301
+ )};
272
302
  </script>
273
303
  `;
274
304
 
@@ -286,8 +316,8 @@ declare global {
286
316
  `;
287
317
 
288
318
  writeCompareFile(path.join(process.cwd(), extension_path, "locales", "en.default.json"), JSON.stringify(translations, undefined, 2));
289
- // writeCompareFile(path.join(process.cwd(), extension_path, "snippets", "translations.liquid"), translationsJs);
290
- // writeCompareFile(path.join(folders.snippets, "translations.liquid"), translationsJs);
319
+ writeCompareFile(path.join(process.cwd(), extension_path, "snippets", "translations.liquid"), translationsJs);
320
+ writeCompareFile(path.join(folders.snippets, "translations.liquid"), translationsJs);
291
321
  writeCompareFile(path.join(folders.types, "translations.ts"), translationTypes);
292
322
 
293
323
  const dynamicJsImports = [];