This repository has been archived by the owner on Aug 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from readium/develop
v1.2.13
- Loading branch information
Showing
5 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
Localizable.strings | ||
r2-shared-swift | ||
|
||
Created by Mickaël Menu on 14.06.19. | ||
|
||
Copyright 2019 Readium Foundation. All rights reserved. | ||
Use of this source code is governed by a BSD-style license which is detailed | ||
in the LICENSE file present in the project repository where this source code is maintained. | ||
*/ | ||
|
||
/* Error while parsing a given JSON type */ | ||
"R2Shared.JSONError.parsing" = "Failed to parse %@ JSON"; | ||
|
||
/* 404 Not found error during a network request made with DownloadSession */ | ||
"R2Shared.DownloadSession.RequestError.notFound" = "Request failed: not found"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// R2LocalizedString.swift | ||
// r2-shared-swift | ||
// | ||
// Created by Mickaël Menu on 13.06.19. | ||
// | ||
// Copyright 2019 Readium Foundation. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license which is detailed | ||
// in the LICENSE file present in the project repository where this source code is maintained. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Returns the localized string in the main bundle, or fallback on the bundle with given ID if not found. | ||
/// Can be used to override framework localized strings in the host app. | ||
public func R2LocalizedString(_ key: String, in bundleID: String, _ values: [CVarArg]) -> String { | ||
let defaultValue = Bundle(identifier: bundleID)?.localizedString(forKey: key, value: nil, table: nil) | ||
var string = Bundle.main.localizedString(forKey: key, value: defaultValue, table: nil) | ||
if !values.isEmpty { | ||
string = String(format: string, locale: Locale.current, arguments: values) | ||
} | ||
return string | ||
} | ||
|
||
public func R2LocalizedString(_ key: String, in bundleID: String, _ values: CVarArg...) -> String { | ||
return R2LocalizedString(key, in: bundleID, values) | ||
} | ||
|
||
func R2SharedLocalizedString(_ key: String, _ values: CVarArg...) -> String { | ||
return R2LocalizedString("R2Shared.\(key)", in: "org.readium.r2-shared-swift", values) | ||
} |