{"id":1320,"url":"https://github.com/marmelroy/Localize-Swift","last_synced_at":"2025-08-06T13:32:54.418Z","repository":{"id":35949608,"uuid":"40238940","full_name":"marmelroy/Localize-Swift","owner":"marmelroy","description":"Swift friendly localization and i18n with in-app language switching","archived":false,"fork":false,"pushed_at":"2023-09-06T11:53:01.000Z","size":311,"stargazers_count":3081,"open_issues_count":78,"forks_count":330,"subscribers_count":41,"default_branch":"master","last_synced_at":"2024-12-05T05:04:27.551Z","etag":null,"topics":[],"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/marmelroy.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}},"created_at":"2015-08-05T10:19:09.000Z","updated_at":"2024-12-04T16:31:03.000Z","dependencies_parsed_at":"2022-07-08T13:00:38.999Z","dependency_job_id":"1e1b7dab-54d6-4331-846b-829c28642dbf","html_url":"https://github.com/marmelroy/Localize-Swift","commit_stats":{"total_commits":204,"total_committers":22,"mean_commits":9.272727272727273,"dds":"0.26960784313725494","last_synced_commit":"0aa221fed0512772eaad04171d966b8d77b15212"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelroy%2FLocalize-Swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelroy%2FLocalize-Swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelroy%2FLocalize-Swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelroy%2FLocalize-Swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marmelroy","download_url":"https://codeload.github.com/marmelroy/Localize-Swift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228905520,"owners_count":17989779,"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:15:43.746Z","updated_at":"2024-12-09T14:31:06.684Z","avatar_url":"https://github.com/marmelroy.png","language":"Swift","funding_links":[],"categories":["Localization","Libs","Swift","Localization [🔝](#readme)","iOS","多语言"],"sub_categories":["Other Hardware","Localization","Other free courses","Localize"],"readme":"[![Platform](https://img.shields.io/cocoapods/p/Localize-Swift.svg?maxAge=2592000)](http://cocoapods.org/?q=Localize-Swift)\n[![Version](http://img.shields.io/cocoapods/v/Localize-Swift.svg)](http://cocoapods.org/?q=Localize-Swift)\n[![Build Status](https://travis-ci.org/marmelroy/Localize-Swift.svg?branch=master)](https://travis-ci.org/marmelroy/Localize-Swift)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n# Localize-Swift\nLocalize-Swift is a simple framework that improves i18n and localization in Swift iOS apps - providing cleaner syntax and in-app language switching.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"http://i.imgur.com/vsrpqBt.gif\" width=\"242\" height=\"425\"/\u003e\u003c/p\u003e\n\n## Features\n\n- Keep the Localizable.strings file your app already uses.\n- Allow your users to change the app's language without changing their device language.\n- Use .localized() instead of NSLocalizedString(key,comment) - a more Swifty syntax.\n- Generate your strings with a new genstrings swift/python script that recognises .localized().\n\n## Usage\n\nImport Localize at the top of each Swift file that will contain localized text.\n\nIf CocoaPods -\n```swift\nimport Localize_Swift\n```\n\nAdd `.localized()` following any `String` object you want translated:\n```swift\ntextLabel.text = \"Hello World\".localized()\n```\n\nTo get an array of available localizations:\n```swift\nLocalize.availableLanguages()\n```\n\nTo change the current language:\n```swift\nLocalize.setCurrentLanguage(\"fr\")\n```\n\nTo update the UI in the view controller where a language change can take place, observe LCLLanguageChangeNotification:\n```swift\nNotificationCenter.default.addObserver(self, selector: #selector(setText), name: NSNotification.Name(LCLLanguageChangeNotification), object: nil)\n```\n\nTo reset back to the default app language:\n```swift\nLocalize.resetCurrentLanguageToDefault()\n```\n\n## genstrings\n\nTo support this new i18n syntax, Localize-Swift includes custom genstrings swift script.\n\nCopy the genstrings.swift file into your project's root folder and run with\n\n```bash\n./genstrings.swift\n```\n\nThis will print the collected strings in the terminal. Select and copy to your default Localizable.strings.\n\nThe script includes the ability to specify excluded directories and files (by editing the script).\n\n### [Preferrred] Setting up with [Swift Package Manager](https://swiftpm.co/?query=Localize-Swift)\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is now the preferred tool for distributing Localize-Swift. \n\nFrom Xcode 11+ :\n\n1. Select File \u003e Swift Packages \u003e Add Package Dependency. Enter `https://github.com/marmelroy/Localize-Swift.git` in the \"Choose Package Repository\" dialog.\n2. In the next page, specify the version resolving rule as \"Up to Next Major\" with \"3.2.0\".\n3. After Xcode checked out the source and resolving the version, you can choose the \"Localize-Swift\" library and add it to your app target.\n\nFor more info, read [Adding Package Dependencies to Your App](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) from Apple.\n\nAlternatively, you can also add Localize-Swift to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/marmelroy/Localize-Swift.git\", .upToNextMajor(from: \"3.2.0\"))\n]\n```\n\n### Setting up with Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate Localize-Swift into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"marmelroy/Localize-Swift\"\n```\n\n### Setting up with [CocoaPods](http://cocoapods.org/?q=Localize-Swift)\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\npod 'Localize-Swift', '~\u003e 3.2'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarmelroy%2FLocalize-Swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarmelroy%2FLocalize-Swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarmelroy%2FLocalize-Swift/lists"}