@nocode-factory/sanity-kit 2.65.0-rc.6 → 2.66.0-rc.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,60 +1,36 @@
1
1
  import {useCallback, useState} from 'react'
2
- import {Box, Button, Card, Checkbox, Dialog, Flex, Spinner, Stack, Text} from '@sanity/ui'
2
+ import {Box, Button, Card, Dialog, Flex, Spinner, Stack, Text} from '@sanity/ui'
3
3
  import {useSchema} from 'sanity'
4
4
  import {TranslateIcon} from '@sanity/icons/Translate'
5
5
  import {useKitConfig} from '../../context/KitContext'
6
6
  import {useKitClient} from '../../hooks/useKitClient'
7
7
  import type {SchemaTypeLike} from '../../lib/propagate'
8
- import {createTranslatedVersion, fillTranslation, retryTranslatedVersion, untranslatedPaths} from '../../lib/translateDocument'
9
- import {readTrace, recordTrace} from '../../lib/translationTrace'
10
- import {valueAtKey} from '../../lib/aiTexts'
8
+ import {createTranslatedVersion, fillTranslation, untranslatedPaths} from '../../lib/translateDocument'
9
+ import {recordTrace} from '../../lib/translationTrace'
11
10
  import {BOARD_LAYOUT_TYPE} from '../../schema/boardLayout'
12
11
  import {TRANSLATION_TODO_TYPE} from '../../schema/translationTodo'
13
12
 
14
13
  type Doc = Record<string, unknown>
15
- type Source = {_id: string; _type: string; title?: string}
16
- type Todo = {documentId: string; sourceId: string; sourceLanguage: string; paths: string[]; language?: string; title?: string}
17
14
 
18
15
  interface Plan {
19
16
  /** Documents de la langue principale sans version dans une langue. */
20
- missing: {language: string; docs: Source[]}[]
21
- /** Versions traduites inachevées (textes « To translate » : échec de l'IA, texte gardé...). */
22
- unfinished: Todo[]
23
- /** Versions traduites qui n'existent qu'en brouillon (à relire puis publier). */
24
- drafts: {language: string; count: number}[]
17
+ missing: {language: string; docs: {_id: string; _type: string}[]}[]
25
18
  /** Valeurs par défaut des composants : document absent, ou textes à traduire, par langue. */
26
19
  defaults: {language: string; exists: boolean; texts: number; from: string}[]
27
20
  }
28
21
 
29
- /** Ligne du compte rendu : réussite, à relire, ou échec AVEC sa raison. */
30
- type Line = {tone: 'positive' | 'caution' | 'critical'; text: string}
31
-
32
22
  const EXCLUDED = ['translation.metadata', BOARD_LAYOUT_TYPE, TRANSLATION_TODO_TYPE]
33
- const TITLE = 'coalesce(title, name, heading, internalName, slug.current, _id)'
34
-
35
- /** Erreur lisible pour l'équipe (le service renvoie parfois un message technique). */
36
- function explain(error: string): string {
37
- const e = error.toLowerCase()
38
- if (/401|403|unauthori|forbidden|key/.test(e)) return `${error} (kit project key: run \`npx ncf-kit setup\`)`
39
- if (/429|rate|quota|limit/.test(e)) return `${error} (AI service busy or quota reached: retry in a few minutes)`
40
- if (/timeout|timed out|network|fetch|50\d/.test(e)) return `${error} (AI service unreachable: retry in a few minutes)`
41
- if (/too (long|large)|length|token/.test(e)) return `${error} (text too long for one request: translate this field by hand)`
42
- return error
43
- }
44
23
 
