{"id":15293583,"url":"https://github.com/sgr-ksmt/i18nswift","last_synced_at":"2026-03-06T12:34:00.783Z","repository":{"id":56932164,"uuid":"86208841","full_name":"sgr-ksmt/i18nSwift","owner":"sgr-ksmt","description":"i18n for Swift","archived":false,"fork":false,"pushed_at":"2020-03-25T04:11:05.000Z","size":225,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T14:07:39.953Z","etag":null,"topics":["carthage","cocoapods","currency","framework","i18n","localization","swift","swift-library","swift3"],"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/sgr-ksmt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"sgr-ksmt"}},"created_at":"2017-03-26T05:01:23.000Z","updated_at":"2020-03-25T04:11:08.000Z","dependencies_parsed_at":"2022-08-21T05:50:33.003Z","dependency_job_id":null,"html_url":"https://github.com/sgr-ksmt/i18nSwift","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgr-ksmt%2Fi18nSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgr-ksmt%2Fi18nSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgr-ksmt%2Fi18nSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgr-ksmt%2Fi18nSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgr-ksmt","download_url":"https://codeload.github.com/sgr-ksmt/i18nSwift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724636,"owners_count":21151561,"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":["carthage","cocoapods","currency","framework","i18n","localization","swift","swift-library","swift3"],"created_at":"2024-09-30T16:50:03.996Z","updated_at":"2026-03-06T12:34:00.727Z","avatar_url":"https://github.com/sgr-ksmt.png","language":"Swift","funding_links":["https://github.com/sponsors/sgr-ksmt"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"/logo.png\" alt=\"logo\" width=\"600\" /\u003e  \n\u003c/p\u003e\n\ni18n for Swift.  \n\n\n[![Build Status](https://travis-ci.org/sgr-ksmt/i18nSwift.svg?branch=master)](https://travis-ci.org/sgr-ksmt/i18nSwift)\n[![GitHub release](https://img.shields.io/github/release/sgr-ksmt/i18nSwift.svg)](https://github.com/sgr-ksmt/i18nSwift/releases)\n![Language](https://img.shields.io/badge/language-Swift%203-orange.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods](https://img.shields.io/badge/Cocoa%20Pods-✓-4BC51D.svg?style=flat)](https://cocoapods.org/pods/i18nSwift)\n[![CocoaPodsDL](https://img.shields.io/cocoapods/dt/i18nSwift.svg)](https://cocoapods.org/pods/i18nSwift)\n[![codecov](https://codecov.io/gh/sgr-ksmt/i18nSwift/branch/master/graph/badge.svg)](https://codecov.io/gh/sgr-ksmt/i18nSwift)\n\n\n```swift\n\"order_view_title\" = \"Order\"\n\"order_view_button\" = \"Order (price: %@)\"\n==========================\n\n// \"Order\"\ntitleLabel.text = NSLocalizedString(\"order_view_title\", comment: \"\")\n// \"Order (price: USD100.00)\"\nlet price = \"$100.00\"\nlet buttonTitle = String(format: NSLocalizedString(\"order_view_button\", comment: \"\"), arguments: price)\norderButton.setTitle(buttonTitle, for: .normal)\n\n\n⬇️⬇️⬇️\n\n// \"Order\"\ntitleLabel.text = i18n.t(.orderViewTitle)\n// \"Order (price: USD100.00)\"\norderButton.setTitle(i18n.t(.orderViewButton, args: i18n.currencyISO(100)), for: .normal)\n```\n\n\n## Features\n\n- Swifty handling\n- Localization\n  - **Safety**,\n  - **Static typing**\n  - Change language without switching system language setting.\n- Currency (convert number into currency using locale)\n- Tested perfectly.\n\n### TODO\n- [ ] Number\n- [ ] Date\n- [ ] Pluralization\n\n## Requirements\n- Swift 3.x\n- Xcode 8.x\n- iOS 9.0 or later\n\n## Usage\n\n### Localization\n\n- **Create `Localizable.strings`**\n\n```swift\n\"hello_world\" = \"Hello, world!\";\n\"total_count\" = \"Total: %d\";\n```\n\nAdd `Localizable.strings` in your project and define keys and values.\n\n- **Define `LocalizedString`**\n\n```swift\nextension i18n.LocalizedString {\n    static let helloWorld: i18n.LocalizedString = \"hello_world\"\n    static let totalCount: i18n.LocalizedString = \"total_count\"\n    // or\n    static let helloWorld = i18n.LocalizedString(rawValue: \"hello_world\")\n}\n```\n\nAdd `LocalizedString`'s static variable as extension of `i18n.LocalizedString`.  \nIt's similar to `Notification.Name`. :heart:\n\n```swift\nextension Notification.Name {\n    static let fooDidUpdate = Notification.Name(rawValue: \"FooDidUpdate\")\n}\n```\n\n\n- **localize with `i18n`**\n\n```swift\nlet message = i18n.t(.helloWorld)\nprint(message) // \"Hello, world!\n\n// localize and embed paramter(s)\nlet total = i18n.t(.totalCount, args: 100)\nprint(total) // \"Total: 100\"\n```\n\n**Tips** Add `args:` label and parameter(s) if you can embed arguments in localized string.\n\n## Language\n**i18nSwift** equips function of changing the language in appllication.  \nIf you change the language, result of localization will change.\n\n```swift\n// en\n\"greeting\" = \"Hello!\";\n// fr\n\"greeting\" = \"Bonjour!\";\n```\n\n```swift\n// system language is \"en\"\nprint(i18n.t(.greeting)) // \"Hello!\"\n\n// Change language to \"fr\"\ni18n.Language.current = \"fr\"\nprint(i18n.t(.greeting)) // \"Bonjour!\"\n\n// ===================\n// Reboot application!!\n// ===================\n\n// `Language.current` is being stored.\nprint(i18n.t(.greeting)) // \"Bonjour!\"\n\n// Reset to system language\ni18n.Language.reset()\n\n// change temporary in localization\nprint(i18n.t(.greeting, \"fr\")) // \"Bonjour!\"\n```\n\n**Tips** : `i18n.Language.current` is saved in UserDefaults using `i18n.Language.Constant.currentLanguageKey`\n\n### Currency\n**i18nSwift** converts number into localized currency.\n\n```swift\n// default is `Locale.current`\n\nprint(i18n.currency(100)) // $100.00\nprint(i18n.currency(100, Locale(identifier: \"ja_JP\"))) // ¥100\nprint(i18n.currency(100, fractionDigits: (4, 4))) // $100.0000\nprint(i18n.currencyISO(100)) // USD100.00\n```\n\n## Installation\n\n### Carthage\n\n- Add the following to your *Cartfile*:\n\n```bash\ngithub \"sgr-ksmt/i18nSwift\" ~\u003e 0.3\n```\n\n- Run `carthage update`\n- Add the framework as described.\n\u003cbr\u003e Details: [Carthage Readme](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application)\n\n\n### CocoaPods\n\n**i18nSwift** is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'i18nSwift', '~\u003e 0.3'\n```\n\nand run `pod install`\n\n### Manually Install\nDownload all `*.swift` files and put your project.\n\n## Change log\nChange log is [here](https://github.com/sgr-ksmt/i18nSwift/blob/master/CHANGELOG.md).\n\n## Communication\n- If you found a bug, open an issue.\n- If you have a feature request, open an issue.\n- If you want to contribute, submit a pull request.:muscle:\n\n## License\n\n**i18nSwift** is under MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgr-ksmt%2Fi18nswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgr-ksmt%2Fi18nswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgr-ksmt%2Fi18nswift/lists"}