@proveanything/smartlinks 2.1.31 → 2.1.32
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/api/translations.d.ts +6 -1
- package/dist/api/translations.js +11 -1
- package/dist/docs/API_SUMMARY.md +31 -2
- package/dist/docs/translations.md +24 -0
- package/dist/index.d.ts +1 -1
- package/dist/openapi.yaml +106 -0
- package/dist/types/translations.d.ts +33 -0
- package/docs/API_SUMMARY.md +31 -2
- package/docs/translations.md +24 -0
- package/openapi.yaml +106 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TranslationActivity } from '../translationActivity.js';
|
|
2
|
-
import type { ResolvedTranslationResponse, TranslationHashOptions, TranslationListParams, TranslationListResponse, TranslationLookupRequest, TranslationLookupResponse, TranslationRecord, TranslationResolveOptions, TranslationUpdateRequest } from '../types/translations.js';
|
|
2
|
+
import type { ResolvedTranslationResponse, TranslationHashOptions, TranslationListParams, TranslationListResponse, TranslationLookupRequest, TranslationLookupResponse, TranslationRecord, TranslationResolveOptions, TranslationRules, TranslationUpdateRequest } from '../types/translations.js';
|
|
3
3
|
/** @internal tests only */
|
|
4
4
|
export declare function _resetRevisionChecks(): void;
|
|
5
5
|
export declare namespace translations {
|
|
@@ -31,6 +31,7 @@ export declare namespace translations {
|
|
|
31
31
|
language: string;
|
|
32
32
|
total: number;
|
|
33
33
|
edited: number;
|
|
34
|
+
issues?: number;
|
|
34
35
|
}>;
|
|
35
36
|
}>;
|
|
36
37
|
/** Admin: where translated text appears for one language (context keys), with counts. */
|
|
@@ -43,5 +44,9 @@ export declare namespace translations {
|
|
|
43
44
|
}>;
|
|
44
45
|
/** Admin: undo a person's edit with a fresh machine translation. */
|
|
45
46
|
function reset(collectionId: string, translationId: string): Promise<TranslationRecord>;
|
|
47
|
+
/** Admin: the site's translation rules (brief, notes per language, required terms). */
|
|
48
|
+
function rules(collectionId: string): Promise<TranslationRules>;
|
|
49
|
+
/** Admin: replace the site's translation rules. They apply to new translations from now on. */
|
|
50
|
+
function saveRules(collectionId: string, body: Pick<TranslationRules, 'guidance' | 'languages' | 'terms'>): Promise<TranslationRules>;
|
|
46
51
|
function clearLocalCache(collectionId?: string): Promise<void>;
|
|
47
52
|
}
|
package/dist/api/translations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isProxyEnabled, patch, post, request } from '../http.js';
|
|
1
|
+
import { isProxyEnabled, patch, post, put, request } from '../http.js';
|
|
2
2
|
import { clearCachedTranslations, deriveTranslationContextKey, getCachedTranslations, getDefaultTranslationCacheTtlMs, hashTranslationText, normalizeTranslationText, setCachedTranslations, } from '../translationCache.js';
|
|
3
3
|
import { trackTranslation, onActivity as onTranslationActivity, activity as translationActivity, translatingMessage as translatingLine } from '../translationActivity.js';
|
|
4
4
|
function normalizeLookupRequest(body) {
|
|
@@ -305,6 +305,16 @@ export var translations;
|
|
|
305
305
|
return post(`/admin/collection/${encodeURIComponent(collectionId)}/translations/${encodeURIComponent(translationId)}/reset`, {});
|
|
306
306
|
}
|
|
307
307
|
translations.reset = reset;
|
|
308
|
+
/** Admin: the site's translation rules (brief, notes per language, required terms). */
|
|
309
|
+
async function rules(collectionId) {
|
|
310
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/translations/rules`);
|
|
311
|
+
}
|
|
312
|
+
translations.rules = rules;
|
|
313
|
+
/** Admin: replace the site's translation rules. They apply to new translations from now on. */
|
|
314
|
+
async function saveRules(collectionId, body) {
|
|
315
|
+
return put(`/admin/collection/${encodeURIComponent(collectionId)}/translations/rules`, body);
|
|
316
|
+
}
|
|
317
|
+
translations.saveRules = saveRules;
|
|
308
318
|
async function clearLocalCache(collectionId) {
|
|
309
319
|
await clearCachedTranslations(collectionId);
|
|
310
320
|
}
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.32 | Generated: 2026-11-20T14:23:37.441Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -12079,6 +12079,7 @@ interface TranslationListParams {
|
|
|
12079
12079
|
contextKey?: string
|
|
12080
12080
|
q?: string
|
|
12081
12081
|
isOverride?: boolean
|
|
12082
|
+
termIssues?: boolean
|
|
12082
12083
|
limit?: number
|
|
12083
12084
|
offset?: number
|
|
12084
12085
|
}
|
|
@@ -12104,6 +12105,28 @@ interface TranslationUpdateRequest {
|
|
|
12104
12105
|
}
|
|
12105
12106
|
```
|
|
12106
12107
|
|
|
12108
|
+
**TranslationTerm** (interface)
|
|
12109
|
+
```typescript
|
|
12110
|
+
interface TranslationTerm {
|
|
12111
|
+
source: string
|
|
12112
|
+
keep?: boolean
|
|
12113
|
+
translations?: Record<string, string>
|
|
12114
|
+
note?: string
|
|
12115
|
+
}
|
|
12116
|
+
```
|
|
12117
|
+
|
|
12118
|
+
**TranslationRules** (interface)
|
|
12119
|
+
```typescript
|
|
12120
|
+
interface TranslationRules {
|
|
12121
|
+
guidance: string
|
|
12122
|
+
languages: Record<string, { guidance: string }>
|
|
12123
|
+
terms: TranslationTerm[]
|
|
12124
|
+
version?: string | null
|
|
12125
|
+
updatedAt?: string | null
|
|
12126
|
+
limits?: { guidance: number; languageGuidance: number; terms: number; term: number; note: number }
|
|
12127
|
+
}
|
|
12128
|
+
```
|
|
12129
|
+
|
|
12107
12130
|
**TranslationLookupMode** = `'cache-fill' | 'cache-only'`
|
|
12108
12131
|
|
|
12109
12132
|
**TranslationContentType** = `'text/plain' | 'text/html' | 'text/x-liquid' | (string & {})`
|
|
@@ -15538,8 +15561,14 @@ Admin: where translated text appears for one language (context keys), with count
|
|
|
15538
15561
|
**reset**(collectionId: string, translationId: string) → `Promise<TranslationRecord>`
|
|
15539
15562
|
Admin: undo a person's edit with a fresh machine translation.
|
|
15540
15563
|
|
|
15564
|
+
**rules**(collectionId: string) → `Promise<TranslationRules>`
|
|
15565
|
+
Admin: the site's translation rules (brief, notes per language, required terms).
|
|
15566
|
+
|
|
15567
|
+
**saveRules**(collectionId: string, body: Pick<TranslationRules, 'guidance' | 'languages' | 'terms'>) → `Promise<TranslationRules>`
|
|
15568
|
+
Admin: replace the site's translation rules. They apply to new translations from now on.
|
|
15569
|
+
|
|
15541
15570
|
**clearLocalCache**(collectionId?: string) → `Promise<void>`
|
|
15542
|
-
Admin:
|
|
15571
|
+
Admin: replace the site's translation rules. They apply to new translations from now on.
|
|
15543
15572
|
|
|
15544
15573
|
### tts
|
|
15545
15574
|
|
|
@@ -357,6 +357,30 @@ translation or puts a machine one back. When it has changed, that collection's s
|
|
|
357
357
|
dropped and fetched again (from the server's store, no AI). A slow or failed answer never holds the
|
|
358
358
|
page for more than 1.5 s, and the saved copies are used as before.
|
|
359
359
|
|
|
360
|
+
### Translation rules (a site's own terminology)
|
|
361
|
+
|
|
362
|
+
A site can give the AI a brief, notes per language and a list of required terms, for example a
|
|
363
|
+
pharmaceutical company whose leaflets must use regulatory wording. They apply to every new machine
|
|
364
|
+
translation for that collection; existing translations are not changed.
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
await translations.saveRules(collectionId, {
|
|
368
|
+
guidance: 'Patient information for prescription medicines. Formal register.',
|
|
369
|
+
languages: { de: { guidance: 'Address the reader with Sie.' } },
|
|
370
|
+
terms: [
|
|
371
|
+
{ source: 'tablet', translations: { de: 'Tablette', 'zh-Hans': '片剂' } },
|
|
372
|
+
{ source: 'Lumora', keep: true, note: 'brand name' }, // never translated
|
|
373
|
+
],
|
|
374
|
+
})
|
|
375
|
+
await translations.rules(collectionId) // what is saved, with its version
|
|
376
|
+
await translations.list(collectionId, { targetLanguage: 'de', termIssues: true }) // translations missing a required term
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Only the terms a text mentions are sent with it. After translating, each result is checked: if the
|
|
380
|
+
source mentions a term and the translation doesn't contain the required wording (any case, endings
|
|
381
|
+
allowed), its `metadata.termIssues` lists the term and `summary()` counts it under `issues`. A person's
|
|
382
|
+
edit is checked the same way. Each machine translation records `metadata.rulesVersion`.
|
|
383
|
+
|
|
360
384
|
## Recommended Usage Pattern
|
|
361
385
|
|
|
362
386
|
For front-end rendering:
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export type { VariantResponse, VariantCreateRequest, VariantUpdateRequest, } fro
|
|
|
35
35
|
export type { BroadcastSendRequest } from "./types/broadcasts.js";
|
|
36
36
|
export type { AppConfigOptions } from "./api/appConfiguration.js";
|
|
37
37
|
export type { AdditionalGtin, ISODateString, JsonPrimitive, JsonValue, ProductCreateRequest, ProductClaimCreateInput, ProductClaimCreateRequestBody, ProductClaimLookupInput, ProductFacetMap, ProductFacetValue, ProductImageUrlInput, ProductKey, ProductQueryRequest, ProductQueryResponse, ProductUpdateRequest, Product, ProductWriteInput, PublicProduct, } from "./types/product.js";
|
|
38
|
-
export type { TranslationLookupMode, TranslationContentType, TranslationQuality, TranslationItemStatus, TranslationContextValue, TranslationContext, TranslationLookupRequestBase, TranslationLookupSingleRequest, TranslationLookupBatchRequest, TranslationLookupRequest, TranslationLookupItem, TranslationLookupResponse, ResolvedTranslationItem, ResolvedTranslationResponse, TranslationHashOptions, TranslationResolveOptions, TranslationRecord, TranslationListParams, TranslationListResponse, TranslationUpdateRequest, } from "./types/translations.js";
|
|
38
|
+
export type { TranslationLookupMode, TranslationContentType, TranslationQuality, TranslationItemStatus, TranslationContextValue, TranslationContext, TranslationLookupRequestBase, TranslationLookupSingleRequest, TranslationLookupBatchRequest, TranslationLookupRequest, TranslationLookupItem, TranslationLookupResponse, ResolvedTranslationItem, ResolvedTranslationResponse, TranslationHashOptions, TranslationResolveOptions, TranslationRecord, TranslationListParams, TranslationListResponse, TranslationUpdateRequest, TranslationRules, TranslationTerm, } from "./types/translations.js";
|
|
39
39
|
export type { TranslationActivity } from "./translationActivity.js";
|
|
40
40
|
export type { FacetBucket, FacetDefinition, FacetDefinitionWriteInput, FacetGetParams, FacetListParams, FacetListResponse, FacetNamespaceListResponse, FacetQueryRequest, FacetQueryResponse, FacetValue, FacetValueDefinition, FacetValueGetParams, FacetValueListParams, FacetValueListResponse, FacetValueResponse, FacetValueWriteInput, PublicFacetListParams, } from "./types/facets.js";
|
|
41
41
|
export type { Collection, CollectionResponse, CollectionCreateRequest, CollectionUpdateRequest, DomainTarget, HubAvailabilityResponse, } from "./types/collection.js";
|
package/dist/openapi.yaml
CHANGED
|
@@ -9380,6 +9380,11 @@ paths:
|
|
|
9380
9380
|
required: false
|
|
9381
9381
|
schema:
|
|
9382
9382
|
type: boolean
|
|
9383
|
+
- name: termIssues
|
|
9384
|
+
in: query
|
|
9385
|
+
required: false
|
|
9386
|
+
schema:
|
|
9387
|
+
type: boolean
|
|
9383
9388
|
- name: limit
|
|
9384
9389
|
in: query
|
|
9385
9390
|
required: false
|
|
@@ -9403,6 +9408,65 @@ paths:
|
|
|
9403
9408
|
description: Unauthorized
|
|
9404
9409
|
404:
|
|
9405
9410
|
description: Not found
|
|
9411
|
+
/admin/collection/{collectionId}/translations/rules:
|
|
9412
|
+
get:
|
|
9413
|
+
tags:
|
|
9414
|
+
- translations
|
|
9415
|
+
summary: "Admin: the site's translation rules (brief, notes per language, required terms)."
|
|
9416
|
+
operationId: translations_rules
|
|
9417
|
+
security:
|
|
9418
|
+
- bearerAuth: []
|
|
9419
|
+
parameters:
|
|
9420
|
+
- name: collectionId
|
|
9421
|
+
in: path
|
|
9422
|
+
required: true
|
|
9423
|
+
schema:
|
|
9424
|
+
type: string
|
|
9425
|
+
responses:
|
|
9426
|
+
200:
|
|
9427
|
+
description: Success
|
|
9428
|
+
content:
|
|
9429
|
+
application/json:
|
|
9430
|
+
schema:
|
|
9431
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9432
|
+
400:
|
|
9433
|
+
description: Bad request
|
|
9434
|
+
401:
|
|
9435
|
+
description: Unauthorized
|
|
9436
|
+
404:
|
|
9437
|
+
description: Not found
|
|
9438
|
+
put:
|
|
9439
|
+
tags:
|
|
9440
|
+
- translations
|
|
9441
|
+
summary: "Admin: replace the site's translation rules."
|
|
9442
|
+
operationId: translations_saveRules
|
|
9443
|
+
security:
|
|
9444
|
+
- bearerAuth: []
|
|
9445
|
+
parameters:
|
|
9446
|
+
- name: collectionId
|
|
9447
|
+
in: path
|
|
9448
|
+
required: true
|
|
9449
|
+
schema:
|
|
9450
|
+
type: string
|
|
9451
|
+
responses:
|
|
9452
|
+
200:
|
|
9453
|
+
description: Success
|
|
9454
|
+
content:
|
|
9455
|
+
application/json:
|
|
9456
|
+
schema:
|
|
9457
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9458
|
+
400:
|
|
9459
|
+
description: Bad request
|
|
9460
|
+
401:
|
|
9461
|
+
description: Unauthorized
|
|
9462
|
+
404:
|
|
9463
|
+
description: Not found
|
|
9464
|
+
requestBody:
|
|
9465
|
+
required: true
|
|
9466
|
+
content:
|
|
9467
|
+
application/json:
|
|
9468
|
+
schema:
|
|
9469
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9406
9470
|
/admin/collection/{collectionId}/translations/{translationId}:
|
|
9407
9471
|
get:
|
|
9408
9472
|
tags:
|
|
@@ -37145,6 +37209,8 @@ components:
|
|
|
37145
37209
|
type: string
|
|
37146
37210
|
isOverride:
|
|
37147
37211
|
type: boolean
|
|
37212
|
+
termIssues:
|
|
37213
|
+
type: boolean
|
|
37148
37214
|
limit:
|
|
37149
37215
|
type: number
|
|
37150
37216
|
offset:
|
|
@@ -37176,6 +37242,46 @@ components:
|
|
|
37176
37242
|
metadata:
|
|
37177
37243
|
type: object
|
|
37178
37244
|
additionalProperties: true
|
|
37245
|
+
TranslationTerm:
|
|
37246
|
+
type: object
|
|
37247
|
+
properties:
|
|
37248
|
+
source:
|
|
37249
|
+
type: string
|
|
37250
|
+
keep:
|
|
37251
|
+
type: boolean
|
|
37252
|
+
translations:
|
|
37253
|
+
type: object
|
|
37254
|
+
additionalProperties:
|
|
37255
|
+
type: string
|
|
37256
|
+
note:
|
|
37257
|
+
type: string
|
|
37258
|
+
required:
|
|
37259
|
+
- source
|
|
37260
|
+
TranslationRules:
|
|
37261
|
+
type: object
|
|
37262
|
+
properties:
|
|
37263
|
+
guidance:
|
|
37264
|
+
type: string
|
|
37265
|
+
languages:
|
|
37266
|
+
type: object
|
|
37267
|
+
additionalProperties:
|
|
37268
|
+
type: object
|
|
37269
|
+
additionalProperties: true
|
|
37270
|
+
terms:
|
|
37271
|
+
type: array
|
|
37272
|
+
items:
|
|
37273
|
+
$ref: "#/components/schemas/TranslationTerm"
|
|
37274
|
+
version:
|
|
37275
|
+
type: string
|
|
37276
|
+
updatedAt:
|
|
37277
|
+
type: string
|
|
37278
|
+
limits:
|
|
37279
|
+
type: object
|
|
37280
|
+
additionalProperties: true
|
|
37281
|
+
required:
|
|
37282
|
+
- guidance
|
|
37283
|
+
- languages
|
|
37284
|
+
- terms
|
|
37179
37285
|
TranslationLookupMode:
|
|
37180
37286
|
type: string
|
|
37181
37287
|
enum:
|
|
@@ -90,6 +90,8 @@ export interface TranslationListParams {
|
|
|
90
90
|
contextKey?: string;
|
|
91
91
|
q?: string;
|
|
92
92
|
isOverride?: boolean;
|
|
93
|
+
/** Only translations that don't use the site's required wording (see TranslationRules). */
|
|
94
|
+
termIssues?: boolean;
|
|
93
95
|
limit?: number;
|
|
94
96
|
offset?: number;
|
|
95
97
|
}
|
|
@@ -105,3 +107,34 @@ export interface TranslationUpdateRequest {
|
|
|
105
107
|
quality?: TranslationQuality;
|
|
106
108
|
metadata?: Record<string, any>;
|
|
107
109
|
}
|
|
110
|
+
/** One required term: the English wording and what each language must use, or kept as written. */
|
|
111
|
+
export interface TranslationTerm {
|
|
112
|
+
source: string;
|
|
113
|
+
/** Keep exactly as written in every language (brand names, drug names, units). */
|
|
114
|
+
keep?: boolean;
|
|
115
|
+
/** Language code -> required wording. */
|
|
116
|
+
translations?: Record<string, string>;
|
|
117
|
+
note?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A site's own rules for its machine translations: a brief for the whole site, notes per language, and
|
|
121
|
+
* required terms. Used for every new translation; translations missing a required term are flagged
|
|
122
|
+
* (record metadata.termIssues / termIssueCount).
|
|
123
|
+
*/
|
|
124
|
+
export interface TranslationRules {
|
|
125
|
+
guidance: string;
|
|
126
|
+
languages: Record<string, {
|
|
127
|
+
guidance: string;
|
|
128
|
+
}>;
|
|
129
|
+
terms: TranslationTerm[];
|
|
130
|
+
/** Fingerprint of these rules; each machine translation stores the one it was made under (metadata.rulesVersion). */
|
|
131
|
+
version?: string | null;
|
|
132
|
+
updatedAt?: string | null;
|
|
133
|
+
limits?: {
|
|
134
|
+
guidance: number;
|
|
135
|
+
languageGuidance: number;
|
|
136
|
+
terms: number;
|
|
137
|
+
term: number;
|
|
138
|
+
note: number;
|
|
139
|
+
};
|
|
140
|
+
}
|
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.32 | Generated: 2026-11-20T14:23:37.441Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -12079,6 +12079,7 @@ interface TranslationListParams {
|
|
|
12079
12079
|
contextKey?: string
|
|
12080
12080
|
q?: string
|
|
12081
12081
|
isOverride?: boolean
|
|
12082
|
+
termIssues?: boolean
|
|
12082
12083
|
limit?: number
|
|
12083
12084
|
offset?: number
|
|
12084
12085
|
}
|
|
@@ -12104,6 +12105,28 @@ interface TranslationUpdateRequest {
|
|
|
12104
12105
|
}
|
|
12105
12106
|
```
|
|
12106
12107
|
|
|
12108
|
+
**TranslationTerm** (interface)
|
|
12109
|
+
```typescript
|
|
12110
|
+
interface TranslationTerm {
|
|
12111
|
+
source: string
|
|
12112
|
+
keep?: boolean
|
|
12113
|
+
translations?: Record<string, string>
|
|
12114
|
+
note?: string
|
|
12115
|
+
}
|
|
12116
|
+
```
|
|
12117
|
+
|
|
12118
|
+
**TranslationRules** (interface)
|
|
12119
|
+
```typescript
|
|
12120
|
+
interface TranslationRules {
|
|
12121
|
+
guidance: string
|
|
12122
|
+
languages: Record<string, { guidance: string }>
|
|
12123
|
+
terms: TranslationTerm[]
|
|
12124
|
+
version?: string | null
|
|
12125
|
+
updatedAt?: string | null
|
|
12126
|
+
limits?: { guidance: number; languageGuidance: number; terms: number; term: number; note: number }
|
|
12127
|
+
}
|
|
12128
|
+
```
|
|
12129
|
+
|
|
12107
12130
|
**TranslationLookupMode** = `'cache-fill' | 'cache-only'`
|
|
12108
12131
|
|
|
12109
12132
|
**TranslationContentType** = `'text/plain' | 'text/html' | 'text/x-liquid' | (string & {})`
|
|
@@ -15538,8 +15561,14 @@ Admin: where translated text appears for one language (context keys), with count
|
|
|
15538
15561
|
**reset**(collectionId: string, translationId: string) → `Promise<TranslationRecord>`
|
|
15539
15562
|
Admin: undo a person's edit with a fresh machine translation.
|
|
15540
15563
|
|
|
15564
|
+
**rules**(collectionId: string) → `Promise<TranslationRules>`
|
|
15565
|
+
Admin: the site's translation rules (brief, notes per language, required terms).
|
|
15566
|
+
|
|
15567
|
+
**saveRules**(collectionId: string, body: Pick<TranslationRules, 'guidance' | 'languages' | 'terms'>) → `Promise<TranslationRules>`
|
|
15568
|
+
Admin: replace the site's translation rules. They apply to new translations from now on.
|
|
15569
|
+
|
|
15541
15570
|
**clearLocalCache**(collectionId?: string) → `Promise<void>`
|
|
15542
|
-
Admin:
|
|
15571
|
+
Admin: replace the site's translation rules. They apply to new translations from now on.
|
|
15543
15572
|
|
|
15544
15573
|
### tts
|
|
15545
15574
|
|
package/docs/translations.md
CHANGED
|
@@ -357,6 +357,30 @@ translation or puts a machine one back. When it has changed, that collection's s
|
|
|
357
357
|
dropped and fetched again (from the server's store, no AI). A slow or failed answer never holds the
|
|
358
358
|
page for more than 1.5 s, and the saved copies are used as before.
|
|
359
359
|
|
|
360
|
+
### Translation rules (a site's own terminology)
|
|
361
|
+
|
|
362
|
+
A site can give the AI a brief, notes per language and a list of required terms, for example a
|
|
363
|
+
pharmaceutical company whose leaflets must use regulatory wording. They apply to every new machine
|
|
364
|
+
translation for that collection; existing translations are not changed.
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
await translations.saveRules(collectionId, {
|
|
368
|
+
guidance: 'Patient information for prescription medicines. Formal register.',
|
|
369
|
+
languages: { de: { guidance: 'Address the reader with Sie.' } },
|
|
370
|
+
terms: [
|
|
371
|
+
{ source: 'tablet', translations: { de: 'Tablette', 'zh-Hans': '片剂' } },
|
|
372
|
+
{ source: 'Lumora', keep: true, note: 'brand name' }, // never translated
|
|
373
|
+
],
|
|
374
|
+
})
|
|
375
|
+
await translations.rules(collectionId) // what is saved, with its version
|
|
376
|
+
await translations.list(collectionId, { targetLanguage: 'de', termIssues: true }) // translations missing a required term
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Only the terms a text mentions are sent with it. After translating, each result is checked: if the
|
|
380
|
+
source mentions a term and the translation doesn't contain the required wording (any case, endings
|
|
381
|
+
allowed), its `metadata.termIssues` lists the term and `summary()` counts it under `issues`. A person's
|
|
382
|
+
edit is checked the same way. Each machine translation records `metadata.rulesVersion`.
|
|
383
|
+
|
|
360
384
|
## Recommended Usage Pattern
|
|
361
385
|
|
|
362
386
|
For front-end rendering:
|
package/openapi.yaml
CHANGED
|
@@ -9380,6 +9380,11 @@ paths:
|
|
|
9380
9380
|
required: false
|
|
9381
9381
|
schema:
|
|
9382
9382
|
type: boolean
|
|
9383
|
+
- name: termIssues
|
|
9384
|
+
in: query
|
|
9385
|
+
required: false
|
|
9386
|
+
schema:
|
|
9387
|
+
type: boolean
|
|
9383
9388
|
- name: limit
|
|
9384
9389
|
in: query
|
|
9385
9390
|
required: false
|
|
@@ -9403,6 +9408,65 @@ paths:
|
|
|
9403
9408
|
description: Unauthorized
|
|
9404
9409
|
404:
|
|
9405
9410
|
description: Not found
|
|
9411
|
+
/admin/collection/{collectionId}/translations/rules:
|
|
9412
|
+
get:
|
|
9413
|
+
tags:
|
|
9414
|
+
- translations
|
|
9415
|
+
summary: "Admin: the site's translation rules (brief, notes per language, required terms)."
|
|
9416
|
+
operationId: translations_rules
|
|
9417
|
+
security:
|
|
9418
|
+
- bearerAuth: []
|
|
9419
|
+
parameters:
|
|
9420
|
+
- name: collectionId
|
|
9421
|
+
in: path
|
|
9422
|
+
required: true
|
|
9423
|
+
schema:
|
|
9424
|
+
type: string
|
|
9425
|
+
responses:
|
|
9426
|
+
200:
|
|
9427
|
+
description: Success
|
|
9428
|
+
content:
|
|
9429
|
+
application/json:
|
|
9430
|
+
schema:
|
|
9431
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9432
|
+
400:
|
|
9433
|
+
description: Bad request
|
|
9434
|
+
401:
|
|
9435
|
+
description: Unauthorized
|
|
9436
|
+
404:
|
|
9437
|
+
description: Not found
|
|
9438
|
+
put:
|
|
9439
|
+
tags:
|
|
9440
|
+
- translations
|
|
9441
|
+
summary: "Admin: replace the site's translation rules."
|
|
9442
|
+
operationId: translations_saveRules
|
|
9443
|
+
security:
|
|
9444
|
+
- bearerAuth: []
|
|
9445
|
+
parameters:
|
|
9446
|
+
- name: collectionId
|
|
9447
|
+
in: path
|
|
9448
|
+
required: true
|
|
9449
|
+
schema:
|
|
9450
|
+
type: string
|
|
9451
|
+
responses:
|
|
9452
|
+
200:
|
|
9453
|
+
description: Success
|
|
9454
|
+
content:
|
|
9455
|
+
application/json:
|
|
9456
|
+
schema:
|
|
9457
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9458
|
+
400:
|
|
9459
|
+
description: Bad request
|
|
9460
|
+
401:
|
|
9461
|
+
description: Unauthorized
|
|
9462
|
+
404:
|
|
9463
|
+
description: Not found
|
|
9464
|
+
requestBody:
|
|
9465
|
+
required: true
|
|
9466
|
+
content:
|
|
9467
|
+
application/json:
|
|
9468
|
+
schema:
|
|
9469
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9406
9470
|
/admin/collection/{collectionId}/translations/{translationId}:
|
|
9407
9471
|
get:
|
|
9408
9472
|
tags:
|
|
@@ -37145,6 +37209,8 @@ components:
|
|
|
37145
37209
|
type: string
|
|
37146
37210
|
isOverride:
|
|
37147
37211
|
type: boolean
|
|
37212
|
+
termIssues:
|
|
37213
|
+
type: boolean
|
|
37148
37214
|
limit:
|
|
37149
37215
|
type: number
|
|
37150
37216
|
offset:
|
|
@@ -37176,6 +37242,46 @@ components:
|
|
|
37176
37242
|
metadata:
|
|
37177
37243
|
type: object
|
|
37178
37244
|
additionalProperties: true
|
|
37245
|
+
TranslationTerm:
|
|
37246
|
+
type: object
|
|
37247
|
+
properties:
|
|
37248
|
+
source:
|
|
37249
|
+
type: string
|
|
37250
|
+
keep:
|
|
37251
|
+
type: boolean
|
|
37252
|
+
translations:
|
|
37253
|
+
type: object
|
|
37254
|
+
additionalProperties:
|
|
37255
|
+
type: string
|
|
37256
|
+
note:
|
|
37257
|
+
type: string
|
|
37258
|
+
required:
|
|
37259
|
+
- source
|
|
37260
|
+
TranslationRules:
|
|
37261
|
+
type: object
|
|
37262
|
+
properties:
|
|
37263
|
+
guidance:
|
|
37264
|
+
type: string
|
|
37265
|
+
languages:
|
|
37266
|
+
type: object
|
|
37267
|
+
additionalProperties:
|
|
37268
|
+
type: object
|
|
37269
|
+
additionalProperties: true
|
|
37270
|
+
terms:
|
|
37271
|
+
type: array
|
|
37272
|
+
items:
|
|
37273
|
+
$ref: "#/components/schemas/TranslationTerm"
|
|
37274
|
+
version:
|
|
37275
|
+
type: string
|
|
37276
|
+
updatedAt:
|
|
37277
|
+
type: string
|
|
37278
|
+
limits:
|
|
37279
|
+
type: object
|
|
37280
|
+
additionalProperties: true
|
|
37281
|
+
required:
|
|
37282
|
+
- guidance
|
|
37283
|
+
- languages
|
|
37284
|
+
- terms
|
|
37179
37285
|
TranslationLookupMode:
|
|
37180
37286
|
type: string
|
|
37181
37287
|
enum:
|