@nocode-factory/sanity-kit 2.65.0-rc.6 → 2.65.0-rc.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/CHANGELOG.md +7 -1
- package/bin/ncf-kit.mjs +6 -0
- package/bin/translation-audit.mjs +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/tools/pages/LanguagesSync.tsx +15 -4
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -53,7 +53,13 @@
|
|
|
53
53
|
- **`npx ncf-kit translations audit [--apply]`** : le détail (chemin, valeur actuelle, valeur
|
|
54
54
|
attendue) ; `--apply` corrige EN BROUILLON (rien n'est publié) : ancres remises à celle de
|
|
55
55
|
la version principale (règle : une ancre ne se traduit jamais), textes alternatifs marqués
|
|
56
|
-
« To translate » pour Pages → Languages → « Unfinished translations, retry ».
|
|
56
|
+
« To translate » pour Pages → Languages → « Unfinished translations, retry ». Contrôle
|
|
57
|
+
aussi les liens « adresse » vers une ancre de la page (`href: "#pratique"`) ; dit « rien à
|
|
58
|
+
corriger » quand c'est le cas. Validé sur JAF : 60 ancres remises, 25 textes alternatifs
|
|
59
|
+
traduits, doctor à zéro.
|
|
60
|
+
- **Pages → Languages, valeurs par défaut** : comptées depuis le brouillon en cours (une
|
|
61
|
+
traduction en relecture n'est plus « à traduire ») et sans les textes déjà repris par
|
|
62
|
+
« Unfinished translations » (plus de double comptage) ; nommées « Component defaults ».
|
|
57
63
|
- **Textes rendus à l'identique par l'IA** (noms propres, marques) : comptés comme
|
|
58
64
|
traduits, plus reproposés sans fin, et signalés « à vérifier » (vu sur JAF : 12 textes).
|
|
59
65
|
- **`doctor`, « Langues : contenus »** : une langue ne compte que si sa version est
|
package/bin/ncf-kit.mjs
CHANGED
|
@@ -1035,6 +1035,7 @@ async function translations() {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
let anchorsFixed = 0
|
|
1037
1037
|
let altsMarked = 0
|
|
1038
|
+
let found = 0
|
|
1038
1039
|
for (const [masterId, id, lang] of pairs) {
|
|
1039
1040
|
const [master, published, draft] = await Promise.all([
|
|
1040
1041
|
query(`*[_id == $id][0]`, {id: masterId}),
|
|
@@ -1045,6 +1046,7 @@ async function translations() {
|
|
|
1045
1046
|
if (!master || !target) continue
|
|
1046
1047
|
const {anchors, alts} = auditTranslation(master, target)
|
|
1047
1048
|
if (!anchors.length && !alts.length) continue
|
|
1049
|
+
found++
|
|
1048
1050
|
const title = target.title ?? target.name ?? (target._type === 'componentDefaults' ? 'Component defaults' : id)
|
|
1049
1051
|
console.log(`\n${lang.toUpperCase()} « ${title} » (${id})`)
|
|
1050
1052
|
for (const a of anchors) console.log(` ancre ${a} : « ${valueAt(target, a)} » → « ${valueAt(master, a)} »`)
|
|
@@ -1071,6 +1073,10 @@ async function translations() {
|
|
|
1071
1073
|
anchorsFixed += anchors.length
|
|
1072
1074
|
altsMarked += alts.length
|
|
1073
1075
|
}
|
|
1076
|
+
if (!found) {
|
|
1077
|
+
console.log('✔ Rien à corriger : ancres identiques à la version principale, textes alternatifs traduits.')
|
|
1078
|
+
return
|
|
1079
|
+
}
|
|
1074
1080
|
if (!apply) {
|
|
1075
1081
|
console.log('\nLecture seule. `npx ncf-kit translations audit --apply` : ancres remises et textes alternatifs marqués « To translate », EN BROUILLON (rien n\'est publié).')
|
|
1076
1082
|
return
|
|
@@ -27,7 +27,9 @@ export function auditTranslation(master, translated) {
|
|
|
27
27
|
if (k.startsWith('_')) continue
|
|
28
28
|
const w = b[k]
|
|
29
29
|
const at = path ? `${path}.${k}` : k
|
|
30
|
-
|
|
30
|
+
// Ancre d'une section ou d'un lien, et lien « adresse » vers une ancre de la page
|
|
31
|
+
// (href « #pratique », vu sur JAF : le bouton restait sur « #practical »).
|
|
32
|
+
if (typeof v === 'string' && (ANCHOR.test(k) || (k === 'href' && v.startsWith('#')))) {
|
|
31
33
|
if (v && typeof w === 'string' && w && w !== v) anchors.push(at)
|
|
32
34
|
} else if (typeof v === 'string' && k === 'alt' && isObj(a.asset)) {
|
|
33
35
|
if (v.trim() && w === v) alts.push(at)
|
package/dist/index.d.ts
CHANGED
|
@@ -1483,7 +1483,7 @@ export declare function ActorName(props: {
|
|
|
1483
1483
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1484
1484
|
* le vérifie.
|
|
1485
1485
|
*/
|
|
1486
|
-
export declare const KIT_VERSION = "2.65.0-rc.
|
|
1486
|
+
export declare const KIT_VERSION = "2.65.0-rc.7";
|
|
1487
1487
|
/**
|
|
1488
1488
|
* Données de la page proposées comme colonnes.
|
|
1489
1489
|
*
|
package/dist/index.js
CHANGED
|
@@ -1423,7 +1423,7 @@ function explainGrantError(error) {
|
|
|
1423
1423
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1424
1424
|
* le vérifie.
|
|
1425
1425
|
*/
|
|
1426
|
-
const KIT_VERSION = "2.65.0-rc.
|
|
1426
|
+
const KIT_VERSION = "2.65.0-rc.7";
|
|
1427
1427
|
/**
|
|
1428
1428
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1429
1429
|
*
|
|
@@ -1931,7 +1931,7 @@ function useKitUpdate() {
|
|
|
1931
1931
|
!controller.signal.aborted && body?.version && setLatest(body.version);
|
|
1932
1932
|
}).catch(() => {}), () => controller.abort();
|
|
1933
1933
|
}, []);
|
|
1934
|
-
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.65.0-rc.
|
|
1934
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.65.0-rc.7") > 0);
|
|
1935
1935
|
return {
|
|
1936
1936
|
current: KIT_VERSION,
|
|
1937
1937
|
latest,
|
|
@@ -4413,7 +4413,7 @@ const EXCLUDED = [
|
|
|
4413
4413
|
"translation.metadata",
|
|
4414
4414
|
BOARD_LAYOUT_TYPE,
|
|
4415
4415
|
TRANSLATION_TODO_TYPE
|
|
4416
|
-
], TITLE = "coalesce(title, name, heading, internalName, slug.current, _id)";
|
|
4416
|
+
], TITLE = "coalesce(title, name, heading, internalName, slug.current, _id)", label = (t) => /componentDefaults/.test(t.documentId) || /componentDefaults/.test(t.title ?? "") ? "Component defaults" : (t.title ?? t.documentId).replace(/^drafts\./, "");
|
|
4417
4417
|
/** Erreur lisible pour l'équipe (le service renvoie parfois un message technique). */
|
|
4418
4418
|
function explain$1(error) {
|
|
4419
4419
|
let e = error.toLowerCase();
|
|
@@ -4460,9 +4460,9 @@ function LanguagesSync() {
|
|
|
4460
4460
|
}), drafts = others.map((language) => ({
|
|
4461
4461
|
language,
|
|
4462
4462
|
count: draftOnly.filter((d) => d.language === language).length
|
|
4463
|
-
})).filter((d) => d.count), defaultsDocs = await client.fetch("*[_type == $type && !(_id in path(\"drafts.**\"))]", { type: defaultsType }), byLang = (lang) => defaultsDocs.find((d) => d[field] === lang) ?? null, sourceLang = byLang(i18n.defaultsSourceLocale) ? i18n.defaultsSourceLocale : main, sourceDoc = byLang(sourceLang), mainDoc = byLang(main), defaults = [];
|
|
4463
|
+
})).filter((d) => d.count), defaultsDocs = await client.fetch("*[_type == $type && !(_id in path(\"drafts.**\"))]", { type: defaultsType }), defaultsDrafts = await client.fetch("*[_type == $type && _id in path(\"drafts.**\")]", { type: defaultsType }), byLang = (lang) => defaultsDocs.find((d) => d[field] === lang) ?? null, currentOf = (doc) => defaultsDrafts.find((d) => d._id === `drafts.${String(doc._id)}`) ?? doc, inTodo = (doc) => new Set(unfinished.filter((t) => t.documentId === String(doc._id)).flatMap((t) => t.paths)), sourceLang = byLang(i18n.defaultsSourceLocale) ? i18n.defaultsSourceLocale : main, sourceDoc = byLang(sourceLang), mainDoc = byLang(main), defaults = [];
|
|
4464
4464
|
if (sourceDoc && mainDoc && sourceLang !== main) {
|
|
4465
|
-
let trace = await readTrace(client, String(sourceDoc._id)), texts = untranslatedPaths(mainDoc, sourceDoc, typeOf(defaultsType), trace).length;
|
|
4465
|
+
let trace = await readTrace(client, String(sourceDoc._id)), pending = inTodo(sourceDoc), texts = untranslatedPaths(mainDoc, currentOf(sourceDoc), typeOf(defaultsType), trace).filter((p) => !pending.has(p)).length;
|
|
4466
4466
|
texts && defaults.push({
|
|
4467
4467
|
language: sourceLang,
|
|
4468
4468
|
exists: !0,
|
|
@@ -4471,11 +4471,11 @@ function LanguagesSync() {
|
|
|
4471
4471
|
});
|
|
4472
4472
|
}
|
|
4473
4473
|
if (sourceDoc) for (let language of i18n.locales.filter((l) => l !== sourceLang)) {
|
|
4474
|
-
let doc = byLang(language), trace = doc ? await readTrace(client, String(doc._id)) : void 0;
|
|
4474
|
+
let doc = byLang(language), trace = doc ? await readTrace(client, String(doc._id)) : void 0, pending = doc ? inTodo(doc) : /* @__PURE__ */ new Set(), texts = untranslatedPaths(sourceDoc, doc ? currentOf(doc) : null, typeOf(defaultsType), trace).filter((p) => !pending.has(p)).length;
|
|
4475
4475
|
defaults.push({
|
|
4476
4476
|
language,
|
|
4477
4477
|
exists: !!doc,
|
|
4478
|
-
texts
|
|
4478
|
+
texts,
|
|
4479
4479
|
from: sourceLang
|
|
4480
4480
|
});
|
|
4481
4481
|
}
|
|
@@ -4539,7 +4539,7 @@ function LanguagesSync() {
|
|
|
4539
4539
|
}
|
|
4540
4540
|
if (pick.unfinished) for (let [n, t] of plan.unfinished.entries()) {
|
|
4541
4541
|
setProgress(`Unfinished translations ${n + 1}/${plan.unfinished.length}`);
|
|
4542
|
-
let what = `${(t.language ?? "").toUpperCase()} « ${t
|
|
4542
|
+
let what = `${(t.language ?? "").toUpperCase()} « ${label(t)} »`;
|
|
4543
4543
|
if (!t.language) {
|
|
4544
4544
|
fail(what, "language of the translated version unknown");
|
|
4545
4545
|
continue;
|
|
@@ -4710,7 +4710,7 @@ function LanguagesSync() {
|
|
|
4710
4710
|
children: [
|
|
4711
4711
|
(t.language ?? "").toUpperCase(),
|
|
4712
4712
|
" « ",
|
|
4713
|
-
t
|
|
4713
|
+
label(t),
|
|
4714
4714
|
" »: ",
|
|
4715
4715
|
t.paths.length,
|
|
4716
4716
|
" text",
|