sanity-plugin-studio-smartling 2.0.6 → 3.0.0-beta-private
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/LICENSE +21 -0
- package/README.md +204 -74
- package/dist/index.d.ts +53 -11
- package/dist/index.esm.js +239 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +298 -7
- package/dist/index.js.map +1 -0
- package/package.json +76 -47
- package/sanity.json +8 -0
- package/src/adapter/createTask.ts +59 -59
- package/src/adapter/getLocales.ts +16 -9
- package/src/adapter/getTranslation.ts +20 -12
- package/src/adapter/getTranslationTask.ts +63 -23
- package/src/adapter/helpers.ts +30 -16
- package/src/adapter/index.ts +5 -5
- package/src/index.ts +9 -3
- package/src/types.d.ts +0 -0
- package/v2-incompatible.js +11 -0
- package/dist/adapter/createTask.d.ts +0 -12
- package/dist/adapter/getLocales.d.ts +0 -2
- package/dist/adapter/getTranslation.d.ts +0 -2
- package/dist/adapter/getTranslationTask.d.ts +0 -12
- package/dist/adapter/helpers.d.ts +0 -7
- package/dist/adapter/index.d.ts +0 -2
- package/dist/sanity-plugin-studio-smartling.cjs.development.js +0 -1316
- package/dist/sanity-plugin-studio-smartling.cjs.development.js.map +0 -1
- package/dist/sanity-plugin-studio-smartling.cjs.production.min.js +0 -2
- package/dist/sanity-plugin-studio-smartling.cjs.production.min.js.map +0 -1
- package/dist/sanity-plugin-studio-smartling.esm.js +0 -1259
- package/dist/sanity-plugin-studio-smartling.esm.js.map +0 -1
- package/src/3rdparty-typings/sanity-parts.d.ts +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Sanity.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,146 +1,276 @@
|
|
|
1
|
+
> This is a **Sanity Studio v3** plugin.
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install sanity-plugin-studio-smartling
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
1
10
|
|
|
2
11
|
# Studio Plugin for Sanity & Smartling
|
|
3
12
|
|
|
4
13
|

