Skip to content

Port sanity-plugin-google-translate to monorepo#906

Open
Copilot wants to merge 79 commits into
mainfrom
copilot/move-google-translate-plugin
Open

Port sanity-plugin-google-translate to monorepo#906
Copilot wants to merge 79 commits into
mainfrom
copilot/move-google-translate-plugin

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

Migrates sanity-plugin-google-translate into the plugins monorepo using git subtree to preserve commit history. Also includes the generator fix from #905 (CJS format for Node.js 24 compatibility) since the generator was broken without it.

Changes

  • Git subtree import from sanity-io/sanity-plugin-google-translate main branch with full history
  • Monorepo scaffold: package.json (ESM-only, catalog deps), tsconfig, vitest, package.config.ts with React Compiler + styled-components babel plugin
  • Test studio integration: workspace dependency, #google-translate example plugin in sanity.config.ts
  • Knip workspace entry with babel-plugin-styled-components in ignoreDependencies
  • Changeset for major version bump (React 19.2+, Sanity v5+, ESM-only, Node 20.19+)
  • Generator fix (from feat: fold sanity-plugin-latex-input into monorepo #905): tsdown.config.mts outputs CJS, config.ts imports .cjs extension
  • Cleanup: Removed standalone repo config files not needed in the monorepo (.github/, .husky/, .editorconfig, .eslintignore, .eslintrc, .gitignore, .npmignore, .prettierignore, .prettierrc, .releaserc.json)

Breaking changes in the new major

  • ESM-only (CJS dropped)
  • React 19.2+, Sanity v5+, Node.js 20.19+
  • React Compiler enabled (target: 19)
  • styled-components ^6.1 peer dependency retained

Notes

  • @sanity/icons kept at ^3.7.4 (not in workspace catalog)
  • isolatedDeclarations disabled in tsconfig.build.json (can be enabled later)
  • Trusted publishing needs to be configured: npm trust github sanity-plugin-google-translate --file=release.yml --repository=sanity-io/plugins

@pedrobonamin
Copy link
Copy Markdown
Contributor

@copilot you are moving over some config files that are not necessary in this monorepo setup, please verify and remove all the unnecessary ones

These files came from the subtree import but are handled at the monorepo
root level or are no longer needed:
- .editorconfig, .eslintignore, .eslintrc, .prettierignore, .prettierrc (root-level)
- .gitignore (root-level)
- .npmignore (not needed with @sanity/pkg-utils)
- .releaserc.json (using changesets, not semantic-release)
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 27, 2026

@copilot you are moving over some config files that are not necessary in this monorepo setup, please verify and remove all the unnecessary ones

Removed in 25fc5d6. Deleted .editorconfig, .eslintignore, .eslintrc, .gitignore, .npmignore, .prettierignore, .prettierrc, and .releaserc.json — all handled at root level or no longer needed (changesets replaces semantic-release, @sanity/pkg-utils replaces .npmignore).

Comment thread plugins/sanity-plugin-google-translate/README.md Outdated
@pedrobonamin
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 27, 2026

@copilot add an example in where we use the plugin see the readme here https://github.com/sanity-io/plugins/pull/906/changes#diff-fd02b2584732a3a696692c7a6aefd6e329b7eaf90d179904476dddd7944e02fbR42-R7...

Added in 129abd2. The example now includes a localizedString object type with options.translate = true and a googleTranslateTest document type that uses it, following the pattern from the README.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports sanity-plugin-google-translate into the plugins monorepo, adding package scaffolding, source, tests, test-studio integration, and release metadata.

Changes:

  • Adds the Google Translate plugin package with build/test configuration and package exports.
  • Adds plugin source, helper utilities, README/changelog, and a package exports test.
  • Wires the plugin into the test studio, workspace dependencies, lockfile, Knip config, and changeset release flow.

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.changeset/google-translate-monorepo-port.md Adds major-release changeset for the monorepo port.
CHANGELOG.md Imports historical changelog for the plugin.
README.md Adds installation, usage, examples, and API key guidance.
dev/test-studio/package.json Adds the plugin as a test-studio dependency.
dev/test-studio/sanity.config.ts Registers the Google Translate test-studio example.
dev/test-studio/src/google-translate/index.tsx Adds localized string schema and test document example.
knip.jsonc Adds Knip workspace configuration.
package.config.ts Adds package build configuration with React Compiler and styled-components transforms.
package.json Adds package metadata, exports, scripts, dependencies, peers, and engines.
pnpm-lock.yaml Updates lockfile for the new workspace package and test-studio dependency.
src/GoogleTranslateInput.tsx Adds translated object input UI and Google Translate request handling.
src/googleTranslate.tsx Adds Sanity plugin registration and form input override.
src/helpers/extractLanguageFromCode.ts Adds helper for normalizing language codes.
src/helpers/getLanguageFromMember.ts Adds helper for deriving language codes from form members.
src/helpers/htmlDecode.ts Adds helper for decoding translated HTML entities.
src/index.test.ts Adds package exports test.
src/index.ts Adds public package exports.
src/types.ts Adds plugin option and internal helper types.
tsconfig.build.json Adds build TypeScript config.
tsconfig.json Adds typecheck TypeScript config.
vitest.config.ts Adds Vitest configuration.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +76 to +77
if (allLanguageFields.length === 1 && target === source) {
return toast.push({
Comment on lines +85 to +87
url.searchParams.set(`target`, item.fieldLang)

if (item.fieldLang === source) {
Comment on lines +22 to +25
import {createConfig} from 'sanity'
import {googleTranslate} from 'sanity-plugin-google-translate'

export const createConfig({
translate?: boolean
apiKey?: string
}

Copy link
Copy Markdown
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

Copilot calls out a few things that seems legit, but suppose we can fix those later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants