gt-sanity 3.0.0 → 3.1.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 +32 -0
- package/dist/index.cjs +556 -105
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +559 -108
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/adapter/core.ts +10 -2
- package/src/components/TranslationsProvider.tsx +171 -46
- package/src/components/page/SaveLocalTranslationsDialog.tsx +60 -0
- package/src/components/page/TranslateAllDialog.tsx +66 -15
- package/src/components/page/TranslationsTool.tsx +56 -0
- package/src/components/page/UploadExistingDialog.tsx +52 -0
- package/src/components/tab/TranslationView.tsx +50 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/createI18nDocAndPatchMetadata.ts +2 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/createTranslationMetadata.ts +2 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/getOrCreateTranslationMetadata.ts +11 -6
- package/src/configuration/baseDocumentLevelConfig/helpers/getTranslationMetadata.ts +6 -2
- package/src/index.ts +19 -4
- package/src/sanity-api/resolveRefs.ts +8 -3
- package/src/serialization/internationalizedArray/detect.ts +21 -0
- package/src/translation/__tests__/captureExistingTranslations.test.ts +167 -0
- package/src/translation/__tests__/collectExistingTranslations.test.ts +231 -0
- package/src/translation/__tests__/initProject.test.ts +109 -0
- package/src/translation/captureExistingTranslations.ts +111 -0
- package/src/translation/collectExistingTranslations.ts +199 -0
- package/src/translation/createJobs.ts +7 -1
- package/src/translation/initProject.ts +18 -35
- package/src/translation/uploadTranslations.ts +54 -0
- package/src/utils/__tests__/locales.test.ts +48 -0
- package/src/utils/locales.ts +20 -0
- package/src/utils/translationMetadata.ts +38 -0
package/README.md
CHANGED
|
@@ -125,3 +125,35 @@ occurrence of that type (matching the native plugins' "field or type"
|
|
|
125
125
|
semantics). The legacy `localize: false` field property is still supported. For id-based or
|
|
126
126
|
cross-document rules (e.g. slug deduplication), the plugin-level
|
|
127
127
|
`ignoreFields` / `skipFields` / `dedupeFields` options remain available.
|
|
128
|
+
|
|
129
|
+
## Preserving Edits to Translations
|
|
130
|
+
|
|
131
|
+
Translated content often gets touched up in the Studio after it comes back from
|
|
132
|
+
General Translation, and a later translation run would normally regenerate it.
|
|
133
|
+
The **Save local edits** toggle in the Translations tool changes that:
|
|
134
|
+
with it on, the translations currently in Sanity are uploaded to General
|
|
135
|
+
Translation before a translation run, so content whose source text has not
|
|
136
|
+
changed is reused from the Sanity version instead of being regenerated.
|
|
137
|
+
|
|
138
|
+
This is **off by default**; turning it on shows an explanation of the trade-off
|
|
139
|
+
first, and the choice lasts for the Studio session. Turning it on means local
|
|
140
|
+
content overwrites whatever General Translation holds for that source version —
|
|
141
|
+
including a completed translation that has not been imported into Sanity yet.
|
|
142
|
+
Import pending translations before enabling it if that matters to you.
|
|
143
|
+
|
|
144
|
+
Set the initial state of the toggle from plugin config:
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
gtPlugin({
|
|
148
|
+
// ...
|
|
149
|
+
preserveExistingTranslations: true,
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
To upload the translations already in Sanity without starting a translation run
|
|
154
|
+
— useful when adopting the plugin on a project that was translated elsewhere —
|
|
155
|
+
use **Save Local Edits**. It uploads the source files it needs, but does not
|
|
156
|
+
enqueue any translation.
|
|
157
|
+
|
|
158
|
+
To regenerate translations and deliberately discard existing ones for a single
|
|
159
|
+
run, use **Retranslate from scratch** in the Translate All dialog.
|