Site icon TechHype.io

LocalizableChecker – A Swift CLI to check Localizable.strings

A Swift CLI to check if keys from a Localizable.strings file are unused in your project.

When you’re building a translated app, you create a lot of translation keys and values. Sometimes you remove some code but you forget to remove matched translation keys. Your translation file is getting longer and you lose time to translate keys that are not yet used in your app.

This tool is for you! It will print every key from a Localizable.strings file (or any .strings file) that are not used in your app.

And, it can also log if a key has an empty value, such as "mv.help.text" = "";.

Usage

Installation

$ git clone https://github.com/Jonathan-Gander/LocalizableChecker
$ cd LocalizableChecker

Arguments and options

There are 3 mandatory arguments:

And 3 options:

Run

Examples:

# Search in all files. And have probably 2 Localizable.strings files.
$ swift run LocalizableChecker "/Users/user/Projects/myproject/myproject/Resources/en.lproj/Localizable.strings" "/Users/user/Projects/myproject" 2

# Search in files with .swift extensions only.
$ swift run LocalizableChecker "/Users/user/Projects/myproject/myproject/Resources/en.lproj/Localizable.strings" "/Users/user/Projects/myproject" 0 --extensions swift

# Search in files with .swift extensions only. Also log empty values.
$ swift run LocalizableChecker "/Users/user/Projects/myproject/myproject/Resources/en.lproj/Localizable.strings" "/Users/user/Projects/myproject" 0 --extensions swift --log-empty-values

Output

Typical output log:

👋 Welcome in LocalizableChecker
This tool will check if keys from a Localizable.strings file are unused in your project.
Created by Jonathan Gander
--------------------------------------------------------

Will check keys from file...
    /Users/user/Projects/myproject/myproject/Resources/en.lproj/Localizable.strings
in files with extension swift from directory...
    /Users/user/Projects/myproject

ℹ️ Empty values will be logged.

🚀 running ...
(It may take quite long! If you see nothing and it makes you anxious, try setting anxiousMode to true.)

🛑 key '"mpv.position"' is unused (found 0 time).
⚠️ warning, key '"mv.help.text"' has an empty value.
🛑 key '"wv.title"' is unused (found 0 time).

🎉 finished!
LocalizableChecker on GitHub: https://github.com/Jonathan-Gander/LocalizableChecker
Platform: iOS
⭐️: 12
Exit mobile version