sanity-plugin-studio-smartling 2.0.4 → 2.0.6
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 +28 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ This is a separate plugin, and differs in that it provides editors a visual prog
|
|
|
14
14
|
- [Quickstart](#quickstart)
|
|
15
15
|
- [Studio experience](#studio-experience)
|
|
16
16
|
- [Overriding defaults](#overriding-defaults)
|
|
17
|
+
- [v1 to v2 changes](#v1-to-v2-changes)
|
|
17
18
|
|
|
18
19
|
## Plugin features
|
|
19
20
|
|
|
@@ -44,7 +45,7 @@ For example, on a document you don't want to be translated, you may have a "titl
|
|
|
44
45
|
*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`).
|
|
45
46
|
|
|
46
47
|
### Document level translations
|
|
47
|
-
Since we often find users want to use the [
|
|
48
|
+
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}`
|
|
48
49
|
|
|
49
50
|
### Final note
|
|
50
51
|
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).
|
|
@@ -62,7 +63,7 @@ SANITY_STUDIO_SMARTLING_PROXY=http://your-proxy-url.com
|
|
|
62
63
|
|
|
63
64
|
4. 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-)
|
|
64
65
|
* In your studio, create a file called `populateSmartlingSecrets.js`.
|
|
65
|
-
* Place the following in the file and fill out the correct values
|
|
66
|
+
* Place the following in the file and fill out the correct values.
|
|
66
67
|
|
|
67
68
|
```javascript
|
|
68
69
|
import sanityClient from 'part:@sanity/base/client'
|
|
@@ -74,7 +75,7 @@ _id: 'translationService.secrets',
|
|
|
74
75
|
_type: 'smartlingSettings',
|
|
75
76
|
organization: 'YOUR_ORG_HERE',
|
|
76
77
|
project: 'YOUR_PROJECT_HERE',
|
|
77
|
-
secret: '
|
|
78
|
+
secret: '{"userIdentifier":"xxxxxx","userSecret":"xxxx"}', //in this format from Smartling
|
|
78
79
|
})
|
|
79
80
|
```
|
|
80
81
|
|
|
@@ -119,4 +120,27 @@ To personalize this configuration it's useful to know what arguments go into `Tr
|
|
|
119
120
|
|
|
120
121
|
There are a number of reasons to override these functions. More general cases are often around ensuring documents serialize and deserialize correctly. Since the serialization fucntions 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 new config.
|
|
121
122
|
|
|
122
|
-
This plugin is in early stages. We plan on improving some of the user-facing
|
|
123
|
+
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!
|
|
124
|
+
|
|
125
|
+
## V1 to V2 changes
|
|
126
|
+
|
|
127
|
+
Most users will not encounter issues in upgrading to v2. The breaking changes are as follows:
|
|
128
|
+
|
|
129
|
+
1. **Change to document-level localization id structure.** Since the [Internationalization input plugin](https://www.sanity.io/plugins/sanity-plugin-intl-input) was deprecated, the default pattern `i18n.{id-of-base-language-document}.{locale}` was deprecated in favor of `{id-of-base-language-document}__i18n_{locale}`. If you would like to maintain that pattern, please add the `idStructure` param to your tab config, like:
|
|
130
|
+
```javascript
|
|
131
|
+
S.view.component(TranslationsTab).title('Smartling').options(
|
|
132
|
+
{...defaultDocumentLevelConfig, idStructure: 'subpath'}
|
|
133
|
+
)
|
|
134
|
+
```
|
|
135
|
+
2. **Underlying changes in serializers.** Serializers were updated to a) take advantage of the newer [Portable Text to HTML package](https://github.com/portabletext/to-html) and allow for explicit schema closures. If you were overriding serialization methods, that means invocation of `BaseDocumentSerializer` will change from:
|
|
136
|
+
```javascript
|
|
137
|
+
BaseDocumentSerializer.serializeDocument(id, 'serialization-level')
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
to:
|
|
141
|
+
```javascript
|
|
142
|
+
import schemas from 'part:@sanity/base/schema'
|
|
143
|
+
|
|
144
|
+
BaseDocumentSerializer(schemas).serializeDocument(id, 'serialization-level')
|
|
145
|
+
```
|
|
146
|
+
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
2
|
+
"version": "2.0.6",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
"typescript": "^4.0.5"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"sanity-translations-tab": "^2.0.
|
|
57
|
+
"sanity-translations-tab": "^2.0.8"
|
|
58
58
|
}
|
|
59
59
|
}
|