Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
martindaum committed Sep 2, 2020
1 parent a4355a4 commit 31e6bc3
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 29 deletions.
Binary file added .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## [1.0.0] - 2020-09-02
### Added
- Initial release

29 changes: 0 additions & 29 deletions LICENSE

This file was deleted.

11 changes: 11 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright (c) 2020 lingohub GmbH

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3 changes: 3 additions & 0 deletions LingoHub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"1.0.0": "https://github.com/lingohub/ios-sdk/releases/download/1.0.0/LingoHub.framework.zip"
}
18 changes: 18 additions & 0 deletions LingoHub.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Pod::Spec.new do |spec|
spec.name = 'LingoHub'
spec.version = '1.0.0'
spec.summary = 'LingoHub iOS SDK for OTA localization updates'
spec.homepage = 'https://lingohub.com'
spec.author = { 'LingoHub Team' => '[email protected]' }
spec.source = { :http => "https://github.com/lingohub/ios-sdk/releases/download/1.0.0/LingoHub.xcframework.zip" }
spec.license = { :type => "BSD-3-Clause", :file => 'Frameworks/LICENSE.md' }

spec.cocoapods_version = '>= 1.9.1'

spec.ios.deployment_target = '9.0'
spec.watchos.deployment_target = '2.0'
spec.tvos.deployment_target = '9.0'
spec.osx.deployment_target = '10.11'

spec.vendored_frameworks = "Frameworks/LingoHub.xcframework"
end
27 changes: 27 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// swift-tools-version:5.3
import PackageDescription