|
|
5
14
|
|
|
6
|
-
|
|
7
15
|
We're proud to be partnered with Smartling and their [official connector](https://help.smartling.com/hc/en-us/articles/1260803085050-Sanity-Connector-Overview-) makes it quick and easy to get your studio content into your Smartling project.
|
|
8
16
|
|
|
9
17
|
This is a separate plugin, and differs in that it provides editors a visual progress bar for ongoing translations and a way to import translations back into your content at either the document or field level. Feel free to try it out and see which solution works for you!
|
|
10
18
|
|
|
11
19
|
# Table of Contents
|
|
12
|
-
|
|
13
|
-
- [Assumptions](#assumptions)
|
|
20
|
+
|
|
14
21
|
- [Quickstart](#quickstart)
|
|
22
|
+
- [Assumptions](#assumptions)
|
|
15
23
|
- [Studio experience](#studio-experience)
|
|
16
24
|
- [Overriding defaults](#overriding-defaults)
|
|
17
|
-
- [
|
|
25
|
+
- [License](#license)
|
|
26
|
+
- [Develop and test](#develop-and-test)
|
|
27
|
+
|
|
28
|
+
## Quickstart
|
|
18
29
|
|
|
19
|
-
|
|
30
|
+
1. In your studio folder, run:
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
- A `TranslationsTab`, a React element that allows a non-technical user to import, export, and monitor Smartling progress.
|
|
32
|
+
```sh
|
|
33
|
+
npm install sanity-plugin-studio-smartling
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
2. Because of Smartling CORS restrictions, you will need to set up a proxy endpoint to funnel requests to Smartling. We've provided a tiny Next.js app you can set up [here](https://github.com/sanity-io/example-sanity-smartling-proxy). If that's not useful, the important thing to pay attention to is that this endpoint handles requests with an `X-URL` header that contains the Smartling URL configured by the plugin, and can parse a data file to an HTML string and send it back to the adapter.
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
3. Ensure the plugin has access to your Smartling project token. You'll want to create a document that includes your project name, organization name, and a token with appropriate access.
|
|
39
|
+
|
|
40
|
+
[Please refer to the Smartling documentation on creating a token if you don't have one already.](https://help.smartling.com/hc/en-us/articles/115004187694-API-Tokens)
|
|
41
|
+
|
|
42
|
+
In your Studio folder, create a file called `populateSmartlingSecrets.js` with the following contents:
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
// ./populateSmartlingSecrets.js
|
|
46
|
+
// Do not commit this file to your repository
|
|
47
|
+
|
|
48
|
+
import {getCliClient} from 'sanity/cli'
|
|
49
|
+
|
|
50
|
+
const client = getCliClient({apiVersion: '2023-02-15'})
|
|
51
|
+
|
|
52
|
+
client.createOrReplace({
|
|
53
|
+
// The `.` in this _id will ensure the document is private
|
|
54
|
+
// even in a public dataset!
|
|
55
|
+
_id: 'translationService.secrets',
|
|
56
|
+
_type: 'smartlingSettings',
|
|
57
|
+
//replace these with your values
|
|
58
|
+
organization: 'YOUR_SMARTLING_ORGANIZATION_HERE',
|
|
59
|
+
project: 'YOUR_SMARTLING_PROJECT_HERE',
|
|
60
|
+
secret: '{"userIdentifier":"xxxxxx","userSecret":"xxxx"}', //in this format from Smartling when you press the button "copy token" on creation
|
|
61
|
+
proxy: 'my-proxy-endpoint.com/api/proxy' //the endpoint you set up in step 2
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
On the command line, run the file:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
npx sanity exec populateSmartlingSecrets.js --with-user-token
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Verify that the document was created using the Vision Tool in the Studio and query `*[_id == 'translationService.secrets']`. Note: If you have multiple datasets, you'll have to do this across all of them.
|
|
72
|
+
|
|
73
|
+
If the document was found in your dataset(s), delete `populateSmartlingSecrets.js`.
|
|
74
|
+
|
|
75
|
+
If you have concerns about this being exposed to authenticated users of your studio, you can control access to this path with [role-based access control](https://www.sanity.io/docs/access-control).
|
|
76
|
+
|
|
77
|
+
4. Get the Smartling tab on your desired document type, using whatever pattern you like. You'll use the [desk structure](https://www.sanity.io/docs/structure-builder-introduction) for this. The options for translation will be nested under this desired document type's views. Here's an example:
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
import {DefaultDocumentNodeResolver} from 'sanity/desk'
|
|
81
|
+
//...your other desk structure imports...
|
|
82
|
+
import {TranslationsTab, defaultDocumentLevelConfig} from 'sanity-plugin-studio-smartling'
|
|
83
|
+
|
|
84
|
+
export const getDefaultDocumentNode: DefaultDocumentNodeResolver = (S, {schemaType}) => {
|
|
85
|
+
if (schemaType === 'myTranslatableDocumentType') {
|
|
86
|
+
return S.document().views([
|
|
87
|
+
S.view.form(),
|
|
88
|
+
//...my other views -- for example, live preview, document pane, etc.,
|
|
89
|
+
S.view.component(TranslationsTab).title('Smartling').options(defaultDocumentLevelConfig)
|
|
90
|
+
])
|
|
91
|
+
}
|
|
92
|
+
return S.document()
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
And that should do it! Go into your studio, click around, and check the document in Smartling (it should be under its Sanity `_id` by default, but you can override this). Once it's translated, check the import by clicking the `Import` button on your Smartling tab!
|
|
29
97
|
|
|
30
98
|
## Assumptions
|
|
31
|
-
To use the default config mentioned above, we assume that you are following the conventions we outline in [our documentation on localization](https://www.sanity.io/docs/localization).
|
|
32
99
|
|
|
100
|
+
To use the default config mentioned above, we assume that you are following the conventions we outline in [our documentation on localization](https://www.sanity.io/docs/localization).
|
|
33
101
|
|
|
34
102
|
### Field-level translations
|
|
103
|
+
|
|
35
104
|
If you are using field-level translation, we assume any fields you want translated exist in the multi-locale object form we recommend.
|
|
36
105
|
For example, on a document you don't want to be translated, you may have a "title" field that's a flat string: `title: 'My title is here.'` For a field you want to include many languages for, your title may look like
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
106
|
+
`
|
|
107
|
+
{
|
|
108
|
+
title: {
|
|
109
|
+
en: 'My title is here.',
|
|
110
|
+
es: 'Mi título está aquí.',
|
|
111
|
+
etc...
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
`
|
|
115
|
+
_Important_: Smartling's locale representation includes hyphens, like `fr-FR`. These aren't valid as Sanity field names, so ensure that on your fields you change the hyphens to underscores (like `fr_FR`).
|
|
46
116
|
|
|
47
117
|
### Document level translations
|
|
118
|
+
|
|
48
119
|
Since we often find users want to use the [Document internationalization plugin](https://www.sanity.io/plugins/document-internationalization) if they're using document-level translations, we assume that any documents you want in different languages will follow the pattern `{id-of-base-language-document}__i18n_{locale}`
|
|
49
120
|
|
|
50
121
|
### Final note
|
|
122
|
+
|
|
51
123
|
It's okay if your data doesn't follow these patterns and you don't want to change them! You will simply have to override how the plugin gets and patches back information from your documents. Please see [Overriding defaults](#overriding-defaults).
|
|
52
124
|
|
|
53
125
|
## Quickstart
|
|
54
|
-
1. Install this plugin with `npm install sanity-plugin-studio-smartling`
|
|
55
|
-
|
|
56
|
-
2. Because of Smartling CORS restrictions, you will need to set up a proxy endpoint to funnel requests to Smartling. We've provided a tiny Next.js app you can set up [here](https://github.com/sanity-io/example-sanity-smartling-proxy). If that's not useful, the important thing to pay attention to is that this endpoint handles requests with an `X-URL` header that contains the Smartling URL configured by the plugin, and can parse a data file to an HTML string and send it back to the adapter.
|
|
57
126
|
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
#any other environment variables...
|
|
61
|
-
SANITY_STUDIO_SMARTLING_PROXY=http://your-proxy-url.com
|
|
62
|
-
```
|
|
127
|
+
1. Install this plugin with `npm install sanity-plugin-studio-smartling`
|
|
63
128
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
129
|
+
2. Ensure the plugin has access to your Smartling token secret. You'll want to create a document that includes your project name and a token secret with appropriate access. [Please refer to the Smartling documentation on creating a token if you don't have one already.](https://help.smartling.com/hc/en-us/articles/115004187694-API-Tokens-)
|
|
130
|
+
- In your studio, create a file called `populateSmartlingSecrets.js`.
|
|
131
|
+
- Place the following in the file and fill out the correct values.
|
|
67
132
|
|
|
68
133
|
```javascript
|
|
69
134
|
import sanityClient from 'part:@sanity/base/client'
|
|
70
135
|
|
|
71
|
-
const client = sanityClient.withConfig({
|
|
136
|
+
const client = sanityClient.withConfig({apiVersion: '2021-03-25'})
|
|
72
137
|
|
|
73
138
|
client.createOrReplace({
|
|
74
|
-
_id: 'translationService.secrets',
|
|
75
|
-
_type: 'smartlingSettings',
|
|
76
|
-
organization: 'YOUR_ORG_HERE',
|
|
77
|
-
project: 'YOUR_PROJECT_HERE',
|
|
78
|
-
secret: '{"userIdentifier":"xxxxxx","userSecret":"xxxx"}'
|
|
139
|
+
_id: 'translationService.secrets',
|
|
140
|
+
_type: 'smartlingSettings',
|
|
141
|
+
organization: 'YOUR_ORG_HERE',
|
|
142
|
+
project: 'YOUR_PROJECT_HERE',
|
|
143
|
+
secret: '{"userIdentifier":"xxxxxx","userSecret":"xxxx"}' //in this format from Smartling
|
|
79
144
|
})
|
|
80
145
|
```
|
|
81
146
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
147
|
+
- On the command line, run the file with `sanity exec populateSmartlingSecrets.js --with-user-token`.
|
|
148
|
+
Verify that everything went well by using Vision in the studio to query `*[_id == 'translationService.secrets']`. (NOTE: If you have multiple datasets, you'll have to do this across all of them, since it's a document!)
|
|
149
|
+
- If everything looks good, go ahead and delete `populateSmartlingSecrets.js` so you don't commit it.
|
|
150
|
+
Because the document's `_id` is on a path (`translationService`), it won't be exposed to the outside world, even in a public dataset. If you have concerns about this being exposed to authenticated users of your studio, you can control access to this path with [role-based access control](https://www.sanity.io/docs/access-control).
|
|
86
151
|
|
|
87
152
|
5. Now it's time to get the Smartling tab on your desired document type, using whatever pattern you like. You'll use the [desk structure](https://www.sanity.io/docs/structure-builder-introduction) for this. The options for translation will be nested under this desired document type's views. Here's an example:
|
|
88
153
|
|
|
89
154
|
```javascript
|
|
90
|
-
import
|
|
155
|
+
import {DefaultDocumentNodeResolver} from 'sanity/desk'
|
|
91
156
|
//...your other desk structure imports...
|
|
92
|
-
import {
|
|
93
|
-
|
|
157
|
+
import {TranslationsTab, defaultDocumentLevelConfig} from 'sanity-plugin-studio-smartling'
|
|
94
158
|
|
|
95
|
-
export const getDefaultDocumentNode = (
|
|
96
|
-
if (
|
|
159
|
+
export const getDefaultDocumentNode: DefaultDocumentNodeResolver = (S, {schemaType}) => {
|
|
160
|
+
if (schemaType === 'myTranslatableDocumentType') {
|
|
97
161
|
return S.document().views([
|
|
98
162
|
S.view.form(),
|
|
99
163
|
//...my other views -- for example, live preview, the i18n plugin, etc.,
|
|
100
|
-
S.view.component(TranslationsTab).title('Smartling').options(
|
|
101
|
-
defaultDocumentLevelConfig
|
|
102
|
-
)
|
|
164
|
+
S.view.component(TranslationsTab).title('Smartling').options(defaultDocumentLevelConfig)
|
|
103
165
|
])
|
|
104
166
|
}
|
|
105
|
-
return S.document()
|
|
106
|
-
}
|
|
167
|
+
return S.document()
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
And that should do it! Go into your studio, click around, and check the document in Smartling (it should be a job under its Sanity `_id`). Once it's translated, check the import by clicking the `Import` button on your Smartling tab!
|
|
172
|
+
|
|
173
|
+
## Assumptions
|
|
174
|
+
|
|
175
|
+
To use the default config mentioned above, we assume that you are following the conventions we outline in [our documentation on localization](https://www.sanity.io/docs/localization).
|
|
176
|
+
|
|
177
|
+
### Field-level translations
|
|
178
|
+
|
|
179
|
+
If you are using field-level translation, we assume any fields you want to be translated exist in the multi-locale object form we recommend.
|
|
180
|
+
|
|
181
|
+
For example, on a document you don't want to be translated, you may have a "title" field that's a flat string: `title: 'My title is here.'` For a field you want to include many languages for your title may look like:
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
{
|
|
185
|
+
//...other document fields,
|
|
186
|
+
title: {
|
|
187
|
+
en: 'My title is here.',
|
|
188
|
+
es: 'Mi título está aquí.',
|
|
189
|
+
etc...
|
|
190
|
+
}
|
|
191
|
+
}
|
|
107
192
|
```
|
|
108
193
|
|
|
109
|
-
|
|
194
|
+
### Document level translations
|
|
195
|
+
|
|
196
|
+
Since we often find users want to use the [Document internationalization plugin](https://www.sanity.io/plugins/document-internationalization) if they're using document-level translations, we assume that any documents you want in different languages will follow the pattern `{id-of-base-language-document}__i18n_{locale}`
|
|
197
|
+
|
|
198
|
+
### Final note
|
|
199
|
+
|
|
200
|
+
It's okay if your data doesn't follow these patterns and you don't want to change them! You will simply have to override how the plugin gets and patches back information from your documents. Please see [Overriding defaults](#overriding-defaults).
|
|
110
201
|
|
|
111
202
|
## Studio experience
|
|
112
|
-
|
|
203
|
+
|
|
204
|
+
By adding the `TranslationsTab` to your desk structure, your users should now have an additional view on their document. 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. They can also re-send a document, which should update the existing job.
|
|
113
205
|
|
|
114
206
|
## Overriding defaults
|
|
115
207
|
|
|
116
208
|
To personalize this configuration it's useful to know what arguments go into `TranslationsTab` as options (the `defaultConfigs` are just wrappers for these):
|
|
117
|
-
* `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.
|
|
118
|
-
* `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.
|
|
119
|
-
* `Adapter`: An interface with methods to send things over to Smartling. You likely don't want to override this!
|
|
120
209
|
|
|
121
|
-
|
|
210
|
+
- `exportForTranslation`: a function that takes your document id and returns an object like:
|
|
122
211
|
|
|
123
|
-
|
|
212
|
+
```javascript
|
|
213
|
+
{
|
|
214
|
+
`name`: /*the field you want to use identify your doc in Smartling (by default this is `_id`) */
|
|
215
|
+
`content`: /* a serialized HTML string of all the fields in your document to be translated. */
|
|
216
|
+
}
|
|
217
|
+
```
|
|
124
218
|
|
|
125
|
-
|
|
219
|
+
- `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.
|
|
220
|
+
- `Adapter`: An interface with methods to send things over to Smartling. You likely don't want to override this!
|
|
126
221
|
|
|
127
|
-
|
|
222
|
+
There are several reasons to override these functions. Generally, developers will customize to ensure documents serialize and deserialize correctly. Since the serialization functions are used across all our translation plugins currently, you can find some frequently encountered scenarios at [their repository here](https://github.com/sanity-io/sanity-naive-html-serializer), along with code examples for customized configurations.
|
|
128
223
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
BaseDocumentSerializer.serializeDocument(id, 'serialization-level')
|
|
224
|
+
## Migrating to Sanity Studio v3
|
|
225
|
+
|
|
226
|
+
There is one major breaking change in this plugin's migration to Sanity Studio v3: the proxy was set in an environment variable, and now it should be part of the `secrets` document.
|
|
227
|
+
|
|
228
|
+
In v2, you would set the proxy in a `.env` file, like so:
|
|
229
|
+
|
|
230
|
+
```env
|
|
231
|
+
SANITY_STUDIO_SMARTLING_PROXY=https://my-proxy-endpoint.com/api/proxy
|
|
138
232
|
```
|
|
139
233
|
|
|
140
|
-
|
|
234
|
+
In v3, you should set the proxy in the `secrets` document. If you have an existing secrets document, you can patch it like so:
|
|
235
|
+
|
|
141
236
|
```javascript
|
|
142
|
-
|
|
237
|
+
// ./patchSmartlingSecrets.js
|
|
238
|
+
// Do not commit this file to your repository
|
|
239
|
+
|
|
240
|
+
import {getCliClient} from 'sanity/cli'
|
|
143
241
|
|
|
144
|
-
|
|
242
|
+
const client = getCliClient({apiVersion: '2023-02-15'})
|
|
243
|
+
|
|
244
|
+
client.patch('translationService.secrets').set({proxy: 'https://my-proxy.com/api/proxy'}).commit()
|
|
145
245
|
```
|
|
146
246
|
|
|
247
|
+
and run the script with `sanity exec patchSmartlingSecrets.js --with-user-token`.
|
|
248
|
+
|
|
249
|
+
Alternatively, you can re-run the `populateSmartlingSecrets` script in [Quickstart](#quickstart) to create a new secrets document with the proxy set.
|
|
250
|
+
|
|
251
|
+
We apologize for the inconvenience. Because of the new embeddability of the studio, developers may find that their v3 Studio is built and deployed in different ways, with access to different environments. Keeping this setting in `secrets` allows developers to set it in a way that works for their deployment and reduce complexity.
|
|
252
|
+
|
|
253
|
+
Otherwise, you should not have to do anything to migrate to Sanity Studio v3. If you are using the default configs, you should be able to upgrade without any changes. If you are using custom serialization, you may need to update how `BaseDocumentSerializer` receives your schema.
|
|
254
|
+
|
|
255
|
+
These are outlined in the serializer README [here](https://github.com/sanity-io/sanity-naive-html-serializer#v2-to-v3-changes).
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
[MIT](LICENSE) © Sanity.io
|
|
260
|
+
|
|
261
|
+
## Develop & test
|
|
262
|
+
|
|
263
|
+
This plugin is in early stages. We plan on improving some of the user-facing chrome, sorting out some quiet bugs, figuring out where things don't fail elegantly, etc. Please be a part of our development process!
|
|
264
|
+
|
|
265
|
+
This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
|
|
266
|
+
with default configuration for build & watch scripts.
|
|
267
|
+
|
|
268
|
+
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
269
|
+
on how to run this plugin with hotreload in the studio.
|
|
270
|
+
|
|
271
|
+
### Release new version
|
|
272
|
+
|
|
273
|
+
Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-transifex/actions/workflows/main.yml).
|
|
274
|
+
Make sure to select the main branch and check "Release new version".
|
|
275
|
+
|
|
276
|
+
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import {Adapter} from 'sanity-translations-tab'
|
|
2
|
+
import {BaseDocumentDeserializer} from 'sanity-translations-tab'
|
|
3
|
+
import {BaseDocumentMerger} from 'sanity-translations-tab'
|
|
4
|
+
import {BaseDocumentSerializer} from 'sanity-translations-tab'
|
|
5
|
+
import {customSerializers} from 'sanity-translations-tab'
|
|
6
|
+
import {defaultStopTypes} from 'sanity-translations-tab'
|
|
7
|
+
import {documentLevelPatch} from 'sanity-translations-tab'
|
|
8
|
+
import {fieldLevelPatch} from 'sanity-translations-tab'
|
|
9
|
+
import {findLatestDraft} from 'sanity-translations-tab'
|
|
10
|
+
import {SerializedDocument} from 'sanity-naive-html-serializer'
|
|
11
|
+
import {TranslationFunctionContext} from 'sanity-translations-tab'
|
|
12
|
+
import {TranslationsTab} from 'sanity-translations-tab'
|
|
13
|
+
|
|
14
|
+
export {BaseDocumentDeserializer}
|
|
15
|
+
|
|
16
|
+
export {BaseDocumentMerger}
|
|
17
|
+
|
|
18
|
+
export {BaseDocumentSerializer}
|
|
19
|
+
|
|
20
|
+
declare interface ConfigOptions {
|
|
21
|
+
adapter: Adapter
|
|
22
|
+
secretsNamespace: string | null
|
|
23
|
+
exportForTranslation: (
|
|
24
|
+
id: string,
|
|
25
|
+
context: TranslationFunctionContext
|
|
26
|
+
) => Promise<SerializedDocument>
|
|
27
|
+
importTranslation: (
|
|
28
|
+
id: string,
|
|
29
|
+
localeId: string,
|
|
30
|
+
doc: string,
|
|
31
|
+
context: TranslationFunctionContext
|
|
32
|
+
) => Promise<void>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {customSerializers}
|
|
36
|
+
|
|
37
|
+
export declare const defaultDocumentLevelConfig: ConfigOptions
|
|
38
|
+
|
|
39
|
+
export declare const defaultFieldLevelConfig: ConfigOptions
|
|
40
|
+
|
|
41
|
+
export {defaultStopTypes}
|
|
42
|
+
|
|
43
|
+
export {documentLevelPatch}
|
|
44
|
+
|
|
45
|
+
export {fieldLevelPatch}
|
|
46
|
+
|
|
47
|
+
export {findLatestDraft}
|
|
48
|
+
|
|
49
|
+
export declare const SmartlingAdapter: Adapter
|
|
50
|
+
|
|
51
|
+
export {TranslationsTab}
|
|
52
|
+
|
|
53
|
+
export {}
|