From 5ccb7ec4ae980b17d0b4758918d131b03724273c Mon Sep 17 00:00:00 2001 From: Jeroen Wesbeek Date: Fri, 9 Feb 2018 12:03:48 +0100 Subject: [PATCH] Fixed the plural string showing when it should show singular, and updated the README to document i18n --- GHKit.podspec | 2 +- README.md | 15 +++++++++++++-- .../Extensions/UIViewController+Releases.swift | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/GHKit.podspec b/GHKit.podspec index 9f5f7a0..11c86e5 100644 --- a/GHKit.podspec +++ b/GHKit.podspec @@ -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' } diff --git a/README.md b/README.md index ec1206f..228f315 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/4np/GHKit.svg?branch=master)](https://travis-ci.org/4np/GHKit) [![Release](https://img.shields.io/github/release/4np/GHKit.svg)](https://github.com/4np/GHKit/releases/latest) -[![Commits Since](https://img.shields.io/github/commits-since/4np/GHKit/0.0.2.svg?maxAge=3600)](https://github.com/4np/GHKit/commits/master) +[![Commits Since](https://img.shields.io/github/commits-since/4np/GHKit/0.0.3.svg?maxAge=3600)](https://github.com/4np/GHKit/commits/master) [![Platform](https://img.shields.io/badge/platform-tvOS%2011-green.svg?maxAge=3600)](https://developer.apple.com/tvos/) [![Swift](https://img.shields.io/badge/language-Swift-ed523f.svg?maxAge=3600)](https://swift.org) [![Open Issues](https://img.shields.io/github/issues/4np/GHKit.svg?maxAge=3600)](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!_ diff --git a/Sources/GHKit/Extensions/UIViewController+Releases.swift b/Sources/GHKit/Extensions/UIViewController+Releases.swift index be25ea2..91bab3e 100644 --- a/Sources/GHKit/Extensions/UIViewController+Releases.swift +++ b/Sources/GHKit/Extensions/UIViewController+Releases.swift @@ -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)