Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freshos/localize
🏁 Automatically clean your Localizable.strings files
https://github.com/freshos/localize
cleanup freshos ios localisation script swift translation xcode
Last synced: 3 days ago
JSON representation
🏁 Automatically clean your Localizable.strings files
- Host: GitHub
- URL: https://github.com/freshos/localize
- Owner: freshOS
- License: mit
- Created: 2016-12-10T09:19:38.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-31T11:59:16.000Z (over 1 year ago)
- Last Synced: 2024-12-18T15:23:48.558Z (8 days ago)
- Topics: cleanup, freshos, ios, localisation, script, swift, translation, xcode
- Language: Swift
- Homepage:
- Size: 200 KB
- Stars: 356
- Watchers: 10
- Forks: 30
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![Localize](https://raw.githubusercontent.com/s4cha/Localize/master/banner.png)
# Localize
[![Language: Swift](https://img.shields.io/badge/language-swift-f48041.svg?style=flat)](https://developer.apple.com/swift)
![Platform: iOS](https://img.shields.io/badge/platform-iOS-blue.svg?style=flat)
[![codebeat badge](https://codebeat.co/badges/1eefc440-01e1-4408-bc92-1b8eeab9796c)](https://codebeat.co/projects/github-com-freshos-localize-master)
[![License: MIT](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/s4cha/Localize/blob/master/LICENSE)
[![Release version](https://img.shields.io/badge/release-0.1-blue.svg)]()*Localize* is a tiny run script that keeps your `Localizable.strings` files clean and emits warnings when something is suspicious.
![Localize](https://raw.githubusercontent.com/s4cha/Localize/master/xcodeScreenshot.png)
Because **Localization** files tend to **rot over time** and become a hassle to work with. **Stressful** when you have to test your app against many different Localizations.
## Try it!
Localize is part of [freshOS](https://freshos.github.io/) iOS toolset. Try it out in the included example app!
## How
By using a **script** running automatically, you have a **safety net** keeping them **sane**, checking for **translation issues** and preventing then to **rot over time.**## What
Automatically (On build)
- [x] **Cleans** you localization files (removes spaces)
- [x] **Sorts** keys Alphabetically
- [x] Checks for **Unused Keys**
- [x] Checks for **Missing Keys**
- [x] Checks for **Untranslated** (which you can ignore with a flag)
- [x] Checks for **Redundant Keys**
- [x] Checks for **Duplicate Keys**## Installation
Add the following `Run Script` in your project's `Build Phases` in XCode, this will run the script at every build.
Use the path of where you copied `Localize.swift` script.```shell
${SRCROOT}/{REPLACE ME}} # e.g. ${SRCROOT}/Libs/Localize.swift
```
Run and Enjoy \o/## Configuration
Configure the top section of the `Localize.swift` according to your project.## More
### Ignore [Potentially Untranslated] warnings
Just Add `//ignore-same-translation-warning` next to the translation.
Example :
```
"PhotoKey" = "Photo"; //ignore-same-translation-warning
```
This will take care of ignoring `[Potentially Untranslated] "XXX" in FR file doesn't seem to be localized`### Unused false positive
#### Not found by the script reason 1
The script parses your project sources and checks if your keys are called within `NSLocalizedString` calls.
But chances are you have a helper for a shorter NSLocalizedString syntax.
This is indeed supported but you have to give the script what to look for.You can modify the script to include other ways of localizations:
```swift
let patterns = [
"NSLocalizedString\\(@?\"(\\w+)\"", // Swift and Objc Native
"Localizations\\.((?:[A-Z]{1}[a-z]*[A-z]*)*(?:\\.[A-Z]{1}[a-z]*[A-z]*)*)", // Laurine Calls
//Add your own matching regex here
"fsLocalized\\(@?\"(\\w+)\""
]
```#### Not found by the script reason 2
Another common pattern is to have keys being built at runtime.
Of course those keys are not present at compile time so the script can't know about them and emits false positive errors.
You can add those keys at the top of of the script to prevent this from happening:```swift
let ignoredFromUnusedKeys = [
"NotificationNoOne",
"NotificationCommentPhoto",
"NotificationCommentHisPhoto",
"NotificationCommentHerPhoto"
]
```## Author
Sacha Durand Saint Omer, [email protected]
## Contributors
[JuliusBahr](https://github.com/JuliusBahr), [ezisazis](https://github.com/ezisazis/), [michalsrutek](https://github.com/michalsrutek/)## Contributing
Contributions to Localize are very welcomed and encouraged!
## License
Localize is available under the MIT license. See [LICENSE](https://github.com/s4cha/Localize/blob/master/LICENSE) for more information.
# Backers
Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)### Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site :)