Swiftpack.co - AlexPinhasov/AutoLocalized as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by AlexPinhasov.
AlexPinhasov/AutoLocalized 1.03
A tool written in Swift to manage localization in your project and show errors and/or warnings when needed.
⭐️ 3
🕓 3 weeks ago
.package(url: "https://github.com/AlexPinhasov/AutoLocalized.git", from: "1.03")

A tool to manage localization in your project and show errors and/or warnings when needed.

Platform Author Swift

Behind the scenesInstallationAuthorLicense

AutoLocalized scans your project and search for your localization files and project files containing localized keys. By using Rules and Validation methods ensuring your keys and files are organized, clean, and always up to date with your work.

Behind the scenes

For every localization file found the following is executed:

  • Make sure each row has only 1 key and 1 value.
  • Sort by keys.
  • Validate no duplicate keys exist.
  • Validate all localization files keys match.
  • Validate all keys that are being used.

For every project file found the following is executed:

  • If a localization key is used in the file but missing from the localization files, show a warning for the dead key.


AutoLocalized is available through SPM (Swift Package Manager). To install it, simply follow the next steps.
  1. Add AutoLocalized as a dependecy using SPM:
    • File -> Swift Packages -> Add Package Dependency

  1. Create a "New Run Script Phase" under you target in "Build Phases" tab and copy the script below.

cd ~/Library/Developer/Xcode/DerivedData/${PROJECT_NAME}-*/SourcePackages/checkouts/AutoLocalized
swift run -c release AutoLocalized ${PROJECT_DIR}/${PROJECT_NAME}

  1. Build the project, in your project file you will find a ".autolocalized.yml" configuration file.
  • If you get an "error:invalid Access" error after building, just build agian it will go away. (SPM bug)

Configuration (.autolocalized.yml)

Configure AutoLocalized by adding a .autolocalized.yml file in your project file or building the project once, the framework can create a file when non is found. The following parameters can be configured:


  • extension to support
  • regex to search by keys
  • match_index what index in regex match to select

excluded: what directories to ignore

  • Path

disabledRules: what rules to ignore

  • duplicateValue
fileExtensions: # extensions to support (.swift, .xib...).
  - extension: swift
    regex: "(case|return|static let).*?\"([a-z|_]*?)\""
    match_index: 2
  - extension: xib
    regex: "(text|title|value|placeholder)=\"([a-z|_]*?)\""
    match_index: 2
  - extension: storyboard
    regex: "(text|title|value|placeholder)=\"([a-z|_]*?)\""
    match_index: 2
excluded: # paths to ignore.
  - Attribution/
  - Operations/
  - Localization/LocalizableProtocol
disabledRules: # ignore rules by specefing their names
  - duplicateValue

Disable Auto localized

If you only want to exclude a part of your code use

// autolocalized:disable
  {your code }
// autolocalized:enable


In your "Build report" in Xcode, you will see all the files that were found using your .autolocalized.yml configuration, separated by file type. In addition, you will see the number of keys in that files and the keys.


AlexPinhasov, alexp.software@gmail.com


AutoLocalized is available under the MIT license. See the LICENSE file for more info.


Stars: 3
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.


Release Notes

Change Rules error type
1 year ago

Change duplicateValue rule from error -> warning

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics