Skip to content

SamuelFolledo/StringsUtility

Repository files navigation

Strings Utility

commits commits License: MIT gitmoji-changelog

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

Live Demo

Why Use?

  • 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

How to Use?

Download StringsUtility

  • 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

$ 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 setup
    export GOOGLE_APPLICATION_CREDENTIALS=[PATH]
    
    For example:
    export GOOGLE_APPLICATION_CREDENTIALS=/Users/Samuel/Downloads/StringsUtility-Tester-785c7f11aedf.json
    

For further details, tips, recommendations go to Tips and Requirements

Run StringsUtility

  • run the program locally replacing [PATH_TO_YOUR_PROJECT] with your project directory
    $ go build && go run main.go -dir=[PATH_TO_YOUR_PROJECT]
    
    For example:
    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

Links

To have a customized version for your company standards, feel free to email me at samuelfolledo@gmail.com

Lincense under MIT License

About

Swift utility written in Go which automates boring Swift strings tasks like globalizing, localizing, and translation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages