Swift Translate is a CLI tool and Swift Package Plugin that makes it easy to localize your app. It deconstructs your string catalogs and sends them to OpenAI's GPT-3.5-Turbo/GPT-4o models or Google Cloud Translate (v2) for translation. See it in action:
Before continuing, please read the following:
π Note: By default, your catalogs WILL NOT be overwritten, instead a copy will be made with .loc
extension.
If you wish to overwrite your catalogs, be sure they are checked into your repository or backed up, then use the --overwrite
CLI argument.
Ok, with that out of the way let's get into the fun stuff...
π Note: While this plugin is still in development, this is the recommended way of trying it with your projects.
cd
to the repo on your machine.swift run swift-translate --verbose -k <your key here> --text "This is a test" --lang de
You should see the following output:
Building for debugging...
Build complete! (0.59s)
Translating `This is a test`:
de: Dies ist ein Test
β
Translated 1 key(s) (0.384 seconds)
--help
command to learn more:
swift run swift-translate --help
Package.swift
file.
dependencies: [
.package(url: "https://github.com/hidden-spectrum/swift-translate", .upToNextMajor(from: "0.1.0"))
]
.target(
name: "App",
// ...
plugins: [
.plugin(name: "SwiftTranslate", package: "swift-translate")
]
)
cd
to your package directory.swift package plugin swift-translate -k <your key here> <path/to/some/localization.xcstrings> --lang de --verbose
Y
when prompted for write access to your package folder and for outgoing network connections.YourFile.loc.xcstrings
file in the same directory as the original file.π§ Not yet supported
If you're a GPT Guru, we'd love to hear from you about how we can improve our use of the OpenAI API. Open a ticket with your suggestions or contact us to get involved directly.
We're still working out a proper process for contributing to this project. In the meantime, check out open issues to see where you may be able to help. If something isn't listed, feel free to open a ticket or PR and we'll take a look!