sanity-plugin-studio-smartling 1.0.11 → 1.2.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.
- package/README.md +5 -5
- package/dist/helpers.d.ts +5 -0
- package/dist/index.d.ts +4 -4
- package/dist/sanity-plugin-studio-smartling.cjs.development.js +364 -135
- package/dist/sanity-plugin-studio-smartling.cjs.development.js.map +1 -1
- package/dist/sanity-plugin-studio-smartling.cjs.production.min.js +1 -1
- package/dist/sanity-plugin-studio-smartling.cjs.production.min.js.map +1 -1
- package/dist/sanity-plugin-studio-smartling.esm.js +362 -135
- package/dist/sanity-plugin-studio-smartling.esm.js.map +1 -1
- package/package.json +4 -4
- package/src/3rdparty-typings/sanity-parts.d.ts +1 -0
- package/src/adapter/createTask.ts +43 -56
- package/src/adapter/getTranslationTask.ts +1 -1
- package/src/helpers.ts +116 -0
- package/src/index.ts +24 -28
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This plugin comes with (and exposes to the developer) the following items:
|
|
|
22
22
|
- A `Serializer` that transforms your content into HTML (we found this was the most efficient way to maintain your document structure, no matter how deeply nested, while remaining readable to translators in Smartling). The `Serializer` takes in optional arguments: `stopTypes`, which prevents certain types from being sent to your translatiors and `customSerializers`, which are rules you can use to have full control over how individual fields on your document get serialized.
|
|
23
23
|
- A `Deserializer` that deserializes translated text back to Sanity's format.
|
|
24
24
|
- A `Patcher` which determines how your content gets patched back into its destination document or field.
|
|
25
|
-
- A `
|
|
25
|
+
- A `TranslationsTab`, a React element that allows a non-technical user to import, export, and monitor Smartling progress.
|
|
26
26
|
|
|
27
27
|
To make life easier, we also include `defaultFieldLevelConfig` and `defaultDocumentLevelConfig`, which bundles all of the above up to get you up and running quickly.
|
|
28
28
|
|
|
@@ -88,7 +88,7 @@ secret: 'YOUR_TOKEN_SECRET_HERE',
|
|
|
88
88
|
```javascript
|
|
89
89
|
import S from '@sanity/desk-tool/structure-builder'
|
|
90
90
|
//...your other desk structure imports...
|
|
91
|
-
import {
|
|
91
|
+
import { TranslationsTab, defaultDocumentLevelConfig } from 'sanity-plugin-studio-smartling'
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
export const getDefaultDocumentNode = (props) => {
|
|
@@ -96,7 +96,7 @@ export const getDefaultDocumentNode = (props) => {
|
|
|
96
96
|
return S.document().views([
|
|
97
97
|
S.view.form(),
|
|
98
98
|
//...my other views -- for example, live preview, the i18n plugin, etc.,
|
|
99
|
-
S.view.component(
|
|
99
|
+
S.view.component(TranslationsTab).title('Smartling').options(
|
|
100
100
|
defaultDocumentLevelConfig
|
|
101
101
|
)
|
|
102
102
|
])
|
|
@@ -108,11 +108,11 @@ export const getDefaultDocumentNode = (props) => {
|
|
|
108
108
|
And that should do it!
|
|
109
109
|
|
|
110
110
|
## Studio experience
|
|
111
|
-
By adding the `
|
|
111
|
+
By adding the `TranslationsTab` to your desk structure, your users should now have an additional view. The boxes at the top of the tab can be used to send translations off to Smartling, and once those jobs are started, they should see progress bars monitoring the progress of the jobs. They can import a partial or complete job back.
|
|
112
112
|
|
|
113
113
|
## Overriding defaults
|
|
114
114
|
|
|
115
|
-
To personalize this configuration it's useful to know what arguments go into `
|
|
115
|
+
To personalize this configuration it's useful to know what arguments go into `TranslationsTab` as options (the `defaultConfigs` are just wrappers for these):
|
|
116
116
|
* `exportForTranslation`: a function that takes your document id and returns an object with `name`: the field you want to use identify your doc in Smartling (by default this is `_id` and `content`: a serialized HTML string of all the fields in your document to be translated.
|
|
117
117
|
* `importTranslation`: a function that takes in `id` (your document id) `localeId` (the locale of the imported language) and `document` the translated HTML from Smartling. It will deserialize your document back into an object that can be patched into your Sanity data, and then executes that patch.
|
|
118
118
|
* `Adapter`: An interface with methods to send things over to Smartling. You likely don't want to override this!
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SanityDocument } from '@sanity/types';
|
|
2
|
+
export declare const findLatestDraft: (documentId: string, ignoreI18n?: boolean) => any;
|
|
3
|
+
export declare const findDocumentAtRevision: (documentId: string, rev: string) => Promise<any>;
|
|
4
|
+
export declare const documentLevelPatch: (documentId: string, translatedFields: SanityDocument, localeId: string) => Promise<void>;
|
|
5
|
+
export declare const fieldLevelPatch: (documentId: string, translatedFields: SanityDocument, localeId: string) => Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { TranslationsTab } from 'sanity-translations-tab';
|
|
2
|
-
import { BaseDocumentDeserializer, BaseDocumentSerializer,
|
|
2
|
+
import { BaseDocumentDeserializer, BaseDocumentSerializer, BaseDocumentMerger, defaultStopTypes, customSerializers } from 'sanity-naive-html-serializer';
|
|
3
3
|
import { SmartlingAdapter } from './adapter';
|
|
4
4
|
declare const defaultDocumentLevelConfig: {
|
|
5
5
|
exportForTranslation: (id: string) => Promise<import("sanity-naive-html-serializer/dist/types").SerializedDocument>;
|
|
6
|
-
importTranslation: (id: string, localeId: string, document: string) =>
|
|
6
|
+
importTranslation: (id: string, localeId: string, document: string) => void;
|
|
7
7
|
adapter: import("sanity-translations-tab").Adapter;
|
|
8
8
|
};
|
|
9
9
|
declare const defaultFieldLevelConfig: {
|
|
10
10
|
exportForTranslation: (id: string) => Promise<import("sanity-naive-html-serializer/dist/types").SerializedDocument>;
|
|
11
|
-
importTranslation: (id: string, localeId: string, document: string) =>
|
|
11
|
+
importTranslation: (id: string, localeId: string, document: string) => void;
|
|
12
12
|
adapter: import("sanity-translations-tab").Adapter;
|
|
13
13
|
};
|
|
14
|
-
export { TranslationsTab, BaseDocumentDeserializer, BaseDocumentSerializer,
|
|
14
|
+
export { TranslationsTab, BaseDocumentDeserializer, BaseDocumentSerializer, BaseDocumentMerger, defaultStopTypes, customSerializers, SmartlingAdapter, defaultDocumentLevelConfig, defaultFieldLevelConfig, };
|