Skip to content
🏁 Hassle-free Localization for iOS
Branch: master
Clone or download
Latest commit 76a0f75 Sep 8, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example/LocalizeExample Fixes type Nov 3, 2017
.gitignore Initial commit Dec 10, 2016
CODE_OF_CONDUCT.md
LICENSE Initial commit Dec 10, 2016
Localize.swift
README.md Update README Aug 22, 2018
banner.png
xcodeScreenshot.png Adds Screenshot Dec 10, 2016

README.md

Localize

Localize

Language: Swift Platform: iOS codebeat badge License: MIT Release version

Localize is a tiny run script that keeps your Localizable.strings files clean and emits warnings when something is suspicious.

Localize

Because Localization files tend to rot over time and become a hassle to work with. Stressful when you have to test your app against many different Localizations.

Try it!

Localize is part of freshOS iOS toolset. Try it in an example App ! Download Starter Project

How

By using a script running automatically, you have a safety net keeping them sane, checking for translation issues and preventing then to rot over time.

What

Automatically (On build)

  • Cleans you localization files (removes spaces)
  • Sorts keys Alphabetically
  • Checks for Unused Keys
  • Checks for Missing Keys
  • Checks for Untranslated (which you can ignore with a flag)

Installation

Add the following Run Script in XCode, this will run the script at every build. Use the path of where you copied Localize.swift script

${SRCROOT}/{REPLACE ME}} # Ex: ${SRCROOT}/Libs/Localize.swift

Run and Enjoy \o/

Configuration

Configure the top section of the Localize.swift according to your project

More

Ignore [Potentialy Untranslated] warnings

Just Add //ignore-same-translation-warning next to the translation. Example :

"PhotoKey" = "Photo"; //ignore-same-translation-warning

This will take care of ignoring [Potentialy Untranslated] "XXX" in FR file doesn't seem to be localized

Unused false positive

Not found by the script reason 1

The script parses your project sources and checks if your keys are called within NSLocalizedString calls. But chances are you have a helper for a shorter NSLocalizedString syntax. This is indeed supported but you have to give the script what to look for.

You can modify the script to include other ways of localizations:

let patterns = [
    "NSLocalizedString\\(@?\"(\\w+)\"", // Swift and Objc Native
    "Localizations\\.((?:[A-Z]{1}[a-z]*[A-z]*)*(?:\\.[A-Z]{1}[a-z]*[A-z]*)*)", // Laurine Calls
    //Add your own matching regex here
    "fsLocalized\\(@?\"(\\w+)\""
]

Not found by the script reason 2

Another common pattern is to have keys being built at runtime. Of course thoses keys are not present at compile time so the script can't know about them and emits false positive errors. You can add those keys at the top of of the script to prevent this from happening:

let ignoredFromUnusedKeys = [
    "NotificationNoOne",
    "NotificationCommentPhoto",
    "NotificationCommentHisPhoto",
    "NotificationCommentHerPhoto"
]

Author

Sacha Durand Saint Omer, sachadso@gmail.com

Contributors

JuliusBahr, ezisazis

Contributing

Contributions to Localize are very welcomed and encouraged!

License

Localize is available under the MIT license. See LICENSE for more information.

Backers

Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site :)

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.