45
24
  /**
46
25
  * Langues du site : met chaque langue au niveau de la langue principale, en UN clic
47
- * explicite (jamais tout seul). Utile à l'ajout d'une langue et après l'ajout d'un
48
- * composant (valeurs par défaut traduites dans chaque langue).
49
- * - On choisit ce qu'on traduit (documents manquants, traductions inachevées, valeurs
50
- * par défaut des composants) et, par défaut, tout est enregistré en BROUILLON à relire
51
- * (kit >= 2.65.0) : une traduction de l'IA n'est publiée sans relecture que si on coche
52
- * « Publish right away ».
53
- * - Chaque échec est listé avec sa raison ; une version inachevée (échec de l'IA) est
54
- * détectée et reprise par « Retry » (seulement ses textes à traduire).
55
- * - Valeurs par défaut : seuls les textes vides ou restés identiques au texte source sont
56
- * traduits (jamais un texte traduit à la main) ; un texte que l'IA a rendu à l'identique
57
- * (nom propre, marque) n'est plus reproposé.
26
+ * explicite (jamais tout seul). Utile à l'ajout d'une langue (« de » : toutes les
27
+ * pages en allemand) et après l'ajout d'un composant (valeurs par défaut traduites
28
+ * dans chaque langue).
29
+ * - Documents : chaque document publié de la langue principale sans version dans
30
+ * une langue reçoit sa version, traduite par l'IA, publiée et reliée.
31
+ * - Valeurs par défaut des composants : langue source (anglais en général), puis
32
+ * chaque langue ; un document absent est créé ; seuls les textes vides ou restés
33
+ * identiques au texte source sont traduits (jamais un texte traduit à la main).
58
34
  */
