Localinter
Check localizable files for Swift
Script can
- Checking the localizable file from masterLanguageCode and find missing keys in other localizable files
- Searching potentially untranslated keys from localizable files
- Checking duplicate keys from localizable files
- Checking unused keys from localizable files
Install
- Just copy Localinter.swift to project.
- Exclude from “Build Phases” -> “Compile Sources”
- Add to “Build Phases” run script:
${SRCROOT}/Localinter.swift
Setup:
/// It language will come as general and ideal
let masterLanguageCode = "en"
/// Path of folder with localizations files. For example "/YouProject/Resources/Languages"
let relativeLocalizablePath = ""
/// Path of the source folder which will used in searching for localization keys you actually use in your project. For Example "/YouProject/Source"
let relativeSourcePath = "/Strings/Src"
/// yuo can use many types
let usingTypes: [UsingType] = [
.swiftGen(enumName: "Strings")
]
/**
If you want to exclude unused keys from checking, yuo can define they this
Example:
let ignoredUnusedKeys = [
"CFBundleDisplayName",
"NSCameraUsageDescription"
]
*/
let ignoredUnusedKeys: Set<String> = [
"CFBundleDisplayName",
"NSCameraUsageDescription"
]
/// If you want to exclude untranslated keys from checking, you can define they this
let ignoredUntranslatedKeys: Set<String> = [
]
let isThrowingErrorForUntranslated = true
let isThrowingErrorForUnused = true
let isClearWhitespasesInLocalizableFiles = false
let isOnlyOneLanguage = false
/// Cleaning localizable files. Will remove comments, empty lines and order your keys by alphabetical.
let isCleaningFiles = false