Docs
Text

Translate ToggleNew

Text with an on-device Translate button: the words blur over one by one into the reader's language as the label rolls.

$npx swiftpieces add TranslateToggle
Free · MIT + Commons ClauseiOS 17.0+translatetranslationlanguagelocaletextreviews
Type
TranslateToggle
Files
TranslateToggle.swift
Depends on
Nothing (Apple frameworks only)
Version
1.0.0

Colors and type for TranslateToggle. .standard is the house palette.

Notes

  • Uses Apple's on-device Translation framework, so there are no keys, no server and nothing leaves the device. The first translation into a language may ask the reader to download it.
  • The source language is detected with NaturalLanguage and shown above the text. The target is the reader's language unless you pass one.
  • Tap Translate and the words blur out one by one and the translation sharpens in the same way, while the language line rolls to say where it came from. The button turns red and reads Original; tap it to go back. The translation is kept, so switching again is instant.
  • The button hides when the text is already in the target language, and before iOS 18, where Translation is not available.
  • If a translation fails, such as an unsupported pair or a declined download, it stays on the original and the next tap tries again.
  • Under Reduce Motion the text cross-fades instead of blurring word by word.

Usage

TranslateToggleExample()

Install

Pick one. Run it from the folder that contains your .xcodeproj and the files land inside your app.

Terminal

$npx swiftpieces add TranslateToggle

Or ask your coding agent · Claude Code, Cursor or Xcode, once the MCP server is connected

>Add the SwiftPieces "Translate Toggle" piece to my app

Or copy the source above into your app.

New to SwiftUI?If you know React, CSS or Tailwind, SwiftUI is easier to pick up than it looks.Try real app patterns first

Building a whole app? See SwiftPieces Pro →

All text →

Build it yourself: SwiftUI animations guide · Liquid Glass guide

On this page

SwiftPiecesPro

Build the whole app with one library.

Production-ready screens, whole flows, complete app templates, a Build Kit your agent follows and Pro remixing.

Explore Pro