{"id":3129,"url":"https://github.com/JiriTrecak/Laurine","last_synced_at":"2025-08-03T13:31:57.655Z","repository":{"id":110031531,"uuid":"45915656","full_name":"JiriTrecak/Laurine","owner":"JiriTrecak","description":"Laurine - Localization code generator written in Swift. Sweet!","archived":false,"fork":false,"pushed_at":"2018-08-02T08:21:04.000Z","size":690,"stargazers_count":1254,"open_issues_count":9,"forks_count":77,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-11-29T04:43:00.000Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JiriTrecak.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-11-10T14:04:26.000Z","updated_at":"2024-10-06T21:44:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"f7b50124-51ba-48f5-9c7a-5b3dd571fb3f","html_url":"https://github.com/JiriTrecak/Laurine","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiriTrecak%2FLaurine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiriTrecak%2FLaurine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiriTrecak%2FLaurine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiriTrecak%2FLaurine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JiriTrecak","download_url":"https://codeload.github.com/JiriTrecak/Laurine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228548567,"owners_count":17935221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:16:32.209Z","updated_at":"2024-12-07T01:30:34.783Z","avatar_url":"https://github.com/JiriTrecak.png","language":"Swift","funding_links":[],"categories":["Tools","WebSocket","Swift"],"sub_categories":["Web View","Other free courses"],"readme":"\u003e Author's note: Thanks everyone for making Laurine the **TOP trending** Swift repository in the world - this is amazing and very heart-warming! But this is just the beginning. \n\n\u003e For the last few years, my team and I worked on a tool to **completely change mobile programming** - make it way **faster** and **more fun** for everyone - and we are nearly ready to release it to the world. If you are interested, **[head over to Product Hunt](https://www.producthunt.com/posts/supernova)** and check it out!\n\n\n[![Swift 3.2](https://img.shields.io/badge/Swift-3.2-orange.svg?style=flat)](https://developer.apple.com/swift/) [![Swift 4.0](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat)](https://developer.apple.com/swift/)\n[![Platforms OS X | iOS | tvos](https://img.shields.io/badge/Platforms-OS%20X%20%7C%20iOS-green.svg?style=flat)](https://developer.apple.com/swift/)\n[![License](http://img.shields.io/:License-MIT-green.svg)](http://doge.mit-license.org)\n[![Contact Me](http://img.shields.io/:Contact_Me-jiritrecak.com-blue.svg)](http://jiritrecak.com)\n\n\n# Laurine\n\n**Localization code generator** written (with love) for Swift, **intended to end the constant problems** that localizations present developers.\n\n\u003e Too tired to read? That is understandable. That is why I made this example. You will find it little bit different from what you usually see - [check it out](https://github.com/JiriTrecak/Laurine/tree/master/Example). Just download and run in Xcode.\n\n\n\u003e Latest version of laurine now supports Swift 3.2 / 4.0 and higher (XCode 9). Looking for version compatible with XCode 8? We have that as well - [switch to S3 branch](https://github.com/JiriTrecak/Laurine/tree/Swift-3.0). Looking for version compatible with Swift 2? Here you go - [switch to S2 branch](https://github.com/JiriTrecak/Laurine/tree/Swift-2.2).\n\n\n## Do I need it? (Yes, you do)\n\nLaurine is a clever Swift script that scans your localization file and generates structured, high-performance code out of it (in both ObjC or Swift, your call), thereby making the usage of localization strings much easier and safer. \n\nThe great thing is that by removing magical strings from your code, the compiler can actually tell you when you forget to make changes (and where), if your localization file changes. It also introduces type checking for strings that contain runtime format specifiers (`%@`, `%d` etc.). \n\nLaurine requires Swift to run and can be used from the command line as well as from a build script (recommended). Laurine uses [CommandLine](https://github.com/jatoben/CommandLine \"CommandLine Swift Tool\") to parse command line arguemnts: no extra configuration is needed.\n\n\n## What do I get?\n\nOnce you run Laurine, the output will be one .swift or .m file containing a `Localizations` structure / object. From this single access point, you will get access to all the sweetness:\n\n**Variables**\n\nFor each string that does not contain any special characters, a property is generated. For example:\n\n```swift\n\"PROFILE_PHONE_NUMBER\" = \"Your phone number!\"\n```\ncan be then used like this:\n\n```swift\nself.labelToLocalize.text = Localizations.ProfilePhoneNumber\n```\nin Xcode, autocomplete is actually, for once, really helpful! Madness.\n\n![Image : Xcode help for variables](https://github.com/JiriTrecak/Laurine/blob/master/Help/help-1.png?raw=true \"Xcode autocomplete\")\n\n**Methods**\n\nIf your localization string has runtime format specifiers, it is generated as a method instead. Laurine detects the format specifiers and generates a proper method header from that definition. There is no limit to how many of them you have. \n\nFor example:\n\n```swift\n\"PROFILE_INFO\" = \"I am %@, I am %d years old and %.2fm in height!\"\n```\ncan be then used like this:\n\n```swift\nself.labelToLocalize.text = Localizations.ProfileInfo(\"Jiri\", 25, 1.75)\n```\nOnce again, Xcode autocomplete for the win! Insanity.\n\n![Image : XCode help for methods](https://github.com/JiriTrecak/Laurine/blob/master/Help/help-2.png?raw=true \"Xcode autocomplete\")\n\n**Swift support**\n\n Swift-written application is recommended Laurine usecase. Internally, it uses nested structures to make your life much easier. Also, it is extremely performant and will have no impact on your current codebase.\n\n**ObjC support**\n\nObjective-C is supported from v0.2 as well. Because of the way the code is generated, you can write just the same code as you would in Swift, using dot notation to access each next element. For example:\n\n```objective-c\nNSString *text = Localizations.ProfileInfo(\"Jiri\", 25, 1.75)\n```\n\nThis produces exactly the same result as you would get in Swift and is recommended. \n\n## Nested Structures\n\nIt is best practice to make the keys as descriptive and structured as possible. Laurine takes advantage of that to generate nested structures rather than overly long key names. For example:\n\n```swift\n\"PROFILE-NAVIGATION_BAR-ITEMS-DONE\" = \"Done\" // -c -d -\n\"PROFILE.NAVIGATION_BAR.ITEMS.DONE\" = \"Done\" // -c -d .\n```\n\nIs actually converted to:\n\n```swift\nself.labelToLocalize.text = Localizations.Profile.NavigationBar.Items.Done\n```\n\nThis way, you can easily traverse through thousands of strings without even thinking about it (obviously, how you actually group your strings is up to you).\n\nYou can use `-d \"delimiter\"` option to specify which character you would like to use for nesting, defaults to `-` (slash). \n\nUse `_` (underscore) to make camel case strings (`MY_AWESOME_WORD` to `MyAwesomeKey`), or omit \"c\" option to disable this feature.\n\nNote: Language-specific keywords (such as Swift: `func` and ObjC: `YES`) and names starting with numbers (`Profile.1stButton`) will get prefixed with `_` to prevent build errors.\n\n\n## Usage\n\nLaurine uses script parameters to change the way how output is generated. Currently, the following is supported:\n\n```\n  -i, --input:     \n      Required | String | Path to the localization file\n  -o, --output:    \n      Optional | String | Path to output file (.swift or .m, depending on your configuration. If you are using ObjC, header will be created on that location. If ommited, output will be sent to stdout instead.\n  -l, --language:  \n      Optional | String | [swift | objc] | Specifies language of generated output files | Defaults to [swift]\n  -d, --delimiter: \n      Optional | String | String delimiter to separate segments of each string | Defaults to [.]\n  -c, --capitalize:\n      Optional | Bool | When enabled, name of all structures / methods / properties are automatically CamelCased | Defaults to false\n```\n\n\n**Command line**\n\nIf you wish to generate output just once, run following from terminal in the directory where you have the script downloaded:\n\n```\n$ swift LaurineGenerator.swift -i Localizable.strings -c -o Localizations.swift\nor for ObjC\n$ swift LaurineGenerator.swift -i Localizable.strings -c -o Localizations.m -l objc\n```\n\nor, alternatively, if you downloaded it through Brew:\n\n```\n$ LaurineGenerator.swift -i Localizable.strings -c -o Localizations.swift\nor for ObjC\n$ LaurineGenerator.swift -i Localizable.strings -c -o Localizations.m -l objc\n```\n\n\n**Build script**\n\nThe recommended way to use Laurine is to create a \"Run Script\" Build Phase (Xcode \u003e Project \u003e Targets \u003e Your build target \u003e Build Phases \u003e New Run Script Phase). This way, Laurine will be executed before each build and will ensure the integrity of your translations. Be sure to put the script before the \"Compile Sources\" phase, as it has to generate the code first, before it can be used anywhere else. For convenience, you can just copy the following, and change the configuration appropriately.\n\n```sh\n set -x\n \n # Get base path to project\n BASE_PATH=\"$PROJECT_DIR/$PROJECT_NAME\"\n \n #--------- START OF YOUR CONFIGURATION (change Path_To_.. to fit)\n \n # Get path to Laurine Generator script\n LAURINE_PATH=\"$BASE_PATH/Path_To_Generator/LaurineGenerator.swift\"\n \n # Get path to main localization file (usually english).\n SOURCE_PATH=\"$BASE_PATH/Path_To_Base_Localization/Localizable.strings\"\n \n # Get path to output. If you use ObjC version of output, set implementation file (.m), as header will be generated automatically\n OUTPUT_PATH=\"$BASE_PATH/Path_To_Output/Localizations.swift\"\n \n #--------- END OF YOUR CONFIGURATION\n \n # Add permission to generator for script execution\n chmod 755 \"$LAURINE_PATH\"\n \n # Actually generate output. -- CUSTOMIZE -- parameters to your needs (see documentation). \n # Will only re-generate script if something changed\n if [ \"$OUTPUT_PATH\" -ot \"$SOURCE_PATH\" ]; then\n    \"$LAURINE_PATH\" -i \"$SOURCE_PATH\" -o \"$OUTPUT_PATH\"\n fi\n\n```\n\n## Installation\n\n**Brew**\n\nLaurine does not require installation. For your convenience, you can make it easily accessible from ``/usr/local/bin`` by installing Laurine through brew:\n\n```\n$ brew tap jiritrecak/laurine\n$ brew install jiritrecak/laurine/laurine\n```\nNow you can just run it from everywhere:\n\n```\n$ LaurineGenerator.swift ...\n```\n\n**GIT**\n\nYou can also just clone it wherever you desire:\n\n```\n$ git clone https://github.com/JiriTrecak/Laurine.git\n$ sudo cp laurine.swift /usr/local/bin/laurine.swift\n```\n\n**Download!**\n\nYes, you can just download the script itself from this repository, it does not need anything else.\n\n## Supported Features\n\nLaurine should suit most of developers, because it covers all the basic stuff. That being said, there are still things missing to have full coverage of what localizations have to offer. Here is the full list of features that will Laurine contain once it is complete:\n\n- [x] Basic localization strings to variables\n- [x] Complex localization strings to methods\n- [x] Multilevel structures (nesting)\n- [x] Generate Swift output\n- [x] Generate ObjC output\n- [ ] Support for all special localization characters\n- [ ] Localization Tables\n- [ ] Plural support\n- [ ] Gender support\n- [ ] Tool for automatic replacement of NSLocalizationString in project (thanks [@Vaberer](https://github.com/Vaberer) )\n\n\n## Contribute\nI will gladly accept Pull Requests (and I encourage you to do so). If you encounter any bug or you have enhancement that you would like to see, please open an issue. Please make sure you target your PR against Development branch.\n\nI'd also like to make round of applause to Marcin Krzyżanowski for his [Natalie Generator](https://github.com/krzyzanowskim/Natalie), which heavily inspired this project by his approach. Hope we meet for beer one day!\n\n## More libraries, same awesomeness\n\nIf you liked it, check out my [other library - Warp](https://github.com/JiriTrecak/Warp \"Warp\"), that will help you with development of your data models. \n\n## Contact me\n\n\n- [@JiriTrecak](https://twitter.com/@JiriTrecak \"My twitter account\")\n- [jiritrecak@gmail.com](mailto:jiritrecak@gmail.com \"My email\") \n\nOr, if you would like to know me better, check out my portfolio.\n\n- [jiritrecak.com](http://jiritrecak.com/ \"My personal website\") \n\n\n##Licence\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Jiří Třečák\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJiriTrecak%2FLaurine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJiriTrecak%2FLaurine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJiriTrecak%2FLaurine/lists"}