Fixed the plural string showing when it should show singular, and updated the README to document i18n
This commit is contained in:
parent
74d8d7c829
commit
5ccb7ec4ae
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |spec|
|
||||
spec.name = 'GHKit'
|
||||
spec.version = '0.0.2'
|
||||
spec.version = '0.0.3'
|
||||
spec.summary = 'GHKit framework for version checks using GitHub releases'
|
||||
spec.homepage = 'https://github.com/4np/GHKit'
|
||||
spec.license = { type: 'APACHE', file: 'LICENSE' }
|
||||
|
|
15
README.md
15
README.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
[](https://travis-ci.org/4np/GHKit)
|
||||
[](https://github.com/4np/GHKit/releases/latest)
|
||||
[](https://github.com/4np/GHKit/commits/master)
|
||||
[](https://github.com/4np/GHKit/commits/master)
|
||||
[](https://developer.apple.com/tvos/)
|
||||
[](https://swift.org)
|
||||
[](https://github.com/4np/GHKit/issues)
|
||||
|
@ -29,7 +29,7 @@ pod 'NPOKit', :git => 'https://github.com/4np/GHKit.git'
|
|||
Add the following entry to your package's dependencies:
|
||||
|
||||
```swift
|
||||
.package(url: "https://github.com/4np/GHKit.git", from: "0.0.2")
|
||||
.package(url: "https://github.com/4np/GHKit.git", from: "0.0.3")
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
@ -82,6 +82,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
|
||||
In order you test, you could change the interval to 10 seconds (`TimeInterval(exactly: 10)`)
|
||||
|
||||
## Internationalization / i18n
|
||||
|
||||
Add the following strings to your `Localizable.strings` file(s):
|
||||
|
||||
```
|
||||
/* GHKit - release alerts */
|
||||
"New release available" = "New release available";
|
||||
"You are %i releases behind" = "You are %i releases behind";
|
||||
"Version '%@' is available for download at '%@'.\n\n%@" = "Version '%@' is available for download at '%@'.\n\n%@";
|
||||
```
|
||||
|
||||
## How does it work?
|
||||
|
||||
`GHKit` will [Swizzle](http://nshipster.com/method-swizzling/) `UIViewController`'s `viewDidLoad` method to check for new releases _if_ the interval has passed. It uses the application bundle's version to check against the available GitHub releases and notify the end user if a new version is available. _Note that `GHKit` only reports that a new release is available; it does not download or install anything!_
|
||||
|
|
|
@ -55,7 +55,7 @@ extension UIViewController {
|
|||
// i18n
|
||||
let singularTitle = "New release available".localized(withComment: "New release alert title (singular)")
|
||||
let pluralTitleFormat = "You are %i releases behind".localized(withComment: "New release alert title (plural)")
|
||||
let title = (count > 0) ? String.localizedStringWithFormat(pluralTitleFormat, count) : singularTitle
|
||||
let title = (count > 1) ? String.localizedStringWithFormat(pluralTitleFormat, count) : singularTitle
|
||||
let messageFormat = "Version '%@' is available for download at '%@'.\n\n%@".localized(withComment: "New release alert message")
|
||||
let message = String.localizedStringWithFormat(messageFormat, version, release.url.absoluteString, release.body)
|
||||
|
||||
|
|
Loading…
Reference in New Issue