Swift utility written in Go which automates boring Swift strings tasks like:
- Feature 1: Constantify Strings Creates global constant variables from all .swift files to a constant file
- Feature 2: Localize Strings Transform all valid translatable strings as NSLocalizedString and copies them to all
Localizable.strings
files while avoiding duplicated strings - Feature 3: Translate Strings Uses Google Cloud Translation to automatically translate all strings in all
Localizable.strings
, allowing iOS, MacOS, etc apps to support multiple languages in a few seconds
- Avoid unintended typos
- Have strings autocompleted
- Easily manage all your strings in one file
- Auto generate strings
Localizable.strings
and avoid duplicate strings - Automatically translate all strings in
Localizable.strings
- clone the repo
$ git clone https://github.com/SamuelFolledo/StringsUtility
$ cd StringsUtility
Install Golang with Updated Homebrew:
- Make sure HomeBrew is updated
$ brew update
$ brew install golang
Setup Google Cloud Translator: Required for feature 3 only
- Set up a Cloud Console project
- Download a private key as JSON
- While inside StringsUtility directory, run in terminal once
$ go get -u cloud.google.com/go/translate
- Important: Run this command once each fresh terminal. Replace the
[PATH]
to the path of the.json
file downloaded from setup 2 step 3. Instructions for more info or for Windows setupFor example:export GOOGLE_APPLICATION_CREDENTIALS=[PATH]
export GOOGLE_APPLICATION_CREDENTIALS=/Users/Samuel/Downloads/StringsUtility-Tester-785c7f11aedf.json
For further details, tips, recommendations go to Tips and Requirements
- run the program locally replacing
[PATH_TO_YOUR_PROJECT]
with your project directoryFor example:$ go build && go run main.go -dir=[PATH_TO_YOUR_PROJECT]
go build && go run main.go -dir=/Users/macbookpro15/Desktop/StringsUtilityTester
- Currently does not support multi line strings
- To avoid unnecessary translation, strings which contains substrings like file extensions, keywords, and symbols will not be translated. Edit strings and files to follow these standards.
"/", "\\", "{", "}", "_", "#", "%", ".swift", ".xib", ".storyboard", ".jpg", ".jpeg", ".png", ".mp4", ".mp3", ".wav", ".mov", ".gif", "http", "https", ".com", "identifier"
- Strings like url, identifiers, and more which contains substrings like the following will not be constantify.
"/", "\\", "{", "}", "http", "https", ".com", "#", "%", "identifier"
- Suported Languages
For more tips and requirements click here
- My final project for MakeSchool's BEW2.5: Patterns & Practices in Strongly Typed Languages - the only university that teaches Go
- MakeUtility Requirements
- My article: 5 Steps to Localizing your Swift Apps
- Added feature 2 and 3 during Make School's Spring Intensive 1.3
- Follow me at LinkedIn, GitHub and Portfolio
To have a customized version for your company standards, feel free to email me at samuelfolledo@gmail.com
Lincense under MIT License