59
35
  export function LanguagesSync() {
60
36
  const config = useKitConfig()
@@ -64,9 +40,7 @@ export function LanguagesSync() {
64
40
  const [plan, setPlan] = useState<Plan | null>(null)
65
41
  const [busy, setBusy] = useState(false)
66
42
  const [progress, setProgress] = useState<string | null>(null)
67
- const [report, setReport] = useState<Line[] | null>(null)
68
- const [pick, setPick] = useState({missing: true, unfinished: true, defaults: true})
69
- const [publishNow, setPublishNow] = useState(false)
43
+ const [report, setReport] = useState<string[] | null>(null)
70
44
  const i18n = config.i18n
71
45
  const field = i18n?.field ?? 'language'
72
46
  const defaultsType = config.componentPreview.defaultsType
@@ -75,10 +49,10 @@ export function LanguagesSync() {
75
49
  const analyse = useCallback(async () => {
76
50
  if (!i18n) return
77
51
  setPlan(null)
52
+ setReport(null)
78
53
  const main = i18n.defaultLocale
79
- const others = i18n.locales.filter((l) => l !== main)
80
- const sources = await client.fetch<Source[]>(
81
- `*[defined(${field}) && ${field} == $main && !(_id in path("drafts.**")) && !(_type in $excluded)]{_id, _type, "title": ${TITLE}}`,
54
+ const sources = await client.fetch<{_id: string; _type: string}[]>(
55
+ `*[defined(${field}) && ${field} == $main && !(_id in path("drafts.**")) && !(_type in $excluded)]{_id, _type}`,
82
56
  {main, excluded: [...EXCLUDED, defaultsType]},
83
57
  )
84
58
  const metas = await client.fetch<{refs: {lang?: string; id?: string}[] | null}[]>(
@@ -89,173 +63,114 @@ export function LanguagesSync() {
89
63
  const langs = new Set((m.refs ?? []).map((r) => r.lang ?? ''))
90
64
  for (const r of m.refs ?? []) if (r.id) langsOf.set(r.id, langs)
91
65
  }
66
+ const others = i18n.locales.filter((l) => l !== main)
92
67
  const missing = others.map((language) => ({language, docs: sources.filter((d) => !langsOf.get(d._id)?.has(language))}))
93
68
 
94
- // Versions traduites inachevées : liste « To translate » non vide.
95
- const unfinished = await client.fetch<Todo[]>(
96
- `*[_type == $todo && count(paths) > 0]{documentId, sourceId, sourceLanguage, paths,
97
- "version": coalesce(*[_id == "drafts." + ^.documentId][0], *[_id == ^.documentId][0]){"language": ${field}, "title": ${TITLE}}}
98
- {documentId, sourceId, sourceLanguage, paths, "language": version.language, "title": version.title}`,
99
- {todo: TRANSLATION_TODO_TYPE},
100
- )
101
- // Versions qui n'existent qu'en brouillon (traduites, pas encore publiées).
102
- const draftOnly = await client.fetch<{language: string}[]>(
103
- `*[_id in path("drafts.**") && ${field} in $others && !(_type in $excluded) && !defined(*[_id == string::split(^._id, "drafts.")[1]][0]._id)]{"language": ${field}}`,
104
- {others, excluded: EXCLUDED},
105
- )
106
- const drafts = others.map((language) => ({language, count: draftOnly.filter((d) => d.language === language).length})).filter((d) => d.count)
107
-
108
69
  const defaultsDocs = await client.fetch<Doc[]>(`*[_type == $type && !(_id in path("drafts.**"))]`, {type: defaultsType})
109
70
  const byLang = (lang: string) => defaultsDocs.find((d) => d[field] === lang) ?? null
110
71
  const sourceLang = byLang(i18n.defaultsSourceLocale) ? i18n.defaultsSourceLocale : main
111
72
  const sourceDoc = byLang(sourceLang)
112
73
  const mainDoc = byLang(main)
113
74
  const defaults: Plan['defaults'] = []
114
- // 1. Un nouveau composant est rempli dans la langue principale : la langue source
115
- // (anglais) est d'abord complétée depuis elle.
75
+ // 1. Un nouveau composant est rempli dans la langue principale (démo, pages) :
76
+ // la langue source (anglais) est d'abord complétée depuis elle.
116
77
  if (sourceDoc && mainDoc && sourceLang !== main) {
117
- const trace = await readTrace(client, String(sourceDoc._id))
118
- const texts = untranslatedPaths(mainDoc, sourceDoc, typeOf(defaultsType), trace).length
78
+ const texts = untranslatedPaths(mainDoc, sourceDoc, typeOf(defaultsType)).length
119
79
  if (texts) defaults.push({language: sourceLang, exists: true, texts, from: main})
120
80
  }
121
81
  // 2. Puis chaque autre langue depuis la langue source.
122
82
  if (sourceDoc)
123
83
  for (const language of i18n.locales.filter((l) => l !== sourceLang)) {
124
84
  const doc = byLang(language)
125
- const trace = doc ? await readTrace(client, String(doc._id)) : undefined
126
- defaults.push({language, exists: Boolean(doc), texts: untranslatedPaths(sourceDoc, doc, typeOf(defaultsType), trace).length, from: sourceLang})
85
+ defaults.push({language, exists: Boolean(doc), texts: untranslatedPaths(sourceDoc, doc, typeOf(defaultsType)).length, from: sourceLang})
127
86
  }
128
- setPlan({missing, unfinished, drafts, defaults})
87
+ setPlan({missing, defaults})
129
88
  }, [client, defaultsType, field, i18n]) // eslint-disable-line react-hooks/exhaustive-deps
130
89
 
131
90
  const run = async () => {
132
91
  if (!plan || !i18n) return
133
92
  setBusy(true)
134
- setReport(null)
135
- const lines: Line[] = []
136
- const fail = (what: string, error: string) => lines.push({tone: 'critical', text: `${what}: ${explain(error)}`})
93
+ const lines: string[] = []
137
94
  try {
138
95
  // 1. Documents manquants (pages, collections, réglages par langue).
139
- if (pick.missing) {
140
- const total = plan.missing.reduce((n, m) => n + m.docs.length, 0)
141
- let n = 0
142
- for (const m of plan.missing) {
143
- let published = 0
144
- let review = 0
145
- for (const d of m.docs) {
146
- n++
147
- setProgress(`Documents ${n}/${total} (${m.language.toUpperCase()})`)
148
- const what = `${m.language.toUpperCase()} « ${d.title ?? d._id} »`
149
- try {
150
- const source = await client.getDocument<Doc>(d._id)
151
- if (!source) {
152
- fail(what, 'source version not found')
153
- continue
154
- }
155
- const created = await createTranslatedVersion({
156
- client,
157
- config,
158
- type: d._type,
159
- schemaType: typeOf(d._type),
160
- source,
161
- sourceId: d._id,
162
- sourceLanguage: i18n.defaultLocale,
163
- language: m.language,
164
- ai: true,
165
- publish: publishNow,
166
- })
167
- if (created.published) published++
168
- else if (created.complete) review++
169
- else if (created.aiError) fail(what, `AI translation failed, saved as a draft with ${created.remaining.length} text(s) to translate. ${created.aiError}`)
170
- else fail(what, `${created.remaining.length} text(s) not translated, saved as a draft (marked "To translate")`)
171
- } catch (cause) {
172
- fail(what, cause instanceof Error ? cause.message : String(cause))
173
- }
174
- }
175
- if (published) lines.push({tone: 'positive', text: `${m.language.toUpperCase()}: ${published} document(s) translated and published`})
176
- if (review) lines.push({tone: 'caution', text: `${m.language.toUpperCase()}: ${review} document(s) translated as drafts, to review then publish`})
177
- }
178
- }
179
- // 2. Traductions inachevées : on reprend seulement leurs textes à traduire.
180
- if (pick.unfinished)
181
- for (const [n, t] of plan.unfinished.entries()) {
182
- setProgress(`Unfinished translations ${n + 1}/${plan.unfinished.length}`)
183
- const what = `${(t.language ?? '').toUpperCase()} « ${t.title ?? t.documentId} »`
184
- if (!t.language) {
185
- fail(what, 'language of the translated version unknown')
186
- continue
187
- }
188
- const r = await retryTranslatedVersion({client, config, todo: t, language: t.language, publish: publishNow})
189
- if (r.aiError) fail(what, `still ${r.remaining.length} text(s) to translate. ${r.aiError}`)
190
- else if (r.remaining.length) fail(what, `${r.remaining.length} text(s) could not be placed (field changed since): translate them by hand`)
191
- else lines.push({tone: r.published ? 'positive' : 'caution', text: `${what}: completed${r.published ? ' and published' : ', draft to review then publish'}`})
192
- }
193
- // 3. Valeurs par défaut des composants.
194
- if (pick.defaults)
195
- for (const d of plan.defaults) {
196
- if (d.exists && !d.texts) continue
197
- const what = `Component defaults ${d.language.toUpperCase()}`
96
+ const total = plan.missing.reduce((n, m) => n + m.docs.length, 0)
97
+ let n = 0
98
+ for (const m of plan.missing) {
99
+ let ok = 0
100
+ let drafts = 0
101
+ for (const d of m.docs) {
102
+ n++
103
+ setProgress(`Documents ${n}/${total} (${m.language.toUpperCase()})`)
104
+ const source = await client.getDocument<Doc>(d._id)
105
+ if (!source) continue
198
106
  try {
199
- // Relu à chaque étape : l'étape précédente vient peut-être de compléter la source.
200
- const src = await client.fetch<Doc | null>(`*[_type == $type && ${field} == $lang && !(_id in path("drafts.**"))][0]`, {type: defaultsType, lang: d.from})
201
- if (!src) continue
202
- setProgress(`${what}`)
203
- if (!d.exists) {
204
- const created = await createTranslatedVersion({
205
- client,
206
- config,
207
- type: defaultsType,
208
- schemaType: typeOf(defaultsType),
209
- source: src,
210
- sourceId: String(src._id),
211
- sourceLanguage: d.from,
212
- language: d.language,
213
- ai: true,
214
- publish: publishNow,
215
- })
216
- if (created.aiError) fail(what, `AI translation failed, created as a draft. ${created.aiError}`)
217
- else lines.push({tone: created.published ? 'positive' : 'caution', text: `${what}: created${created.published ? ' and published' : ' as a draft, to review then publish'}`})
218
- continue
219
- }
220
- const published = await client.fetch<Doc | null>(`*[_type == $type && ${field} == $lang && !(_id in path("drafts.**"))][0]`, {type: defaultsType, lang: d.language})
221
- if (!published) continue
222
- const id = String(published._id)
223
- // Brouillon : complété depuis le brouillon en cours s'il existe (rien n'est défait).
224
- const base = (await client.getDocument<Doc>(`drafts.${id}`)) ?? published
225
- const filled = await fillTranslation({
107
+ const created = await createTranslatedVersion({
108
+ client,
226
109
  config,
227
- schemaType: typeOf(defaultsType),
228
- source: src,
229
- target: base,
230
- sourceLanguage: d.from,
231
- language: d.language,
232
- trace: await readTrace(client, id),
233
- })
234
- const {_rev, _updatedAt, _createdAt, ...doc} = filled.document
235
- const tx = client.transaction()
236
- if (publishNow) {
237
- tx.createOrReplace({...doc, _id: id} as {_id: string; _type: string})
238
- tx.delete(`drafts.${id}`)
239
- } else tx.createOrReplace({...doc, _id: `drafts.${id}`} as {_id: string; _type: string})
240
- await tx.commit()
241
- await recordTrace(client, id, filled.written, {sourceId: String(src._id), sourceLanguage: d.from})
242
- // Textes rendus à l'identique par l'IA (noms propres, marques) : signalés à vérifier.
243
- const unchanged = filled.written.filter((w) => JSON.stringify(w.value) === JSON.stringify(valueAtKey(src, w.path))).length
244
- if (filled.error) fail(what, `${filled.error} The other texts were kept; retry to translate the rest.`)
245
- lines.push({
246
- tone: publishNow ? 'positive' : 'caution',
247
- text: `${what}: ${filled.translated} text(s) translated${publishNow ? ' and published' : ' in the draft, to review then publish'}${unchanged ? ` (${unchanged} kept identical by the AI: names, brands... check them)` : ''}`,
110
+ type: d._type,
111
+ schemaType: typeOf(d._type),
112
+ source,
113
+ sourceId: d._id,
114
+ sourceLanguage: i18n.defaultLocale,
115
+ language: m.language,
116
+ ai: true,
248
117
  })
118
+ if (created.published) ok++
119
+ else drafts++
249
120
  } catch (cause) {
250
- fail(what, cause instanceof Error ? cause.message : String(cause))
121
+ lines.push(`${m.language.toUpperCase()} ${d._id}: ${cause instanceof Error ? cause.message : String(cause)}`)
251
122
  }
252
123
  }
124
+ if (m.docs.length) lines.unshift(`${m.language.toUpperCase()}: ${ok} published${drafts ? `, ${drafts} saved as drafts (texts to translate)` : ''}`)
125
+ }
126
+ // 2. Valeurs par défaut des composants.
127
+ for (const d of plan.defaults) {
128
+ if (d.exists && !d.texts) continue
129
+ // Relu à chaque étape : l'étape 1 vient peut-être de compléter la source.
130
+ const src = await client.fetch<Doc | null>(`*[_type == $type && ${field} == $lang && !(_id in path("drafts.**"))][0]`, {type: defaultsType, lang: d.from})
131
+ if (!src) continue
132
+ const sourceLang = d.from
133
+ setProgress(`Component defaults (${d.language.toUpperCase()})`)
134
+ if (!d.exists) {
135
+ await createTranslatedVersion({
136
+ client,
137
+ config,
138
+ type: defaultsType,
139
+ schemaType: typeOf(defaultsType),
140
+ source: src,
141
+ sourceId: String(src._id),
142
+ sourceLanguage: sourceLang,
143
+ language: d.language,
144
+ ai: true,
145
+ })
146
+ lines.push(`Component defaults ${d.language.toUpperCase()}: created`)
147
+ continue
148
+ }
149
+ const target = await client.fetch<Doc | null>(`*[_type == $type && ${field} == $lang && !(_id in path("drafts.**"))][0]`, {
150
+ type: defaultsType,
151
+ lang: d.language,
152
+ })
153
+ if (!target) continue
154
+ const filled = await fillTranslation({config, schemaType: typeOf(defaultsType), source: src, target, sourceLanguage: sourceLang, language: d.language})
155
+ const {_rev, _updatedAt, _createdAt, ...doc} = filled.document
156
+ const tx = client.transaction().createOrReplace(doc as {_id: string; _type: string})
157
+ // Brouillon en cours : complété aussi, pour que sa publication ne défasse rien.
158
+ const draft = await client.getDocument<Doc>(`drafts.${String(target._id)}`)
159
+ if (draft) {
160
+ const fd = await fillTranslation({config, schemaType: typeOf(defaultsType), source: src, target: draft, sourceLanguage: sourceLang, language: d.language})
161
+ const {_rev: r2, _updatedAt: u2, _createdAt: c2, ...dd} = fd.document
162
+ tx.createOrReplace(dd as {_id: string; _type: string})
163
+ }
164
+ await tx.commit()
165
+ await recordTrace(client, String(target._id), filled.written, {sourceId: String(src._id), sourceLanguage: sourceLang})
166
+ lines.push(`Component defaults ${d.language.toUpperCase()}: ${filled.translated} text${filled.translated > 1 ? 's' : ''} translated`)
167
+ }
253
168
  } catch (cause) {
254
- fail('Stopped', cause instanceof Error ? cause.message : String(cause))
169
+ lines.push(`Stopped: ${cause instanceof Error ? cause.message : String(cause)}`)
255
170
  } finally {
256
171
  setBusy(false)
257
172
  setProgress(null)
258
- setReport(lines.length ? lines : [{tone: 'positive', text: 'Everything was already up to date.'}])
173
+ setReport(lines.length ? lines : ['Everything was already up to date.'])
259
174
  void analyse()
260
175
  }
261
176
  }
@@ -263,17 +178,6 @@ export function LanguagesSync() {
263
178
  if (!i18n || !config.history) return null
264
179
  const pendingDocs = plan?.missing.reduce((n, m) => n + m.docs.length, 0) ?? 0
265
180
  const pendingDefaults = plan?.defaults.filter((d) => !d.exists || d.texts).length ?? 0
266
- const pendingUnfinished = plan?.unfinished.length ?? 0
267
- const selected = (pick.missing && pendingDocs) || (pick.unfinished && pendingUnfinished) || (pick.defaults && pendingDefaults)
268
- const failures = report?.filter((l) => l.tone === 'critical').length ?? 0
269
- const option = (key: keyof typeof pick, label: string, count: number) => (
270
- <Flex as="label" align="center" gap={2}>
271
- <Checkbox checked={pick[key] && count > 0} disabled={!count || busy} onChange={() => setPick({...pick, [key]: !pick[key]})} />
272
- <Text size={1} muted={!count}>
273
- {label}
274
- </Text>
275
- </Flex>
276
- )
277
181
 
278
182
  return (
279
183
  <>
@@ -285,7 +189,6 @@ export function LanguagesSync() {
285
189
  padding={2}
286
190
  onClick={() => {
287
191
  setOpen(true)
288
- setReport(null)
289
192
  void analyse()
290
193
  }}
291
194
  />
@@ -293,9 +196,9 @@ export function LanguagesSync() {
293
196
  <Dialog id="ncf-languages" header="Languages" width={1} onClose={() => !busy && setOpen(false)}>
294
197
  <Stack gap={4} padding={4}>
295
198
  <Text size={1} muted>
296
- Brings every language to the level of the main language ({i18n.defaultLocale.toUpperCase()}) with AI translation.
297
- Translations are saved as drafts to review, unless you choose to publish them right away. Texts already translated
298
- (even by hand) are never changed.
199
+ Brings every language to the level of the main language ({i18n.defaultLocale.toUpperCase()}): missing pages and
200
+ documents are created, translated with AI and published; component defaults are translated from{' '}
201
+ {i18n.defaultsSourceLocale.toUpperCase()}. Texts already translated (even by hand) are never changed.
299
202
  </Text>
300
203
  {!plan ? (
301
204
  <Flex align="center" gap={2}>
@@ -313,27 +216,6 @@ export function LanguagesSync() {
313
216
  </Text>
314
217
  </Card>
315
218
  ))}
316
- {plan.unfinished.length > 0 && (
317
- <Card padding={3} radius={2} border tone="critical">
318
- <Stack gap={2}>
319
- <Text size={1} weight="semibold">
320
- {plan.unfinished.length} unfinished translation{plan.unfinished.length > 1 ? 's' : ''} (texts still to translate)
321
- </Text>
322
- {plan.unfinished.slice(0, 8).map((t) => (
323
- <Text key={t.documentId} size={1} muted>
324
- {(t.language ?? '').toUpperCase()} « {t.title ?? t.documentId} »: {t.paths.length} text{t.paths.length > 1 ? 's' : ''}
325
- </Text>
326
- ))}
327
- </Stack>
328
- </Card>
329
- )}
330
- {plan.drafts.map((d) => (
331
- <Card key={`dr-${d.language}`} padding={3} radius={2} border tone="caution">
332
- <Text size={1}>
333
- {d.language.toUpperCase()}: {d.count} translated version{d.count > 1 ? 's' : ''} only in draft, not online yet (review then publish)
334
- </Text>
335
- </Card>
336
- ))}
337
219
  {plan.defaults.map((d) => (
338
220
  <Card key={`d-${d.language}`} padding={3} radius={2} border tone={!d.exists || d.texts ? 'caution' : 'positive'}>
339
221
  <Text size={1}>
@@ -342,20 +224,6 @@ export function LanguagesSync() {
342
224
  </Text>
343
225
  </Card>
344
226
  ))}
345
- <Stack gap={2}>
346
- <Text size={1} weight="semibold">
347
- Translate
348
- </Text>
349
- {option('missing', `Missing documents (${pendingDocs})`, pendingDocs)}
350
- {option('unfinished', `Unfinished translations, retry (${pendingUnfinished})`, pendingUnfinished)}
351
- {option('defaults', `Component defaults (${pendingDefaults} language${pendingDefaults > 1 ? 's' : ''})`, pendingDefaults)}
352
- <Box paddingTop={2}>
353
- <Flex as="label" align="center" gap={2}>
354
- <Checkbox checked={publishNow} disabled={busy} onChange={() => setPublishNow(!publishNow)} />
355
- <Text size={1}>Publish right away, without review (otherwise: drafts to review then publish)</Text>
356
- </Flex>
357
- </Box>
358
- </Stack>
359
227
  </Stack>
360
228
  )}
361
229
  {progress && (
@@ -365,27 +233,26 @@ export function LanguagesSync() {
365
233
  </Flex>
366
234
  )}
367
235
  {report && (
368
- <Stack gap={2}>
369
- {failures > 0 && (
370
- <Text size={1} weight="semibold">
371
- {failures} item{failures > 1 ? 's' : ''} failed: the reason is given for each. Fix it if needed, then retry (unfinished translations are kept and listed above).
372
- </Text>
373
- )}
374
- {report.map((line, i) => (
375
- <Card key={i} padding={3} radius={2} tone={line.tone}>
376
- <Text size={1}>{line.text}</Text>
377
- </Card>
378
- ))}
379
- </Stack>
236
+ <Card padding={3} radius={2} tone="primary">
237
+ <Stack gap={2}>
238
+ {report.map((line, i) => (
239
+ <Text key={i} size={1}>
240
+ {line}
241
+ </Text>
242
+ ))}
243
+ </Stack>
244
+ </Card>
380
245
  )}
381
246
  <Flex justify="flex-end" gap={2}>
382
247
  <Button text="Close" mode="ghost" disabled={busy} onClick={() => setOpen(false)} />
383
- <Button
384
- tone={publishNow ? 'caution' : 'primary'}
385
- text={busy ? 'Working…' : failures && pendingUnfinished ? 'Retry' : publishNow ? 'Translate with AI and publish' : 'Translate with AI (drafts)'}
386
- disabled={busy || !plan || !selected}
387
- onClick={() => void run()}
388
- />
248
+ <Box>
249
+ <Button
250
+ tone="primary"
251
+ text={busy ? 'Working…' : 'Translate with AI and publish'}
252
+ disabled={busy || !plan || (!pendingDocs && !pendingDefaults)}
253
+ onClick={() => void run()}
254
+ />
255
+ </Box>
389
256
  </Flex>
390
257
  </Stack>
391
258
  </Dialog>
package/src/version.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
4
4
  * le vérifie.
5
5
  */
6
- export const KIT_VERSION = '2.65.0-rc.6'
6
+ export const KIT_VERSION = '2.66.0-rc.1'