Command line tool to get strong typed, autocompleted localized strings in Swift, inspired by R.swift.
After installing L.swift into your project you can use the L-struct to access localized strings. If the struct is outdated just build and L.swift will correct any missing/changed/added resources.
L.swift supports dot-separated keys.
Key | L.swift |
---|---|
"One" |
L.one (return NSLocalizedString("One", comment: "") |
"One.Two" |
L.One.two (return NSLocalizedString("One.Two", comment: "") |
"One.Two.Three" |
L.One.Two.three (return NSLocalizedString("One.Two.Three", comment: "") |
- Add
pod 'L.swift'
to your Podfile and runpod install
- In XCode: Click on your project in the file list, choose your target under
TARGETS
, click theBuild Phases
tab and add aNew Run Script Phase
by clicking the little plus icon in the top left - Drag the new
Run Script
phase above theCompile Sources
phase and belowCheck Pods Manifest.lock
, expand it and paste the following script:"$PODS_ROOT/L.swift/lswift" "$SRCROOT"
- Build your project, in Finder you will now see a
L.generated.swift
in the $SRCROOT-folder, drag theL.generated.swift
file into your project and uncheckCopy items if needed
L.swift is owned and maintained by RECRUIT LIFESTYLE CO., LTD.
L.swift was originally created by Yuki Nagai.
The MIT License (MIT)
Copyright (c) 2015 RECRUIT LIFESTYLE CO., LTD.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.