@turbofy-ai/app-runtime 0.0.8 → 0.0.9
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/dist/src/dsl.d.ts +3 -0
- package/dist/src/dsl.js +22 -3
- package/package.json +1 -1
package/dist/src/dsl.d.ts
CHANGED
|
@@ -1874,7 +1874,10 @@ export interface IPageOutput {
|
|
|
1874
1874
|
id?: string;
|
|
1875
1875
|
name: string;
|
|
1876
1876
|
slugConfig: IPageSlugConfig;
|
|
1877
|
+
/** @deprecated Prefer `localizations`. Kept for the local DSL / old MCP. */
|
|
1877
1878
|
defaultLocalization?: LocalizationDictionary;
|
|
1879
|
+
/** Per-locale page copies / SEO meta (`{locale}_page_{pageId}`). */
|
|
1880
|
+
localizations?: ILocalizationsByLocale;
|
|
1878
1881
|
localizedConfig?: string;
|
|
1879
1882
|
blocks: IBlockOutput[];
|
|
1880
1883
|
}
|
package/dist/src/dsl.js
CHANGED
|
@@ -430,7 +430,26 @@ function pageLocalizedConfigCode() {
|
|
|
430
430
|
const slugConfig = $$self.slugConfig;
|
|
431
431
|
const appId = $$self.appId ?? '';
|
|
432
432
|
const lang = $$args.lang ?? 'en';
|
|
433
|
-
const
|
|
433
|
+
const resolveFallbackLocale = () => {
|
|
434
|
+
if (!appId) return 'en';
|
|
435
|
+
const appRecord = $$std.getRecord('cmsapp', appId);
|
|
436
|
+
if (!appRecord || typeof appRecord !== 'object') return 'en';
|
|
437
|
+
const settings = $$std.get(appRecord, 'settings');
|
|
438
|
+
const i18n = settings && typeof settings === 'object' ? settings.i18n : null;
|
|
439
|
+
if (!i18n || typeof i18n !== 'object') return 'en';
|
|
440
|
+
if (typeof i18n.fallback === 'string' && i18n.fallback) return i18n.fallback;
|
|
441
|
+
if (typeof i18n.default === 'string' && i18n.default) return i18n.default;
|
|
442
|
+
if (Array.isArray(i18n.locales) && typeof i18n.locales[0] === 'string' && i18n.locales[0]) {
|
|
443
|
+
return i18n.locales[0];
|
|
444
|
+
}
|
|
445
|
+
return 'en';
|
|
446
|
+
};
|
|
447
|
+
const fallbackLocale = resolveFallbackLocale();
|
|
448
|
+
const activeSlug =
|
|
449
|
+
slugConfig?.[lang]?.slug ??
|
|
450
|
+
slugConfig?.[fallbackLocale]?.slug ??
|
|
451
|
+
slugConfig?.en?.slug ??
|
|
452
|
+
'/';
|
|
434
453
|
const activeSlugArray = activeSlug.split('/').filter(Boolean);
|
|
435
454
|
|
|
436
455
|
const canonicalPathArray = [lang, ...activeSlugArray];
|
|
@@ -524,8 +543,8 @@ function pageLocalizedConfigCode() {
|
|
|
524
543
|
|
|
525
544
|
const layers = [];
|
|
526
545
|
for (const suffix of suffixes) {
|
|
527
|
-
if (lang !==
|
|
528
|
-
const fallbackLayer = fetchLocalizationDictionary(
|
|
546
|
+
if (lang !== fallbackLocale) {
|
|
547
|
+
const fallbackLayer = fetchLocalizationDictionary(fallbackLocale, suffix);
|
|
529
548
|
if (fallbackLayer) layers.push(fallbackLayer);
|
|
530
549
|
}
|
|
531
550
|
const activeLayer = fetchLocalizationDictionary(lang, suffix);
|