let package = Package(
name: "LingoHub",
platforms: [
.macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "LingoHub",
targets: ["LingoHub"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.binaryTarget(
name: "LingoHub",
url: "https://github.com/lingohub/ios-sdk/releases/download/1.0.0/LingoHub.xcframework.zip",
checksum: "22539a4c8ab89750847dbd47470c78376e14c2af4ffed3d9bf39f16ceb603a93"
)
]
)
229 changes: 229 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
# LingoHub iOS SDK

Master translation and connect with world leading translators. Automate and optimize your translation workflow with [LingoHub](https://lingohub.com).

## Features

- Over-The-Air localization update
- Language switching at runtime
- Method swizzling for easy integration
- Storyboard & XIB localization
- Localization testing using preproduction builds

## Requirements

- iOS 9.0
- watchOS 2.0
- tvOS 9.0
- macOS 10.11

## Installation

### CocoaPods

To integrate LingoHub into your Xcode project using [CocoaPods](https://cocoapods.org), specify it in your `Podfile`:

```ruby
pod 'LingoHub'
```

### Swift Package Manager

To integrate LingoHub into your Xcode project using [Swift Package Manager](https://swift.org/package-manager/), specify it in the `dependencies` of your `Package.swift`:

```swift
// swift-tools-version:5.3
import PackageDescription
...
dependencies: [
.package(url: "https://github.com/lingohub/lh-ios-sdk.git", .upToNextMajor(from: "1.0.0"))
]
...
```

:warning: Our SDK has dependencies on binary frameworks, so you have to use a version higher than 5.3 of your Swift Tools

### Accio

To integrate LingoHub into your Xcode project using [Accio](https://github.com/JamitLabs/Accio), use the same configuration as for Swift Package Manager. Once your`Package.swift`file is configured, run`accio update`.

### Carthage

To integrate LingoHub into your Xcode project using [Carthage](https://github.com/Carthage/Carthage), specify it in your `Cartfile`:

```ogdl
binary "https://raw.githubusercontent.com/lingohub/lingohub-ios-sdk/master/LingoHub.json"
```

### Manually

If you prefer not to integrate LingoHub manually instead of using a Dependency Manager, [download the latest LingoHub.xcframwork](https://github.com/lingohub/ios-sdk/releases/latest/download/LingoHub.xcframework.zip) and add it to your project.

## Usage

### Import

Wherever you want to use LingoHub, import the module first

###### Swift

```swift
import LingoHub
```

###### Objective-C

```objectivec
#import <LingoHub/LingoHub.h>
```

### Configuration

Configure the LingoHub SDK in your `AppDelegate` with:

- *API Key*
- *Project Id*
- optional: *App Version* (The default is the ```CFBundleShortVersionString``` of the main Bundle)

The easiest way is to use our Swizzle feature, so you can use `NSLocalizedString` as usual.

###### Swift

```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LingoHubSDK.shared.configure(withApiKey: "YOUR-API-KEY", projectId: "YOUR-PROJECT-ID")
LingoHubSDK.shared.swizzleMainBundle()
}
```

###### Objective-C

```objectivec
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
[LingoHubSDK.shared configureWithApiKey:@"YOUR-API-KEY" projectId:@"YOUR-PROJECT-KEY"];
[LingoHubSDK.shared swizzleMainBundle];
}
```
### Check for updates
In order to have your localizations updated, include following code in your `AppDelegate`:
###### Swift
```swift
func applicationDidBecomeActive(_ application: UIApplication) {
LingoHubSDK.shared.update { result in
switch result {
case .success(let value):
print("Content updated: \(value)")
case .failure(let error):
print(error.localizedDescription)
}
}
}
```

###### Objective-C

```objectivec
- (void)applicationDidBecomeActive:(UIApplication *)application {
[LingoHubSDK.shared updateWithCompletion:^(BOOL value, NSError * _Nullable error) {
if (error != nil) {
NSLog(@"Content updated: %d", value);
} else {
NSLog(error.localizedDescription);
}
}];
}
```

### Manual usage

If you do not want to use method swizzling, you can get your updated localization by asking the LingoHub SDK for it.

###### Swift

```swift
func localizedString(withKey key: String, tableName: String? = nil) {
if let localizedString = LingoHubSDK.shared.localizedString(forKey: key, tableName: tableName) {
return localizedString
}
return NSLocalizedString(key, tableName: tableName, comment: "")
}
```

###### Objective-C

```objectivec
- (NSString * _Nonnull)localizedStringWithKey:(NSString * _Nonnull)key tableName:(NSString * _Nullable)tableName {
NSString *updatedLocalization = [LingoHubSDK.shared localizedStringForKey:key tableName:tableName];
if (updatedLocalization != nil) {
return updatedLocalization;
}

return NSLocalizedStringFromTable(key, tableName, @"");
}
```

### Observing updates

If LingoHub has found updated localization, it will post the `LingoHubDidUpdateLocalization` notification. Observe it to get notified on updates.

###### Swift

```swift
NotificationCenter.default.addObserver(forName: .LingoHubDidUpdateLocalization, object: nil, queue: nil) { [weak self] _ in
self?.updateLocalization()
}
```

###### Objective-C

```objectivec
_weak MyViewController *weakSelf = self;
[NSNotificationCenter.defaultCenter addObserverForName:NSNotification.LingoHubDidUpdateLocalization object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
MyViewController *strongSelf = weakSelf;
[strongSelf updateLocalization];
}];
```
### Language switching
If you would like to change the language of your app at runtime, you can use the LingoHub SDK for it.
###### Swift
```swift
LingoHubSDK.shared.setLanguage("de")
```

###### Objective-C

```objectivec
[LingoHubSDK.shared setLanguage:@"de"];
```
### Preproduction mode
If you would like to test your localizations before submitting a new package, enable preproduction mode.
###### Swift
```swift
LingoHubSDK.shared.isPreproductionEnabled = true
```

###### Objective-C

```objectivec
[LingoHubSDK.shared setIsPreproductionEnabled:true];
```
## Storyboard & XIB Localization
If you are using storyboard and/or XIB localization, you have to reload the view after LingoHub did update your localizations.
## Support
For bug reports, please create a new Issue right here on Github. Otherwise have a look at our [Contact options](https://lingohub.com/support)

0 comments on commit 31e6bc3

Please sign in to comment.