A Localization package for swift

SwiftLingo

Localization is time-consuming so I made a package to automate the task.

Steps to setup, only take a few minutes!

  1. Import the pacakge https://github.com/kumarneel/SwiftLingo
  2. Setup a folder where you would like to store your localized information
  • Create a .swift file called LocalizableStrings

  • Create a .string file called Localizable, Xcode will automatically call it by this name

  1. Go to Project Settings tab Info
  • Go to the Localization Section
  1. Click + and add any Language that you would like to translate into
  • NOTE, these language codes are important and will passed into SwiftPackage Initializer
  1. Go back to your Localizable.strings file. Go to the navigation tab on the right and click Localize...
  1. Check the languages you just added to be localized
  1. They will now appear under the file you have created

Usage

Create your first key in your English Translation file

"log_in_title" = "Login";

Import SwiftLingo

Initialize in AppDelegate or anywhere AND RUN ON SIMULATOR

// Path to root directory where files are stored
// 'fr' is the French Language Code
SL.initialize(
    directoryPath: "/Users/photos/Desktop/Localization/SwiftLingoTest/SwiftLingoTest/Localization",
    desiredLanguages: ["en", fr"],
    openAPIKey: "your_API_KEY"
)

Watch as files auto-populate once logs are complete

Use localized string variable in View

struct ContentView: View {
    var body: some View {
        VStack {
            Text(LocalizableStrings.log_in_title)
        }
        .padding()
    }
}

GitHub

View Github