Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
56a1d72
First commit
runeb May 17, 2021
628ceb2
Begin README
runeb Jun 22, 2021
bad371f
Filter and sort by default (base) language
runeb Jun 22, 2021
96f5e13
Update package.json
runeb Jun 22, 2021
b37c41a
Update README.md
runeb Jun 22, 2021
2ad364b
blank out test
runeb Jun 22, 2021
465061b
Add publish workflow
runeb Jun 22, 2021
154ba9c
Add lockfiles
runeb Jun 22, 2021
c395d7f
lint
runeb Jun 23, 2021
c029c54
Delete main.yml
runeb Jun 23, 2021
f95b405
Merge branch 'main' of github.com:sanity-io/sanity-plugin-google-tran…
runeb Jun 23, 2021
b089aa6
Update README.md
runeb Jun 23, 2021
3d558ed
Update README.md
runeb Jun 23, 2021
7d97503
Update README.md
runeb Jun 23, 2021
a195b7e
Update package.json
runeb Jun 24, 2021
66c0edd
Respect filterField function and hidden schema option
runeb Jun 28, 2021
83c2199
Upgrade @sanity/types, bump version
runeb Jun 28, 2021
6c1b535
add form builder to peerDeps
SimeonGriggs Jun 28, 2021
fd4eb69
Merge pull request #2 from sanity-io/add-form-builder
SimeonGriggs Jun 28, 2021
18d37f3
Add @sanity/form-builder to dev dependencies
runeb Jun 28, 2021
8438170
Remove size workflow
runeb Jun 28, 2021
cd5bc34
Create node.js.yml
runeb Jun 28, 2021
0a85063
Merge branch 'main' into filterFields
runeb Jun 28, 2021
ee68f49
Generate package-lock
runeb Jun 28, 2021
4767397
Add @sanity/ui to dev dependencies
runeb Jun 28, 2021
c69d745
Merge pull request #1 from sanity-io/filterFields
runeb Jun 28, 2021
07309b4
Update README.md
runeb Jun 28, 2021
2aa5ffc
add theme wrapper, silence schema warning about title, show permissions
SimeonGriggs Jul 2, 2021
c6d84dc
remove console log
SimeonGriggs Jul 2, 2021
e8c17ba
Merge pull request #3 from sanity-io/permissions
runeb Jul 2, 2021
6723a47
Prepare new version
runeb Jul 2, 2021
e1540ef
update publish workflow
SimeonGriggs Jul 5, 2021
ce9c11b
Merge pull request #4 from sanity-io/permissions
SimeonGriggs Jul 5, 2021
1c2ecb8
add publish on push action
SimeonGriggs Jul 7, 2021
d9d10e8
Merge pull request #5 from sanity-io/push-publish
SimeonGriggs Jul 7, 2021
c592f6e
update packages
SimeonGriggs Dec 20, 2021
f982e95
increment version
SimeonGriggs Dec 20, 2021
7060163
Merge branch 'main' into chore/update-packages
SimeonGriggs Dec 20, 2021
4132933
Merge pull request #8 from sanity-io/chore/update-packages
SimeonGriggs Dec 20, 2021
af4262f
rewrite plugin in Sanipack with native inputs
SimeonGriggs Jan 19, 2022
4c90a8a
fix typo
SimeonGriggs Jan 19, 2022
4da1176
fix helper function import
SimeonGriggs Feb 3, 2022
5506c00
add lodash to peer deps, add empty test script
SimeonGriggs Mar 14, 2022
aa000a5
Merge pull request #9 from sanity-io/v2
SimeonGriggs Mar 14, 2022
5993a3a
add movie
SimeonGriggs Mar 14, 2022
bd06cab
Merge pull request #10 from sanity-io/v2
SimeonGriggs Mar 14, 2022
86646ed
feat: begin v3 upgrade
SimeonGriggs Mar 6, 2023
f85ad9b
fix: remove old/temp files
SimeonGriggs Mar 6, 2023
0901d62
feat: complete input, readme, update plugin-kit
SimeonGriggs Apr 4, 2023
91561fa
feat: rap up work on new plugin
SimeonGriggs Apr 4, 2023
15a48ed
fix: build settings
SimeonGriggs Apr 4, 2023
266316b
Merge pull request #13 from sanity-io/v3
SimeonGriggs Apr 4, 2023
1912141
chore(release): 1.0.0 [skip ci]
semantic-release-bot Apr 4, 2023
732b9d5
feat: force new release
SimeonGriggs Apr 4, 2023
b4b7632
Merge pull request #14 from sanity-io/v3
SimeonGriggs Apr 4, 2023
d7084fa
chore(release): 2.0.0 [skip ci]
semantic-release-bot Apr 4, 2023
7af61d9
feat: force new release
SimeonGriggs Apr 4, 2023
4dd6c58
Merge pull request #15 from sanity-io/v3
SimeonGriggs Apr 4, 2023
05bb070
chore(release): 3.0.0 [skip ci]
semantic-release-bot Apr 4, 2023
9f8f554
chore(release): 3.0.0 [skip ci]
semantic-release-bot Apr 4, 2023
3e98f6a
chore(release): 3.0.0 [skip ci]
semantic-release-bot Apr 4, 2023
027aef4
chore(deps): update actions/checkout action to v4 (#26)
renovate[bot] Apr 9, 2025
91a003c
fix(deps): allow studio v4 peer dep ranges
stipsan Jul 10, 2025
4ad1c4e
chore(release): 3.0.1 [skip ci]
semantic-release-bot Jul 10, 2025
2e8606b
fix(deps): bump icons
stipsan Jul 10, 2025
79ba8da
chore(release): 3.0.2 [skip ci]
semantic-release-bot Jul 10, 2025
384543e
Update README.md
RitaDias Jul 11, 2025
b3eaeee
fix: update package.json and package-lock.json to support Sanity v5 (…
KJHeartbreaker Dec 29, 2025
d3a64cb
chore(release): 3.0.3 [skip ci]
semantic-release-bot Dec 29, 2025
b14c831
initial plan
Copilot May 27, 2026
efec0d0
Add 'plugins/sanity-plugin-google-translate/' from commit 'd3a64cb3d2…
Copilot May 27, 2026
87333fc
chore(sanity-plugin-google-translate): remove files that will be rege…
Copilot May 27, 2026
7af01cc
feat: port sanity-plugin-google-translate to monorepo using git subtree
Copilot May 27, 2026
199a0e8
Merge origin/main into copilot/move-google-translate-plugin
Copilot May 27, 2026
ef32e96
chore: remove .github and .husky from google-translate plugin
Copilot May 27, 2026
25fc5d6
chore: remove unnecessary config files from google-translate plugin
Copilot May 27, 2026
58969d4
chore: restore original README for sanity-plugin-google-translate
Copilot May 27, 2026
129abd2
chore: add schema example to google-translate test studio plugin
Copilot May 27, 2026
e6e4806
fix: knip and lint fixes
pedrobonamin May 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/google-translate-monorepo-port.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'sanity-plugin-google-translate': major
---

Port sanity-plugin-google-translate to the Sanity plugins monorepo

This major release includes several breaking changes as part of the migration to the monorepo:

- **React Compiler enabled**: The plugin is now optimized with React Compiler targeting React 19
- **ESM-only**: CommonJS support has been removed. The package now ships only ESM
- **React 19.2+ required**: Minimum React version is now 19.2
- **Sanity Studio v5+ required**: Minimum Sanity version is now v5
- **Node.js 20.19+ required**: Minimum Node.js version is now 20.19
- **styled-components 6.1+ required**: Peer dependency on styled-components ^6.1
1 change: 1 addition & 0 deletions dev/test-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"sanity-plugin-aprimo": "workspace:*",
"sanity-plugin-asset-source-unsplash": "workspace:*",
"sanity-plugin-bynder-input": "workspace:*",
"sanity-plugin-google-translate": "workspace:*",
"sanity-plugin-graph-view": "workspace:*",
"sanity-plugin-iframe-pane": "workspace:*",
"sanity-plugin-internationalized-array": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions dev/test-studio/sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {codeInputExample} from '#code-input'
import {colorExample} from '#color'
import {debugLiveSyncTagsExample} from '#debug-live-sync-tags'
import {documentInternationalizationExample} from '#document-internationalization'
import {googleTranslateExample} from '#google-translate'
import {iframePaneExample} from '#iframe-pane'
import {
internationalizedArrayAsyncLanguages,
Expand Down Expand Up @@ -62,6 +63,7 @@ export default defineConfig([
plugins: [
structureTool(),
assistExample(),
googleTranslateExample(),
// add new plugins here
latexInputExample(),
debugLiveSyncTagsExample(),
Expand Down
57 changes: 57 additions & 0 deletions dev/test-studio/src/google-translate/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {defineField, definePlugin, defineType} from 'sanity'
import {googleTranslate} from 'sanity-plugin-google-translate'

const languages = [
{id: 'en', title: 'English', isDefault: true},
{id: 'es', title: 'Spanish'},
{id: 'fr', title: 'French'},
]

const localizedString = defineType({
name: 'localizedString',
type: 'object',
options: {
// @ts-expect-error - plugin-specific object option
translate: true,
apiKey: 'DEMO_KEY',
},
fieldsets: [
{
title: 'Translations',
name: 'translations',
options: {collapsible: true, collapsed: false},
},
],
fields: languages.map((lang) =>
defineField({
name: lang.id,
title: lang.title,
type: 'string',
fieldset: lang.isDefault ? undefined : 'translations',
}),
),
})

const googleTranslateTest = defineType({
type: 'document',
name: 'googleTranslateTest',
title: 'Google Translate',
fields: [
defineField({type: 'string', name: 'title', title: 'Title'}),
defineField({
type: 'localizedString',
name: 'greeting',
title: 'Greeting',
}),
defineField({
type: 'localizedString',
name: 'description',
title: 'Description',
}),
],
})

export const googleTranslateExample = definePlugin(() => ({
schema: {types: [localizedString, googleTranslateTest]},
plugins: [googleTranslate()],
}))
8 changes: 8 additions & 0 deletions knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@
],
},
// add new plugin workspaces here
"plugins/sanity-plugin-google-translate": {
"entry": ["package.config.ts"],
"project": ["src/**/*.{ts,tsx}"],
"ignoreDependencies": [
// Used by @sanity/pkg-utils babel transform, not directly imported
"babel-plugin-styled-components",
],
},
"plugins/sanity-plugin-latex-input": {
"entry": ["package.config.ts"],
"project": ["src/**/*.{ts,tsx}"],
Expand Down
104 changes: 104 additions & 0 deletions plugins/sanity-plugin-google-translate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# sanity-plugin-google-translate

## [3.0.3](https://github.com/sanity-io/sanity-plugin-google-translate/compare/v3.0.2...v3.0.3) (2025-12-29)

### Bug Fixes

- update package.json and package-lock.json to support Sanity v5 ([#27](https://github.com/sanity-io/sanity-plugin-google-translate/issues/27)) ([b3eaeee](https://github.com/sanity-io/sanity-plugin-google-translate/commit/b3eaeeeb032da5666bce955ac2f84473d6b147d5))

## [3.0.2](https://github.com/sanity-io/sanity-plugin-google-translate/compare/v3.0.1...v3.0.2) (2025-07-10)

### Bug Fixes

- **deps:** bump icons ([2e8606b](https://github.com/sanity-io/sanity-plugin-google-translate/commit/2e8606b3b41e2537f78a797ba9b87966da0688cd))

## [3.0.1](https://github.com/sanity-io/sanity-plugin-google-translate/compare/v3.0.0...v3.0.1) (2025-07-10)

### Bug Fixes

- **deps:** allow studio v4 peer dep ranges ([91a003c](https://github.com/sanity-io/sanity-plugin-google-translate/commit/91a003c01d86a181665807e3585c3f230816f78a))

## [3.0.0](https://github.com/sanity-io/sanity-plugin-google-translate/compare/v2.0.0...v3.0.0) (2023-04-04)

### ⚠ BREAKING CHANGES

- First new version of v3-compatible plugin

### Features

- force new release ([7af61d9](https://github.com/sanity-io/sanity-plugin-google-translate/commit/7af61d93a0348c63011b2391cf4df83555eb16b1))

## [3.0.0](https://github.com/sanity-io/sanity-plugin-google-translate/compare/v2.0.0...v3.0.0) (2023-04-04)

### ⚠ BREAKING CHANGES

- First new version of v3-compatible plugin

### Features

- force new release ([7af61d9](https://github.com/sanity-io/sanity-plugin-google-translate/commit/7af61d93a0348c63011b2391cf4df83555eb16b1))

## [3.0.0](https://github.com/sanity-io/sanity-plugin-google-translate/compare/v2.0.0...v3.0.0) (2023-04-04)

### ⚠ BREAKING CHANGES

- First new version of v3-compatible plugin

### Features

- force new release ([7af61d9](https://github.com/sanity-io/sanity-plugin-google-translate/commit/7af61d93a0348c63011b2391cf4df83555eb16b1))

## [2.0.0](https://github.com/sanity-io/sanity-plugin-google-translate/compare/v1.0.0...v2.0.0) (2023-04-04)

### ⚠ BREAKING CHANGES

- First new version of v3-compatible plugin

### Features

- force new release ([732b9d5](https://github.com/sanity-io/sanity-plugin-google-translate/commit/732b9d5a0864ce7acd800de53f411289db70fe57))

## 1.0.0 (2023-04-04)

### ⚠ BREAKING CHANGES

- First new version of v3-compatible plugin

### Features

- begin v3 upgrade ([86646ed](https://github.com/sanity-io/sanity-plugin-google-translate/commit/86646ed26e69325b2c78561b9135986b4cca6e57))
- complete input, readme, update plugin-kit ([0901d62](https://github.com/sanity-io/sanity-plugin-google-translate/commit/0901d622b29f82ad10a727ef017833bcd2ffd187))
- rap up work on new plugin ([91561fa](https://github.com/sanity-io/sanity-plugin-google-translate/commit/91561fa1ac6a99380cf2c1b2ef16ba744bceb086))

### Bug Fixes

- build settings ([15a48ed](https://github.com/sanity-io/sanity-plugin-google-translate/commit/15a48ede35d7cf582c7d3e89d0bfe5fa45d76445))
- remove old/temp files ([f85ad9b](https://github.com/sanity-io/sanity-plugin-google-translate/commit/f85ad9bc9072bff330289b9842bf3508c93cc917))

## [1.0.2](https://github.com/SimeonGriggs/sanity-plugin-utils/compare/v1.0.1...v1.0.2) (2023-02-09)

### Bug Fixes

- add a package lock ([a7703cd](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/a7703cdbde1cc0b09b4d66624327c4713efb5643))
- add api version to useClient ([cf3451f](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/cf3451f7aff25e1d683c2d96d8587f7d3057466d))
- downgrade semantic release ([4ae8a7b](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/4ae8a7bb0035e970c61c72bbe67522e59362f713))
- go live ([c1fc363](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/c1fc363799d3d6f5c484244edad0fd4de4df197b))
- inject ([c54e564](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/c54e564707660a364b08920e5b364519465ae25e))
- inject latest ([58175fe](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/58175fec34d4392a8424ce28ff3e2f50615e4e69))
- remove parcel cache ([126bcdf](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/126bcdf949a5bd64a91ac71e4ac6ff5b6a69844d))
- update plugin config ([24c1add](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/24c1add389be2bcbd222b3698b077c4e047f1afe))

## [1.0.1](https://github.com/SimeonGriggs/sanity-plugin-utils/compare/v1.0.0...v1.0.1) (2022-12-13)

### Bug Fixes

- update deps to v3 studio ([fb0c225](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/fb0c2259e99deb28af0af84353471f7e60759a15))
- update package-lock ([45b3faf](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/45b3faf195bf4c44200b313fa755847d915a3e1e))
- update packages ([72c518c](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/72c518cc4b8d11528a546c5be1c66285ecff3f3f))

## 1.0.0 (2022-11-17)

### Features

- release ([5f6a76c](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/5f6a76c8621d8b13d60d567f8f2449aaff775568))
- remove dry run and do first release ([33359be](https://github.com/SimeonGriggs/sanity-plugin-utils/commit/33359bed43a8a69296fbb62c2d8ad3abbae17217))
115 changes: 115 additions & 0 deletions plugins/sanity-plugin-google-translate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# sanity-plugin-google-translate

This plugin lets you connect Sanity fields to Google Cloud Translate API, giving you instant machine translations for 108 languages and counting! Enable it for all of them! ...or just the ones you need.

## Installation

```
npm install --save sanity-plugin-google-translate

OR

yarn add sanity-plugin-google-translate
```

## Usage

First, add it as a plugin in `sanity.config.ts/js`

```ts
// ./sanity.config.ts

import {createConfig} from 'sanity'
import {googleTranslate} from 'sanity-plugin-google-translate'

export const createConfig({
// ...all other config settings
plugins: [
// ...all other plugins
googleTranslate()
]
})
```

This plugin is designed to work with <a href="https://www.sanity.io/docs/localization#cd568b11a09c">field-level translated objects</a> and replace the default input component with a Google Translate-powered one. By setting `options.translate = true` on an object field definition.

These objects should be registered in the way recommended by the <a href="https://www.npmjs.com/package/@sanity/language-filter">@sanity/language-filter plugin</a>. With a field for each language. The base language at the top level, and all other languages inside a fieldset.

Note: This will not translate Portable Text content, as that schema type should not be mapped over multiple times in a single document. If you need multiple languages of Portable Text, you are best to use <a href="https://github.com/sanity-io/document-internationalization">document-level translation</a>.

### Example: Add Google Translate to all localized `string` objects

```js
// ./schemas/fields/localizedString.ts

const languages = [
{id: 'en', title: 'English', isDefault: true},
{id: 'es', title: 'Spanish'},
{id: 'fr', title: 'French'},
]

export default defineField({
name: 'localizedString',
type: 'object',
options: {
// This will replace the default input component
translate: true,
// This API key will be bundled with your studio
// and so should be restricted by hostname
// See: https://www.sanity.io/docs/studio-environment-variables
apiKey: process.env.SANITY_STUDIO_GOOGLE_TRANSLATE_API_KEY,
},
fieldsets: [
{
title: 'Translations',
name: 'translations',
options: {collapsible: true, collapsed: false},
},
],
fields: languages.map((lang) => ({
name: lang.id,
title: lang.title,
type: 'string', // or `text`, etc
fieldset: lang.isDefault ? null : 'translations',
})),
})
```

### Example: Extend some localized `string` objects with Google Translate

Alternatively, you could selectively extend specific uses of `localizedString`, by registering another object to your schema which uses it as a base. This is helpful if you only need Google Translate on specific fields.

```ts
// ./schemas/fields/localizedGoogleTranslateString.ts

export default defineField({
name: 'localizedGoogleTranslateString',
title: 'Localized String',
type: 'localizedString',
options: {
translate: true,
apiKey: process.env.SANITY_STUDIO_GOOGLE_TRANSLATE_API_KEY,
},
})
```

## API Key security

By including your Google Cloud Translation API key in the schema definition it becomes part of the Studio bundle which is hosted as static files on web servers.

To avoid others using your key you should restrict it to hosts where your studio runs, like

- `http://localhost:3333/*`
- `http://<your-project>.sanity.studio/*`
- ...or custom domain you may be hosting the Studio

<a href="https://cloud.google.com/docs/authentication/api-keys#adding_http_restrictions">More info on adding HTTP restrictions</a>

## License

MIT © Sanity.io
See LICENSE

## License

<a>MIT</a> © Sanity.io
8 changes: 8 additions & 0 deletions plugins/sanity-plugin-google-translate/package.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import config from '@repo/package.config'
import {defineConfig} from '@sanity/pkg-utils'

export default defineConfig({
...config,
babel: {reactCompiler: true, styledComponents: true},
reactCompilerOptions: {target: '19'},
})
Loading
Loading