Behind the scenes • Installation • Author • License
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.
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.
- Add AutoLocalized as a dependecy using SPM:
- File -> Swift Packages -> Add Package Dependency
- Create a "New Run Script Phase" under you target in "Build Phases" tab and copy the script below.
SDKROOT=macosx
cd ~/Library/Developer/Xcode/DerivedData/${PROJECT_NAME}-*/SourcePackages/checkouts/AutoLocalized
swift run -c release AutoLocalized ${PROJECT_DIR}/${PROJECT_NAME}
- 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)
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:
fileExtensions:
- 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
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.