{"id":2025,"url":"https://github.com/T-Pham/NoOptionalInterpolation","last_synced_at":"2025-08-02T05:33:28.667Z","repository":{"id":62449068,"uuid":"59821792","full_name":"T-Pham/NoOptionalInterpolation","owner":"T-Pham","description":"✍️ No \"Optional(...)\" in string interpolation + Easy pluralization","archived":false,"fork":false,"pushed_at":"2017-10-24T09:02:25.000Z","size":77,"stargazers_count":51,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-13T05:22:44.285Z","etag":null,"topics":["cartfile","carthage","cocoapods","ios","optional","osx","plural-form","pluralization","podfile","quantity","string-interpolation","swift","tvos","watchos"],"latest_commit_sha":null,"homepage":"","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/T-Pham.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}},"created_at":"2016-05-27T09:14:18.000Z","updated_at":"2023-04-24T05:09:21.000Z","dependencies_parsed_at":"2022-11-01T23:17:06.503Z","dependency_job_id":null,"html_url":"https://github.com/T-Pham/NoOptionalInterpolation","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/T-Pham/NoOptionalInterpolation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Pham%2FNoOptionalInterpolation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Pham%2FNoOptionalInterpolation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Pham%2FNoOptionalInterpolation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Pham%2FNoOptionalInterpolation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/T-Pham","download_url":"https://codeload.github.com/T-Pham/NoOptionalInterpolation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Pham%2FNoOptionalInterpolation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268339405,"owners_count":24234544,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cartfile","carthage","cocoapods","ios","optional","osx","plural-form","pluralization","podfile","quantity","string-interpolation","swift","tvos","watchos"],"created_at":"2024-01-05T20:16:01.539Z","updated_at":"2025-08-02T05:33:28.438Z","avatar_url":"https://github.com/T-Pham.png","language":"Swift","funding_links":[],"categories":["Libs","UI","Text","Localization [🔝](#readme)"],"sub_categories":["Localization","Layout","Other free courses","Other Testing","Keychain"],"readme":"```\n'   ____    ___                                                                             \n'  |    \\  /   \\                                                                            \n'  |  _  ||     |                                                                           \n'  |  |  ||  O  |                                                                           \n'  |  |  ||     |                                                                           \n'  |  |  ||     |                                                                           \n'  |__|__| \\___/                                                                            \n'                                                                                           \n'    ___   ____  ______  ____  ___   ____    ____  _                                        \n'   /   \\ |    \\|      ||    |/   \\ |    \\  /    || |                                       \n'  |     ||  o  )      | |  ||     ||  _  ||  o  || |                                       \n'  |  O  ||   _/|_|  |_| |  ||  O  ||  |  ||     || |___                                    \n'  |     ||  |    |  |   |  ||     ||  |  ||  _  ||     |                                   \n'  |     ||  |    |  |   |  ||     ||  |  ||  |  ||     |                                   \n'   \\___/ |__|    |__|  |____|\\___/ |__|__||__|__||_____|                                   \n'                                                                                           \n'   ____  ____   ______    ___  ____   ____   ___   _       ____  ______  ____  ___   ____  \n'  |    ||    \\ |      |  /  _]|    \\ |    \\ /   \\ | |     /    ||      ||    |/   \\ |    \\ \n'   |  | |  _  ||      | /  [_ |  D  )|  o  )     || |    |  o  ||      | |  ||     ||  _  |\n'   |  | |  |  ||_|  |_||    _]|    / |   _/|  O  || |___ |     ||_|  |_| |  ||  O  ||  |  |\n'   |  | |  |  |  |  |  |   [_ |    \\ |  |  |     ||     ||  _  |  |  |   |  ||     ||  |  |\n'   |  | |  |  |  |  |  |     ||  .  \\|  |  |     ||     ||  |  |  |  |   |  ||     ||  |  |\n'  |____||__|__|  |__|  |_____||__|\\_||__|   \\___/ |_____||__|__|  |__|  |____|\\___/ |__|__|\n'\n```\n\n# NoOptionalInterpolation\n\n[![CI Status](https://img.shields.io/travis/T-Pham/NoOptionalInterpolation/master.svg?style=flat-square)](https://travis-ci.org/T-Pham/NoOptionalInterpolation)\n[![GitHub issues](https://img.shields.io/github/issues/T-Pham/NoOptionalInterpolation.svg?style=flat-square)](https://github.com/T-Pham/NoOptionalInterpolation/issues)\n[![Codecov](https://img.shields.io/codecov/c/github/T-Pham/NoOptionalInterpolation.svg?style=flat-square)](https://codecov.io/gh/T-Pham/NoOptionalInterpolation)\n[![Documentation](https://img.shields.io/cocoapods/metrics/doc-percent/NoOptionalInterpolation.svg?style=flat-square)](http://cocoadocs.org/docsets/NoOptionalInterpolation)\n\n[![GitHub release](https://img.shields.io/github/tag/T-Pham/NoOptionalInterpolation.svg?style=flat-square\u0026label=release)](https://github.com/T-Pham/NoOptionalInterpolation/releases)\n[![Platform](https://img.shields.io/cocoapods/p/NoOptionalInterpolation.svg?style=flat-square)](https://github.com/T-Pham/NoOptionalInterpolation)\n[![License](https://img.shields.io/cocoapods/l/NoOptionalInterpolation.svg?style=flat-square)](LICENSE)\n\n[![Carthage](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat-square)](https://github.com/Carthage/Carthage)\n\n[![CocoaPods](https://img.shields.io/badge/CocoaPods-compatible-4BC51D.svg?style=flat-square)](https://cocoapods.org/pods/NoOptionalInterpolation)\n[![CocoaPods downloads](https://img.shields.io/cocoapods/dt/NoOptionalInterpolation.svg?style=flat-square)](https://cocoapods.org/pods/NoOptionalInterpolation)\n\n## Description\n\nNoOptionalInterpolation gets rid of \"Optional(...)\" and \"nil\" in Swift's string interpolation. This is particularly helpful when you set text to UI elements such as `UILabel` or `UIButton`. Since XCode currently, as of the time this is written, does not show any warnings when interpolating `Optional`s, and you might sometimes need to change your variables' type between `Optional` and non-`Optional`, this library ensures that the text you set never ever includes that annoying additional \"Optional(...)\". You can also revert to the default behavior when needed.\n\nBesides, the library makes pluralizing your text easier with custom operators.\n\n## Usage\n\n### Remove \"Optional(...)\" and \"nil\":\n\nJust import NoOptionalInterpolation and everything is done for you.\n\n```swift\nimport NoOptionalInterpolation\n\nlet n: Int? = 1\nlet t: String? = nil\nlet s: String? = \"string1\"\nlet o: String?? = \"string2\"\n\nlet i = \"\\(n) \\(t) \\(s) \\(o)\"\nprint(i) // 1  string1 string2\n```\n\nAlso, please note that this does not affect the `print` function. Hence, `print(o)` (as opposed to `print(\"\\(o)\")`, `o` as in the example above) would still print out `Optional(Optional(\"string2\"))`.\n\n### Revert to the default behavior:\n\nUse the `*` operator for your `Optional`s.\n\n```swift\n...\nlet i = \"\\(n*) \\(t*) \\(s*) \\(o*)\"\nprint(i) // Optional(1) nil Optional(\"string1\") Optional(Optional(\"string2\"))\n```\n\n### Pluralization:\n\nUse the `~` operator to pluralize words.\n\n```swift\nlet age = 42\nlet text = \"I am \\(age ~ \"year\") old\" // \"I am 42 years old\" // actually not // for now\n```\n\nUse the `/` operator to provide the plural form.\n\n```swift\nlet memberCount = 42\nlet text = \"The team consists of \\(memberCount ~ \"person\" / \"people\")\" // \"The team consists of 42 people\"\n```\n\nTo omit the quantity, swap the position of the quantity and the word.\n\n```swift\nlet listenerCount = 42\nlet text = \"Do it \\(\"yourself\" / \"yourselves\" ~ listenerCount)\" // \"Do it yourselves\"\n```\n\nIt also works with `Optional`s.\n\n```swift\nlet count: Int?? = 42\nlet fruit: String?? = \"apple\"\nlet text = \"I have \\(count ~ fruit)\" // \"I have 42 apples\"\n```\n\nBy default, if you don't provide a plural form using the `/` operator, an \"s\" is appended to your word to make the plural form. To make the pluralization smarter, you can specify a custom `PluralizerType`. You can find one [here](https://github.com/joshualat/Pluralize.swift).\n\nIn your Podfile:\n\n```ruby\npod 'Pluralize.swift', :git =\u003e \"https://github.com/joshualat/Pluralize.swift.git\"\n```\n\nNOTE: `Pluralize.swift` pod is not yet compatible with Swift 3.\n\nThen:\n\n```swift\nimport NoOptionalInterpolation\nimport Pluralize_swift\n\nextension Pluralize: NoOptionalInterpolation.Pluralizer {}\n\n...\nNoOptionalInterpolation.PluralizerType = Pluralize.self\nassert(42 ~ \"oasis\" == \"42 oases\")\n```\n\n## Installation\n\n### [Carthage](https://github.com/Carthage/Carthage)\n\nAdd the line below to your Cartfile:\n\n```ruby\ngithub \"T-Pham/NoOptionalInterpolation\"\n```\n\n### [CocoaPods](https://cocoapods.org/pods/NoOptionalInterpolation)\n\nAdd the line below to your Podfile:\n\n```ruby\npod 'NoOptionalInterpolation'\n```\n\n### [Manually](https://google.com)\n\nAdd all the files in [`/NoOptionalInterpolation/Classes/`](/NoOptionalInterpolation/Classes/) to your project. You are all set.\n\n## Compatibility\nFrom version 3.0.0, Swift 3 syntax is used. If your project is still using earlier versions of Swift, please use a NoOptionalInterpolation version prior to 3.0.0.\n\nPodfile\n\n```ruby\npod 'NoOptionalInterpolation', '~\u003e 2.0.6'\n```\n\nor Cartfile\n\n```ruby\ngithub \"T-Pham/NoOptionalInterpolation\" ~\u003e 2.0.6\n```\n\n## License\n\nNoOptionalInterpolation is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FT-Pham%2FNoOptionalInterpolation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FT-Pham%2FNoOptionalInterpolation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FT-Pham%2FNoOptionalInterpolation/lists"}