scribe-cms 0.0.15 → 0.0.17
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/cli/index.cjs +156 -6
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +156 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +22 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/src/storage/translations.d.ts +8 -0
- package/dist/src/storage/translations.d.ts.map +1 -1
- package/dist/src/translate/prompts/translation-prompt.d.ts +2 -0
- package/dist/src/translate/prompts/translation-prompt.d.ts.map +1 -1
- package/dist/src/translate/worklist.d.ts +4 -1
- package/dist/src/translate/worklist.d.ts.map +1 -1
- package/dist/studio/server.cjs +141 -3
- package/dist/studio/server.cjs.map +1 -1
- package/dist/studio/server.d.ts.map +1 -1
- package/dist/studio/server.js +141 -3
- package/dist/studio/server.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2461,6 +2461,11 @@ function computePageEnHash(translatableFrontmatter, body) {
|
|
|
2461
2461
|
}
|
|
2462
2462
|
|
|
2463
2463
|
// src/translate/worklist.ts
|
|
2464
|
+
function parseContentTypeFilter(contentType) {
|
|
2465
|
+
if (!contentType) return void 0;
|
|
2466
|
+
const ids = contentType.split(",").map((id) => id.trim()).filter(Boolean);
|
|
2467
|
+
return ids.length > 0 ? new Set(ids) : void 0;
|
|
2468
|
+
}
|
|
2464
2469
|
function listEnSlugs4(rootDir, contentDir) {
|
|
2465
2470
|
const dir = path3__default.default.join(rootDir, contentDir);
|
|
2466
2471
|
if (!fs2__default.default.existsSync(dir)) return [];
|
|
@@ -2470,8 +2475,9 @@ function buildWorklist(config, options = {}) {
|
|
|
2470
2475
|
const db = openStore(config, "readonly");
|
|
2471
2476
|
const items = [];
|
|
2472
2477
|
const locales = options.locales ?? config.locales.filter((locale) => locale !== config.defaultLocale);
|
|
2478
|
+
const contentTypes = parseContentTypeFilter(options.contentType);
|
|
2473
2479
|
for (const type of config.types) {
|
|
2474
|
-
if (
|
|
2480
|
+
if (contentTypes && !contentTypes.has(type.id)) continue;
|
|
2475
2481
|
const enSlugs = options.enSlug ? [options.enSlug] : listEnSlugs4(config.rootDir, type.contentDir);
|
|
2476
2482
|
for (const enSlug of enSlugs) {
|
|
2477
2483
|
const enDoc = readEnDocument(config, type, enSlug);
|
|
@@ -2491,12 +2497,13 @@ function buildWorklist(config, options = {}) {
|
|
|
2491
2497
|
});
|
|
2492
2498
|
continue;
|
|
2493
2499
|
}
|
|
2494
|
-
|
|
2500
|
+
const stale = existing.en_hash !== currentEnHash;
|
|
2501
|
+
if (stale || options.force) {
|
|
2495
2502
|
items.push({
|
|
2496
2503
|
contentType: type.id,
|
|
2497
2504
|
enSlug,
|
|
2498
2505
|
locale,
|
|
2499
|
-
reason: "stale",
|
|
2506
|
+
reason: stale ? "stale" : "forced",
|
|
2500
2507
|
currentEnHash,
|
|
2501
2508
|
storedEnHash: existing.en_hash
|
|
2502
2509
|
});
|
|
@@ -2833,6 +2840,13 @@ function defaultLocalizationPrompt(localeName, locale) {
|
|
|
2833
2840
|
"Write as if a native speaker authored it for the target market."
|
|
2834
2841
|
].join(" ");
|
|
2835
2842
|
}
|
|
2843
|
+
function buildLocalizationPrompt(promptOverride, localeName, locale) {
|
|
2844
|
+
const localeDirective = defaultLocalizationPrompt(localeName, locale);
|
|
2845
|
+
if (!promptOverride) return localeDirective;
|
|
2846
|
+
return `${promptOverride}
|
|
2847
|
+
|
|
2848
|
+
${localeDirective}`;
|
|
2849
|
+
}
|
|
2836
2850
|
var TASK_FRAMING = "You are localizing the content below into a target language specified at the end of this prompt.";
|
|
2837
2851
|
function buildOutputFormatLine(hasFrontmatter, slugStrategy) {
|
|
2838
2852
|
if (!hasFrontmatter) {
|
|
@@ -2849,7 +2863,11 @@ function buildRetryContextSection(previousError) {
|
|
|
2849
2863
|
}
|
|
2850
2864
|
function buildPageTranslationPrompt(input) {
|
|
2851
2865
|
const localeName = LOCALE_NAMES[input.targetLocale] ?? input.targetLocale;
|
|
2852
|
-
const localizationPrompt =
|
|
2866
|
+
const localizationPrompt = buildLocalizationPrompt(
|
|
2867
|
+
input.resolved.promptOverride,
|
|
2868
|
+
localeName,
|
|
2869
|
+
input.targetLocale
|
|
2870
|
+
);
|
|
2853
2871
|
const prefix = [
|
|
2854
2872
|
TASK_FRAMING,
|
|
2855
2873
|
"",
|