From 90f55261a116f56c13fb5103e78cd3762ac81393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Menu?= Date: Fri, 14 Jun 2019 12:41:32 +0200 Subject: [PATCH 1/3] Localize the framework --- r2-streamer-swift.xcodeproj/project.pbxproj | 23 ++++++++++- r2-streamer-swift/Fetcher/ContentFilter.swift | 10 ++--- r2-streamer-swift/Fetcher/DRMDecoder.swift | 4 +- r2-streamer-swift/Fetcher/Fetcher.swift | 4 +- r2-streamer-swift/Model/Container.swift | 21 +++++----- .../Parser/CBZ/CBZContainer.swift | 4 +- r2-streamer-swift/Parser/CBZ/CBZParser.swift | 19 +++++---- .../Parser/EPUB/EPUBContainerParser.swift | 4 +- .../Parser/EPUB/EPUBEncryptionParser.swift | 2 +- .../Parser/EPUB/EPUBParser.swift | 39 ++++++++++--------- r2-streamer-swift/Parser/EPUB/OPFParser.swift | 8 ++-- .../Parser/EPUB/SMILParser.swift | 2 +- r2-streamer-swift/Parser/PDF/PDFParser.swift | 8 ++-- .../Resources/en.lproj/Localizable.strings | 38 ++++++++++++++++++ .../Server/WebServerResourceResponse.swift | 2 +- .../Toolkit/R2StreamerLocalizedString.swift | 17 ++++++++ .../Toolkit/Streams/ZIPInputStream.swift | 2 +- .../Toolkit/ZIPArchive/ZIPArchive.swift | 5 ++- 18 files changed, 148 insertions(+), 64 deletions(-) create mode 100644 r2-streamer-swift/Resources/en.lproj/Localizable.strings create mode 100644 r2-streamer-swift/Toolkit/R2StreamerLocalizedString.swift diff --git a/r2-streamer-swift.xcodeproj/project.pbxproj b/r2-streamer-swift.xcodeproj/project.pbxproj index 9a0ed20b..a1020459 100644 --- a/r2-streamer-swift.xcodeproj/project.pbxproj +++ b/r2-streamer-swift.xcodeproj/project.pbxproj @@ -57,10 +57,12 @@ CA130F1D229E7CC1000A627C /* NavigationDocumentParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA130DB6229E7CBE000A627C /* NavigationDocumentParserTests.swift */; }; CA130F1E229E7CC1000A627C /* SampleGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA130DB7229E7CBE000A627C /* SampleGenerator.swift */; }; CA131064229E7CD0000A627C /* Samples in Resources */ = {isa = PBXBuildFile; fileRef = CA131063229E7CD0000A627C /* Samples */; }; + CA50B87D22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA50B87C22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift */; }; CA6F97CE22A50F39007D2049 /* EPUBContainerParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA6F97CD22A50F39007D2049 /* EPUBContainerParser.swift */; }; CA6F97D222A5161A007D2049 /* EPUBContainerParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA6F97D122A5161A007D2049 /* EPUBContainerParserTests.swift */; }; CA6F97D422A52810007D2049 /* OPFParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA6F97D322A52810007D2049 /* OPFParserTests.swift */; }; CA6F97DA22A6A0B7007D2049 /* OPFMeta.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA6F97D922A6A0B6007D2049 /* OPFMeta.swift */; }; + CAD178B222B3AB1B004E6812 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = CAD178B422B3AB1B004E6812 /* Localizable.strings */; }; CAF58199229EC8B3009A04E8 /* EPUBMetadataParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF58198229EC8B3009A04E8 /* EPUBMetadataParserTests.swift */; }; /* End PBXBuildFile section */ @@ -128,10 +130,12 @@ CA130DB7229E7CBE000A627C /* SampleGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleGenerator.swift; sourceTree = ""; }; CA130F17229E7CC0000A627C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; CA131063229E7CD0000A627C /* Samples */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Samples; sourceTree = ""; }; + CA50B87C22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = R2StreamerLocalizedString.swift; sourceTree = ""; }; CA6F97CD22A50F39007D2049 /* EPUBContainerParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EPUBContainerParser.swift; sourceTree = ""; }; CA6F97D122A5161A007D2049 /* EPUBContainerParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EPUBContainerParserTests.swift; sourceTree = ""; }; CA6F97D322A52810007D2049 /* OPFParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPFParserTests.swift; sourceTree = ""; }; CA6F97D922A6A0B6007D2049 /* OPFMeta.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPFMeta.swift; sourceTree = ""; }; + CAD178B322B3AB1B004E6812 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; CAF58198229EC8B3009A04E8 /* EPUBMetadataParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EPUBMetadataParserTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -214,6 +218,7 @@ CA130D04229D4245000A627C /* Resources */ = { isa = PBXGroup; children = ( + CAD178B422B3AB1B004E6812 /* Localizable.strings */, CA130D77229D42E2000A627C /* fonts */, CA130D79229D42E2000A627C /* scripts */, CA130D78229D42E2000A627C /* styles */, @@ -245,10 +250,10 @@ CA130D25229D4245000A627C /* Parser */ = { isa = PBXGroup; children = ( - CA130D26229D4245000A627C /* CBZ */, - CA130D29229D4245000A627C /* PDF */, CA130D2E229D4245000A627C /* PublicationParser.swift */, + CA130D26229D4245000A627C /* CBZ */, CA130D2F229D4245000A627C /* EPUB */, + CA130D29229D4245000A627C /* PDF */, ); path = Parser; sourceTree = ""; @@ -317,6 +322,7 @@ CA130D40229D4245000A627C /* Logger.swift */, CA130D41229D4245000A627C /* DataExtension.swift */, CA130D42229D4245000A627C /* StringExtension.swift */, + CA50B87C22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift */, ); path = Toolkit; sourceTree = ""; @@ -471,6 +477,7 @@ buildActionMask = 2147483647; files = ( CA130D7C229D42E2000A627C /* scripts in Resources */, + CAD178B222B3AB1B004E6812 /* Localizable.strings in Resources */, CA130D7B229D42E2000A627C /* styles in Resources */, CA130D7A229D42E2000A627C /* fonts in Resources */, ); @@ -496,6 +503,7 @@ CA130D71229D4245000A627C /* ArchiveContainer.swift in Sources */, CA130D66229D4245000A627C /* EPUBParser.swift in Sources */, CA130D47229D4245000A627C /* ZIPInputStream.swift in Sources */, + CA50B87D22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift in Sources */, CA130D73229D4245000A627C /* Logger.swift in Sources */, CA130D6B229D4245000A627C /* EPUBEncryptionParser.swift in Sources */, CA130D64229D4245000A627C /* PDFFileParser.swift in Sources */, @@ -556,6 +564,17 @@ }; /* End PBXTargetDependency section */ +/* Begin PBXVariantGroup section */ + CAD178B422B3AB1B004E6812 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + CAD178B322B3AB1B004E6812 /* en */, + ); + name = Localizable.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 59501DDF1E2FB0D700D1B4BF /* Debug */ = { isa = XCBuildConfiguration; diff --git a/r2-streamer-swift/Fetcher/ContentFilter.swift b/r2-streamer-swift/Fetcher/ContentFilter.swift index 84224eb6..bfa86aa4 100644 --- a/r2-streamer-swift/Fetcher/ContentFilter.swift +++ b/r2-streamer-swift/Fetcher/ContentFilter.swift @@ -15,7 +15,7 @@ import Fuzi /// Protocol defining the content filters. They are implemented below and used /// in the fetcher. They come in different flavors depending of the container /// data mimetype. -internal protocol ContentFilters { +internal protocol ContentFilters: Loggable { init() func apply(to input: SeekableInputStream, @@ -161,12 +161,12 @@ final internal class ContentFiltersEpub: ContentFilters { // Inserting at the start of . guard let headStart = resourceHtml.endIndex(of: "") else { - print("Invalid resource") + log(.error, "Invalid resource") abort() } guard let baseUrl = publication.baseURL?.deletingLastPathComponent() else { - print("Invalid host") + log(.error, "Invalid host") abort() } @@ -184,7 +184,7 @@ final internal class ContentFiltersEpub: ContentFilters { // Inserting at the end of . guard let headEnd = resourceHtml.startIndex(of: "") else { - print("Invalid resource") + log(.error, "Invalid resource") abort() } let cssAfter = getHtmlLink(forResource: "\(baseUrl)styles/\(styleSubFolder)/ReadiumCSS-after.css") @@ -214,7 +214,7 @@ final internal class ContentFiltersEpub: ContentFilters { return stream } guard let endHeadIndex = resourceHtml.startIndex(of: "") else { - print("Invalid resource") + log(.error, "Invalid resource") abort() } diff --git a/r2-streamer-swift/Fetcher/DRMDecoder.swift b/r2-streamer-swift/Fetcher/DRMDecoder.swift index eec9dc8e..b3e074b4 100644 --- a/r2-streamer-swift/Fetcher/DRMDecoder.swift +++ b/r2-streamer-swift/Fetcher/DRMDecoder.swift @@ -13,7 +13,7 @@ import Foundation import R2Shared /// Decrypt DRM encrypted content. -class DrmDecoder { +class DrmDecoder: Loggable { /// Decode the given stream using DRM. If it fails, just return the /// stream unchanged. @@ -47,7 +47,7 @@ class DrmDecoder { data = data.subdata(in: Range.init(uncheckedBounds: (0, data.count - padding))) guard let inflatedBuffer = data.inflate() else { - print("Inflate error") + log(.error, "Inflate error") return input } data = inflatedBuffer diff --git a/r2-streamer-swift/Fetcher/Fetcher.swift b/r2-streamer-swift/Fetcher/Fetcher.swift index cfdb9cd7..4d5f669f 100644 --- a/r2-streamer-swift/Fetcher/Fetcher.swift +++ b/r2-streamer-swift/Fetcher/Fetcher.swift @@ -144,9 +144,9 @@ internal class Fetcher { throw FetcherError.missingContainerMimetype } switch mimeType { - case EpubConstant.mimetype, EpubConstant.mimetypeOEBPS: + case EPUBConstant.mimetype, EPUBConstant.mimetypeOEBPS: return ContentFiltersEpub() - case CbzConstant.mimetype: + case CBZConstant.mimetype: return ContentFiltersCbz() case PDFConstant.pdfMimetype, PDFConstant.lcpdfMimetype: return ContentFiltersPDF() diff --git a/r2-streamer-swift/Model/Container.swift b/r2-streamer-swift/Model/Container.swift index 45540849..dc6331dc 100644 --- a/r2-streamer-swift/Model/Container.swift +++ b/r2-streamer-swift/Model/Container.swift @@ -20,7 +20,7 @@ import R2Shared /// - missingFile: The file at the given path couldn't not be found. /// - xmlParse: An error occured while parsing XML (See underlyingError for more infos). /// - missingLink: The given `Link` ressource couldn't be found in the container. -public enum ContainerError: Error { +public enum ContainerError: LocalizedError { case streamInitFailed case fileNotFound case fileError @@ -28,20 +28,24 @@ public enum ContainerError: Error { case xmlParse(underlyingError: Error) case missingLink(title: String?) - public var localizedDescription: String { + public var errorDescription: String? { switch self { case .streamInitFailed: - return "Stream initialization failed." + return R2StreamerLocalizedString("ContainerError.streamInitFailed") case .fileNotFound: - return "The file couldn't be found." + return R2StreamerLocalizedString("ContainerError.fileNotFound") case .fileError: - return "An error occured while accessing the file attributes." + return R2StreamerLocalizedString("ContainerError.fileError") case .missingFile(let path): - return "The file at \(path) is missing from the archive." + return R2StreamerLocalizedString("ContainerError.missingFile", path) case .xmlParse(let underlyingError): - return "Error while parsing XML: \(underlyingError.localizedDescription)" + return R2StreamerLocalizedString("ContainerError.xmlParse", underlyingError.localizedDescription) case .missingLink(let title): - return "The link, titled \(title ?? "missing"), couldn't be found in the container." + if let title = title { + return R2StreamerLocalizedString("ContainerError.missingLink.title", title) + } else { + return R2StreamerLocalizedString("ContainerError.missingLink") + } } } } @@ -91,7 +95,6 @@ public extension Container { let url = NSURL(fileURLWithPath: rootFile.rootPath) var modificationDate : AnyObject? try? url.getResourceValue(&modificationDate, forKey: .contentModificationDateKey) - print("\(rootFile.rootPath) - \(modificationDate as! Date)") return (modificationDate as? Date) ?? Date() } diff --git a/r2-streamer-swift/Parser/CBZ/CBZContainer.swift b/r2-streamer-swift/Parser/CBZ/CBZContainer.swift index fafd1362..4b6e6b43 100644 --- a/r2-streamer-swift/Parser/CBZ/CBZContainer.swift +++ b/r2-streamer-swift/Parser/CBZ/CBZContainer.swift @@ -24,7 +24,7 @@ protocol CBZContainer: Container { final class CBZArchiveContainer: ArchiveContainer, CBZContainer { init?(path: String) { - super.init(path: path, mimetype: CbzConstant.mimetype) + super.init(path: path, mimetype: CBZConstant.mimetype) do { try archive.buildFilesList() @@ -48,7 +48,7 @@ final class CBZArchiveContainer: ArchiveContainer, CBZContainer { final class CBZDirectoryContainer: DirectoryContainer, CBZContainer { init?(directory: String) { - super.init(directory: directory, mimetype: CbzConstant.mimetype) + super.init(directory: directory, mimetype: CBZConstant.mimetype) } var files: [String] { diff --git a/r2-streamer-swift/Parser/CBZ/CBZParser.swift b/r2-streamer-swift/Parser/CBZ/CBZParser.swift index 51530920..acfc13e7 100644 --- a/r2-streamer-swift/Parser/CBZ/CBZParser.swift +++ b/r2-streamer-swift/Parser/CBZ/CBZParser.swift @@ -1,5 +1,5 @@ // -// CbzParser.swift +// CBZParser.swift // r2-streamer-swift // // Created by Alexandre Camilleri on 3/31/17. @@ -15,19 +15,22 @@ import R2Shared /// Errors related to the CBZ publications. /// /// - missingFile: The file at 'path' is missing from the container. -public enum CbzParserError: LocalizedError { +public enum CBZParserError: LocalizedError { case missingFile(path: String) public var errorDescription: String? { switch self { case .missingFile(let path): - return "The file '\(path)' is missing." + return R2StreamerLocalizedString("CBZParserError.missingFile", path) } } } +@available(*, deprecated, renamed: "CBZParserError") +public typealias CbzParserError = CBZParserError + /// CBZ related constants. -public struct CbzConstant { +struct CBZConstant { public static let mimetype = "application/x-cbr" } @@ -65,7 +68,7 @@ public class CbzParser: PublicationParser { /// /// - Parameter path: The path of the file to parse. /// - Returns: The resulting `PubBox` object. - /// - Throws: Throws `CbzParserError.missingFile`. + /// - Throws: Throws `CBZParserError.missingFile`. public static func parse(fileAtPath path: String) throws -> (PubBox, PubParsingCallback) { let container = try generateContainerFrom(fileAtPath: path) let publication = parsePublication(in: container, at: path) @@ -109,13 +112,13 @@ public class CbzParser: PublicationParser { /// /// - Parameter path: The absolute path of the file. /// - Returns: The generated Container. - /// - Throws: `EpubParserError.missingFile`. + /// - Throws: `CBZParserError.missingFile`. private static func generateContainerFrom(fileAtPath path: String) throws -> CBZContainer { var container: CBZContainer? var isDirectory: ObjCBool = false guard FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory) else { - throw CbzParserError.missingFile(path: path) + throw CBZParserError.missingFile(path: path) } if isDirectory.boolValue { container = CBZDirectoryContainer(directory: path) @@ -124,7 +127,7 @@ public class CbzParser: PublicationParser { } guard let containerUnwrapped = container else { - throw CbzParserError.missingFile(path: path) + throw CBZParserError.missingFile(path: path) } return containerUnwrapped } diff --git a/r2-streamer-swift/Parser/EPUB/EPUBContainerParser.swift b/r2-streamer-swift/Parser/EPUB/EPUBContainerParser.swift index 32f68d26..e78fa824 100644 --- a/r2-streamer-swift/Parser/EPUB/EPUBContainerParser.swift +++ b/r2-streamer-swift/Parser/EPUB/EPUBContainerParser.swift @@ -30,7 +30,7 @@ final class EPUBContainerParser: Loggable { let data = try container.data(relativePath: path) try self.init(data: data) } catch { - throw EpubParserError.missingFile(path: path) + throw EPUBParserError.missingFile(path: path) } } @@ -38,7 +38,7 @@ final class EPUBContainerParser: Loggable { func parseRootFilePath() throws -> String { // Get the path of the OPF file, relative to the metadata.rootPath. guard let path = document.firstChild(xpath: "/cn:container/cn:rootfiles/cn:rootfile")?.attr("full-path") else { - throw EpubParserError.missingElement(message: "Missing rootfile in `container.xml`.") + throw EPUBParserError.missingRootfile } return path } diff --git a/r2-streamer-swift/Parser/EPUB/EPUBEncryptionParser.swift b/r2-streamer-swift/Parser/EPUB/EPUBEncryptionParser.swift index 3bf41638..9895cfb2 100644 --- a/r2-streamer-swift/Parser/EPUB/EPUBEncryptionParser.swift +++ b/r2-streamer-swift/Parser/EPUB/EPUBEncryptionParser.swift @@ -31,7 +31,7 @@ final class EPUBEncryptionParser: Loggable { let data = try container.data(relativePath: path) self.init(data: data, drm: drm) } catch { - throw EpubParserError.missingFile(path: path) + throw EPUBParserError.missingFile(path: path) } } diff --git a/r2-streamer-swift/Parser/EPUB/EPUBParser.swift b/r2-streamer-swift/Parser/EPUB/EPUBParser.swift index ce762db5..4e84eb24 100644 --- a/r2-streamer-swift/Parser/EPUB/EPUBParser.swift +++ b/r2-streamer-swift/Parser/EPUB/EPUBParser.swift @@ -13,7 +13,7 @@ import R2Shared import Fuzi /// Epub related constants. -public struct EpubConstant { +struct EPUBConstant { /// Lcpl file path. public static let lcplFilePath = "META-INF/license.lcpl" /// Epub mime-type. @@ -31,26 +31,29 @@ public struct EpubConstant { /// - missingFile: A file is missing from the container at `path`. /// - xmlParse: An XML parsing error occurred. /// - missingElement: An XML element is missing. -public enum EpubParserError: LocalizedError { +public enum EPUBParserError: LocalizedError { case wrongMimeType case missingFile(path: String) case xmlParse(underlyingError: Error) - case missingElement(message: String) + case missingRootfile public var errorDescription: String? { switch self { case .wrongMimeType: - return "The mimetype of the Epub is not valid." + return R2StreamerLocalizedString("EPUBParserError.wrongMimeType") case .missingFile(let path): - return "The file '\(path)' is missing." + return R2StreamerLocalizedString("EPUBParserError.missingFile", path) case .xmlParse(let underlyingError): - return "Error while parsing XML (\(underlyingError))." - case .missingElement(let message): - return "Missing element: \(message)." + return R2StreamerLocalizedString("EPUBParserError.xmlParse", underlyingError.localizedDescription) + case .missingRootfile: + return R2StreamerLocalizedString("EPUBParserError.missingRootfile") } } } +@available(*, deprecated, renamed: "EPUBParserError") +public typealias EpubParserError = EPUBParserError + extension EpubParser: Loggable {} /// An EPUB container parser that extracts the information from the relevant @@ -66,9 +69,9 @@ final public class EpubParser: PublicationParser { /// The point is to get DRM informations in the DRM object, and /// inform the decypher() function in the DRM object to allow /// the fetcher to decypher encrypted resources. - /// - Throws: `EpubParserError.wrongMimeType`, - /// `EpubParserError.xmlParse`, - /// `EpubParserError.missingFile` + /// - Throws: `EPUBParserError.wrongMimeType`, + /// `EPUBParserError.xmlParse`, + /// `EPUBParserError.missingFile` static public func parse(fileAtPath path: String) throws -> (PubBox, PubParsingCallback) { // Generate the `Container` for `fileAtPath` var container = try generateContainerFrom(fileAtPath: path) @@ -127,7 +130,7 @@ final public class EpubParser: PublicationParser { static internal func scanForDRM(in container: Container) -> DRM? { /// LCP. // Check if a LCP license file is present in the container. - if ((try? container.data(relativePath: EpubConstant.lcplFilePath)) != nil) { + if ((try? container.data(relativePath: EPUBConstant.lcplFilePath)) != nil) { return DRM(brand: .lcp) } return nil @@ -228,7 +231,7 @@ final public class EpubParser: PublicationParser { continue } link.mediaOverlays.append(node) - link.properties.mediaOverlay = EpubConstant.mediaOverlayURL + link.href + link.properties.mediaOverlay = EPUBConstant.mediaOverlayURL + link.href } } @@ -237,21 +240,21 @@ final public class EpubParser: PublicationParser { /// /// - Parameter path: The absolute path of the file. /// - Returns: The generated Container. - /// - Throws: `EpubParserError.missingFile`. + /// - Throws: `EPUBParserError.missingFile`. static fileprivate func generateContainerFrom(fileAtPath path: String) throws -> Container { var isDirectory: ObjCBool = false guard FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory) else { - throw EpubParserError.missingFile(path: path) + throw EPUBParserError.missingFile(path: path) } guard let container: Container = { if isDirectory.boolValue { - return DirectoryContainer(directory: path, mimetype: EpubConstant.mimetype) + return DirectoryContainer(directory: path, mimetype: EPUBConstant.mimetype) } else { - return ArchiveContainer(path: path, mimetype: EpubConstant.mimetype) + return ArchiveContainer(path: path, mimetype: EPUBConstant.mimetype) } }() else { - throw EpubParserError.missingFile(path: path) + throw EPUBParserError.missingFile(path: path) } container.rootFile.rootFilePath = try EPUBContainerParser(container: container).parseRootFilePath() diff --git a/r2-streamer-swift/Parser/EPUB/OPFParser.swift b/r2-streamer-swift/Parser/EPUB/OPFParser.swift index 5737b445..ad091e2b 100644 --- a/r2-streamer-swift/Parser/EPUB/OPFParser.swift +++ b/r2-streamer-swift/Parser/EPUB/OPFParser.swift @@ -24,17 +24,17 @@ public enum EPUBTitleType: String { case extended } -public enum OPFParserError: Error { +public enum OPFParserError: LocalizedError { /// The Epub have no title. Title is mandatory. case missingPublicationTitle case invalidSmilResource - var localizedDescription: String { + public var errorDescription: String? { switch self { case .missingPublicationTitle: - return "The publication is missing a title." + return R2StreamerLocalizedString("OPFParserError.missingPublicationTitle") case .invalidSmilResource: - return "Smile resource couldn't beparsed." + return R2StreamerLocalizedString("OPFParserError.invalidSmilResource") } } } diff --git a/r2-streamer-swift/Parser/EPUB/SMILParser.swift b/r2-streamer-swift/Parser/EPUB/SMILParser.swift index 7d8cb1d8..adeaffa6 100644 --- a/r2-streamer-swift/Parser/EPUB/SMILParser.swift +++ b/r2-streamer-swift/Parser/EPUB/SMILParser.swift @@ -50,7 +50,7 @@ final class SMILParser { continue } link.mediaOverlays.append(newNode) - link.properties.mediaOverlay = EpubConstant.mediaOverlayURL + link.href + link.properties.mediaOverlay = EPUBConstant.mediaOverlayURL + link.href } } diff --git a/r2-streamer-swift/Parser/PDF/PDFParser.swift b/r2-streamer-swift/Parser/PDF/PDFParser.swift index 87038c43..fc247381 100644 --- a/r2-streamer-swift/Parser/PDF/PDFParser.swift +++ b/r2-streamer-swift/Parser/PDF/PDFParser.swift @@ -44,13 +44,13 @@ public enum PDFParserError: LocalizedError { public var errorDescription: String? { switch self { case .missingFile(let path): - return "The file '\(path)' is missing." + return R2StreamerLocalizedString("PDFParserError.missingFile", path) case .openFailed: - return "Can't open the PDF file." + return R2StreamerLocalizedString("PDFParserError.openFailed") case .fileEncryptedWithPassword: - return "The PDF is encrypted with a password." + return R2StreamerLocalizedString("PDFParserError.fileEncryptedWithPassword") case .invalidLCPDF: - return "The LCP for PDF package is not valid." + return R2StreamerLocalizedString("PDFParserError.invalidLCPDF") } } diff --git a/r2-streamer-swift/Resources/en.lproj/Localizable.strings b/r2-streamer-swift/Resources/en.lproj/Localizable.strings new file mode 100644 index 00000000..10e02446 --- /dev/null +++ b/r2-streamer-swift/Resources/en.lproj/Localizable.strings @@ -0,0 +1,38 @@ +/* + Localizable.strings + r2-streamer-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. +*/ + +/* CBZParserError: Errors while parsing a CBZ publication */ +"R2Streamer.CBZParserError.missingFile" = "The file '%@' is missing."; + +/* EPUBParserError: Errors while parsing an EPUB publication */ +"R2Streamer.EPUBParserError.wrongMimeType" = "The mimetype of the Epub is not valid."; +"R2Streamer.EPUBParserError.missingFile" = "The file '%@' is missing."; +"R2Streamer.EPUBParserError.xmlParse" = "Error while parsing XML (%@)."; +"R2Streamer.EPUBParserError.missingRootfile" = "Missing rootfile in `container.xml`."; + +/* OPFParserError: Errors while parsing an OPF file */ +"R2Streamer.OPFParserError.missingPublicationTitle" = "The publication is missing a title."; +"R2Streamer.OPFParserError.invalidSmilResource" = "Smile resource couldn't be parsed."; + +/* PDFParserError: Errors while parsing a PDF publication */ +"R2Streamer.PDFParserError.missingFile" = "The file '%@' is missing."; +"R2Streamer.PDFParserError.openFailed" = "Can't open the PDF file."; +"R2Streamer.PDFParserError.fileEncryptedWithPassword" = "The PDF is encrypted with a password."; +"R2Streamer.PDFParserError.invalidLCPDF" = "The LCP for PDF package is not valid."; + +/* ContainerError: Errors occurring while using a Container */ +"R2Streamer.ContainerError.streamInitFailed" = "Stream initialization failed."; +"R2Streamer.ContainerError.fileNotFound" = "The file couldn't be found."; +"R2Streamer.ContainerError.fileError" = "An error occured while accessing the file attributes."; +"R2Streamer.ContainerError.missingFile" = "The file at %@ is missing from the publication."; +"R2Streamer.ContainerError.xmlParse" = "Error while parsing XML: %@"; +"R2Streamer.ContainerError.missingLink" = "The link couldn't be found in the container."; +"R2Streamer.ContainerError.missingLink.title" = "The link, titled %@, couldn't be found in the container."; diff --git a/r2-streamer-swift/Server/WebServerResourceResponse.swift b/r2-streamer-swift/Server/WebServerResourceResponse.swift index e0c1f7da..8e6c7d5b 100644 --- a/r2-streamer-swift/Server/WebServerResourceResponse.swift +++ b/r2-streamer-swift/Server/WebServerResourceResponse.swift @@ -57,7 +57,7 @@ open class WebServerResourceResponse: GCDWebServerFileResponse { self.inputStream = inputStream // If range is non nil - means it's not the first part (?) if let range = range { - print("Request range at \(range.location) remaining: \(range.length).") + WebServerResourceResponse.log(.debug, "Request range at \(range.location) remaining: \(range.length).") /// Return a range of what to read next (nothing, next part, whole data). func getNextRange(after range: NSRange, forStreamOfLength streamLength: UInt64) -> Range { diff --git a/r2-streamer-swift/Toolkit/R2StreamerLocalizedString.swift b/r2-streamer-swift/Toolkit/R2StreamerLocalizedString.swift new file mode 100644 index 00000000..25cf9d04 --- /dev/null +++ b/r2-streamer-swift/Toolkit/R2StreamerLocalizedString.swift @@ -0,0 +1,17 @@ +// +// R2StreamerLocalizedString.swift +// r2-streamer-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 +import R2Shared + +func R2StreamerLocalizedString(_ key: String, _ values: CVarArg...) -> String { + return R2LocalizedString("R2Streamer.\(key)", in: "org.readium.R2Streamer", values) +} diff --git a/r2-streamer-swift/Toolkit/Streams/ZIPInputStream.swift b/r2-streamer-swift/Toolkit/Streams/ZIPInputStream.swift index 84005120..17ae81db 100644 --- a/r2-streamer-swift/Toolkit/Streams/ZIPInputStream.swift +++ b/r2-streamer-swift/Toolkit/Streams/ZIPInputStream.swift @@ -89,7 +89,7 @@ internal class ZipInputStream: SeekableInputStream { try zipArchive.openCurrentFile() _streamStatus = .open } catch { - print("ERROR: could not ZipArchive.openCurrentFile()") + log(.error, "Could not ZipArchive.openCurrentFile()") _streamStatus = .error _streamError = error } diff --git a/r2-streamer-swift/Toolkit/ZIPArchive/ZIPArchive.swift b/r2-streamer-swift/Toolkit/ZIPArchive/ZIPArchive.swift index 6c5602ff..580ab1a6 100644 --- a/r2-streamer-swift/Toolkit/ZIPArchive/ZIPArchive.swift +++ b/r2-streamer-swift/Toolkit/ZIPArchive/ZIPArchive.swift @@ -8,6 +8,7 @@ import Foundation import Minizip +import R2Shared public struct ZipFileInfo { let path: String @@ -35,7 +36,7 @@ internal enum ZipArchiveError: Error { } /// Wrapper around Minizip C lib. (Minizip uses Zlib) -internal class ZipArchive { +internal class ZipArchive: Loggable { /// The minizip memory representation of the Archive. internal var unzFile: unzFile /// The informations about the Archive. @@ -148,7 +149,7 @@ internal class ZipArchive { let bytesRead = unzReadCurrentFile(unzFile, buffer, UInt32(maxLength)) if bytesRead < 0 { - print("ERROR READ NOTHING") + log(.error, "Nothing to read") } // if bytesRead >= 0 { // currentFileOffset += UInt64(bytesRead) From 6b0858ff3483bf4c93522efb459160433ee6cb32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Menu?= Date: Fri, 14 Jun 2019 13:27:33 +0200 Subject: [PATCH 2/3] Remove localization of low-level errors --- r2-streamer-swift.xcodeproj/project.pbxproj | 19 ---------- r2-streamer-swift/Model/Container.swift | 29 ++++---------- r2-streamer-swift/Parser/CBZ/CBZParser.swift | 9 +---- .../Parser/EPUB/EPUBParser.swift | 17 ++------- r2-streamer-swift/Parser/EPUB/OPFParser.swift | 12 +----- r2-streamer-swift/Parser/PDF/PDFParser.swift | 16 +------- .../Resources/en.lproj/Localizable.strings | 38 ------------------- .../Toolkit/R2StreamerLocalizedString.swift | 17 --------- 8 files changed, 14 insertions(+), 143 deletions(-) delete mode 100644 r2-streamer-swift/Resources/en.lproj/Localizable.strings delete mode 100644 r2-streamer-swift/Toolkit/R2StreamerLocalizedString.swift diff --git a/r2-streamer-swift.xcodeproj/project.pbxproj b/r2-streamer-swift.xcodeproj/project.pbxproj index a1020459..85c40f45 100644 --- a/r2-streamer-swift.xcodeproj/project.pbxproj +++ b/r2-streamer-swift.xcodeproj/project.pbxproj @@ -57,12 +57,10 @@ CA130F1D229E7CC1000A627C /* NavigationDocumentParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA130DB6229E7CBE000A627C /* NavigationDocumentParserTests.swift */; }; CA130F1E229E7CC1000A627C /* SampleGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA130DB7229E7CBE000A627C /* SampleGenerator.swift */; }; CA131064229E7CD0000A627C /* Samples in Resources */ = {isa = PBXBuildFile; fileRef = CA131063229E7CD0000A627C /* Samples */; }; - CA50B87D22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA50B87C22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift */; }; CA6F97CE22A50F39007D2049 /* EPUBContainerParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA6F97CD22A50F39007D2049 /* EPUBContainerParser.swift */; }; CA6F97D222A5161A007D2049 /* EPUBContainerParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA6F97D122A5161A007D2049 /* EPUBContainerParserTests.swift */; }; CA6F97D422A52810007D2049 /* OPFParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA6F97D322A52810007D2049 /* OPFParserTests.swift */; }; CA6F97DA22A6A0B7007D2049 /* OPFMeta.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA6F97D922A6A0B6007D2049 /* OPFMeta.swift */; }; - CAD178B222B3AB1B004E6812 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = CAD178B422B3AB1B004E6812 /* Localizable.strings */; }; CAF58199229EC8B3009A04E8 /* EPUBMetadataParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF58198229EC8B3009A04E8 /* EPUBMetadataParserTests.swift */; }; /* End PBXBuildFile section */ @@ -130,12 +128,10 @@ CA130DB7229E7CBE000A627C /* SampleGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleGenerator.swift; sourceTree = ""; }; CA130F17229E7CC0000A627C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; CA131063229E7CD0000A627C /* Samples */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Samples; sourceTree = ""; }; - CA50B87C22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = R2StreamerLocalizedString.swift; sourceTree = ""; }; CA6F97CD22A50F39007D2049 /* EPUBContainerParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EPUBContainerParser.swift; sourceTree = ""; }; CA6F97D122A5161A007D2049 /* EPUBContainerParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EPUBContainerParserTests.swift; sourceTree = ""; }; CA6F97D322A52810007D2049 /* OPFParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPFParserTests.swift; sourceTree = ""; }; CA6F97D922A6A0B6007D2049 /* OPFMeta.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPFMeta.swift; sourceTree = ""; }; - CAD178B322B3AB1B004E6812 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; CAF58198229EC8B3009A04E8 /* EPUBMetadataParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EPUBMetadataParserTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -218,7 +214,6 @@ CA130D04229D4245000A627C /* Resources */ = { isa = PBXGroup; children = ( - CAD178B422B3AB1B004E6812 /* Localizable.strings */, CA130D77229D42E2000A627C /* fonts */, CA130D79229D42E2000A627C /* scripts */, CA130D78229D42E2000A627C /* styles */, @@ -322,7 +317,6 @@ CA130D40229D4245000A627C /* Logger.swift */, CA130D41229D4245000A627C /* DataExtension.swift */, CA130D42229D4245000A627C /* StringExtension.swift */, - CA50B87C22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift */, ); path = Toolkit; sourceTree = ""; @@ -477,7 +471,6 @@ buildActionMask = 2147483647; files = ( CA130D7C229D42E2000A627C /* scripts in Resources */, - CAD178B222B3AB1B004E6812 /* Localizable.strings in Resources */, CA130D7B229D42E2000A627C /* styles in Resources */, CA130D7A229D42E2000A627C /* fonts in Resources */, ); @@ -503,7 +496,6 @@ CA130D71229D4245000A627C /* ArchiveContainer.swift in Sources */, CA130D66229D4245000A627C /* EPUBParser.swift in Sources */, CA130D47229D4245000A627C /* ZIPInputStream.swift in Sources */, - CA50B87D22B2A6AB003AFF24 /* R2StreamerLocalizedString.swift in Sources */, CA130D73229D4245000A627C /* Logger.swift in Sources */, CA130D6B229D4245000A627C /* EPUBEncryptionParser.swift in Sources */, CA130D64229D4245000A627C /* PDFFileParser.swift in Sources */, @@ -564,17 +556,6 @@ }; /* End PBXTargetDependency section */ -/* Begin PBXVariantGroup section */ - CAD178B422B3AB1B004E6812 /* Localizable.strings */ = { - isa = PBXVariantGroup; - children = ( - CAD178B322B3AB1B004E6812 /* en */, - ); - name = Localizable.strings; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - /* Begin XCBuildConfiguration section */ 59501DDF1E2FB0D700D1B4BF /* Debug */ = { isa = XCBuildConfiguration; diff --git a/r2-streamer-swift/Model/Container.swift b/r2-streamer-swift/Model/Container.swift index dc6331dc..d2aec9ac 100644 --- a/r2-streamer-swift/Model/Container.swift +++ b/r2-streamer-swift/Model/Container.swift @@ -20,34 +20,19 @@ import R2Shared /// - missingFile: The file at the given path couldn't not be found. /// - xmlParse: An error occured while parsing XML (See underlyingError for more infos). /// - missingLink: The given `Link` ressource couldn't be found in the container. -public enum ContainerError: LocalizedError { +public enum ContainerError: Error { + // Stream initialization failed. case streamInitFailed + // The file couldn't be found. case fileNotFound + // An error occured while accessing the file attributes. case fileError + // The file is missing from the publication. case missingFile(path: String) + // Error while parsing XML case xmlParse(underlyingError: Error) + // The link with given title couldn't be found in the container case missingLink(title: String?) - - public var errorDescription: String? { - switch self { - case .streamInitFailed: - return R2StreamerLocalizedString("ContainerError.streamInitFailed") - case .fileNotFound: - return R2StreamerLocalizedString("ContainerError.fileNotFound") - case .fileError: - return R2StreamerLocalizedString("ContainerError.fileError") - case .missingFile(let path): - return R2StreamerLocalizedString("ContainerError.missingFile", path) - case .xmlParse(let underlyingError): - return R2StreamerLocalizedString("ContainerError.xmlParse", underlyingError.localizedDescription) - case .missingLink(let title): - if let title = title { - return R2StreamerLocalizedString("ContainerError.missingLink.title", title) - } else { - return R2StreamerLocalizedString("ContainerError.missingLink") - } - } - } } /// Provide methods for accessing raw data from container's files. diff --git a/r2-streamer-swift/Parser/CBZ/CBZParser.swift b/r2-streamer-swift/Parser/CBZ/CBZParser.swift index acfc13e7..685f3da9 100644 --- a/r2-streamer-swift/Parser/CBZ/CBZParser.swift +++ b/r2-streamer-swift/Parser/CBZ/CBZParser.swift @@ -15,15 +15,8 @@ import R2Shared /// Errors related to the CBZ publications. /// /// - missingFile: The file at 'path' is missing from the container. -public enum CBZParserError: LocalizedError { +public enum CBZParserError: Error { case missingFile(path: String) - - public var errorDescription: String? { - switch self { - case .missingFile(let path): - return R2StreamerLocalizedString("CBZParserError.missingFile", path) - } - } } @available(*, deprecated, renamed: "CBZParserError") diff --git a/r2-streamer-swift/Parser/EPUB/EPUBParser.swift b/r2-streamer-swift/Parser/EPUB/EPUBParser.swift index 4e84eb24..b864e348 100644 --- a/r2-streamer-swift/Parser/EPUB/EPUBParser.swift +++ b/r2-streamer-swift/Parser/EPUB/EPUBParser.swift @@ -31,24 +31,13 @@ struct EPUBConstant { /// - missingFile: A file is missing from the container at `path`. /// - xmlParse: An XML parsing error occurred. /// - missingElement: An XML element is missing. -public enum EPUBParserError: LocalizedError { +public enum EPUBParserError: Error { + /// The mimetype of the EPUB is not valid. case wrongMimeType case missingFile(path: String) case xmlParse(underlyingError: Error) + /// Missing rootfile in `container.xml`. case missingRootfile - - public var errorDescription: String? { - switch self { - case .wrongMimeType: - return R2StreamerLocalizedString("EPUBParserError.wrongMimeType") - case .missingFile(let path): - return R2StreamerLocalizedString("EPUBParserError.missingFile", path) - case .xmlParse(let underlyingError): - return R2StreamerLocalizedString("EPUBParserError.xmlParse", underlyingError.localizedDescription) - case .missingRootfile: - return R2StreamerLocalizedString("EPUBParserError.missingRootfile") - } - } } @available(*, deprecated, renamed: "EPUBParserError") diff --git a/r2-streamer-swift/Parser/EPUB/OPFParser.swift b/r2-streamer-swift/Parser/EPUB/OPFParser.swift index ad091e2b..5e0edf5c 100644 --- a/r2-streamer-swift/Parser/EPUB/OPFParser.swift +++ b/r2-streamer-swift/Parser/EPUB/OPFParser.swift @@ -24,19 +24,11 @@ public enum EPUBTitleType: String { case extended } -public enum OPFParserError: LocalizedError { +public enum OPFParserError: Error { /// The Epub have no title. Title is mandatory. case missingPublicationTitle + /// Smile resource couldn't be parsed. case invalidSmilResource - - public var errorDescription: String? { - switch self { - case .missingPublicationTitle: - return R2StreamerLocalizedString("OPFParserError.missingPublicationTitle") - case .invalidSmilResource: - return R2StreamerLocalizedString("OPFParserError.invalidSmilResource") - } - } } /// EpubParser support class, able to parse the OPF package document. diff --git a/r2-streamer-swift/Parser/PDF/PDFParser.swift b/r2-streamer-swift/Parser/PDF/PDFParser.swift index fc247381..96df9957 100644 --- a/r2-streamer-swift/Parser/PDF/PDFParser.swift +++ b/r2-streamer-swift/Parser/PDF/PDFParser.swift @@ -31,7 +31,7 @@ public struct PDFConstant { /// Errors thrown during the parsing of the PDF. -public enum PDFParserError: LocalizedError { +public enum PDFParserError: Error { // The file at 'path' is missing from the container. case missingFile(path: String) // Failed to open the PDF @@ -40,20 +40,6 @@ public enum PDFParserError: LocalizedError { case fileEncryptedWithPassword // The LCP for PDF Package is malformed. case invalidLCPDF - - public var errorDescription: String? { - switch self { - case .missingFile(let path): - return R2StreamerLocalizedString("PDFParserError.missingFile", path) - case .openFailed: - return R2StreamerLocalizedString("PDFParserError.openFailed") - case .fileEncryptedWithPassword: - return R2StreamerLocalizedString("PDFParserError.fileEncryptedWithPassword") - case .invalidLCPDF: - return R2StreamerLocalizedString("PDFParserError.invalidLCPDF") - } - } - } diff --git a/r2-streamer-swift/Resources/en.lproj/Localizable.strings b/r2-streamer-swift/Resources/en.lproj/Localizable.strings deleted file mode 100644 index 10e02446..00000000 --- a/r2-streamer-swift/Resources/en.lproj/Localizable.strings +++ /dev/null @@ -1,38 +0,0 @@ -/* - Localizable.strings - r2-streamer-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. -*/ - -/* CBZParserError: Errors while parsing a CBZ publication */ -"R2Streamer.CBZParserError.missingFile" = "The file '%@' is missing."; - -/* EPUBParserError: Errors while parsing an EPUB publication */ -"R2Streamer.EPUBParserError.wrongMimeType" = "The mimetype of the Epub is not valid."; -"R2Streamer.EPUBParserError.missingFile" = "The file '%@' is missing."; -"R2Streamer.EPUBParserError.xmlParse" = "Error while parsing XML (%@)."; -"R2Streamer.EPUBParserError.missingRootfile" = "Missing rootfile in `container.xml`."; - -/* OPFParserError: Errors while parsing an OPF file */ -"R2Streamer.OPFParserError.missingPublicationTitle" = "The publication is missing a title."; -"R2Streamer.OPFParserError.invalidSmilResource" = "Smile resource couldn't be parsed."; - -/* PDFParserError: Errors while parsing a PDF publication */ -"R2Streamer.PDFParserError.missingFile" = "The file '%@' is missing."; -"R2Streamer.PDFParserError.openFailed" = "Can't open the PDF file."; -"R2Streamer.PDFParserError.fileEncryptedWithPassword" = "The PDF is encrypted with a password."; -"R2Streamer.PDFParserError.invalidLCPDF" = "The LCP for PDF package is not valid."; - -/* ContainerError: Errors occurring while using a Container */ -"R2Streamer.ContainerError.streamInitFailed" = "Stream initialization failed."; -"R2Streamer.ContainerError.fileNotFound" = "The file couldn't be found."; -"R2Streamer.ContainerError.fileError" = "An error occured while accessing the file attributes."; -"R2Streamer.ContainerError.missingFile" = "The file at %@ is missing from the publication."; -"R2Streamer.ContainerError.xmlParse" = "Error while parsing XML: %@"; -"R2Streamer.ContainerError.missingLink" = "The link couldn't be found in the container."; -"R2Streamer.ContainerError.missingLink.title" = "The link, titled %@, couldn't be found in the container."; diff --git a/r2-streamer-swift/Toolkit/R2StreamerLocalizedString.swift b/r2-streamer-swift/Toolkit/R2StreamerLocalizedString.swift deleted file mode 100644 index 25cf9d04..00000000 --- a/r2-streamer-swift/Toolkit/R2StreamerLocalizedString.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// R2StreamerLocalizedString.swift -// r2-streamer-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 -import R2Shared - -func R2StreamerLocalizedString(_ key: String, _ values: CVarArg...) -> String { - return R2LocalizedString("R2Streamer.\(key)", in: "org.readium.R2Streamer", values) -} From 2f7cf208710e6f1815d9d38fe339a4f5ddc921f3 Mon Sep 17 00:00:00 2001 From: Aferdita Muriqi Date: Sun, 16 Jun 2019 15:58:21 -0400 Subject: [PATCH 3/3] updated dependencies --- Cartfile | 2 +- Cartfile.resolved | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cartfile b/Cartfile index 6ed3b456..357e19c3 100644 --- a/Cartfile +++ b/Cartfile @@ -1,4 +1,4 @@ -github "readium/r2-shared-swift" == 1.2.11 +github "readium/r2-shared-swift" == 1.2.12 github "dexman/Minizip" github "edrlab/Fuzi" == 2.2.2 github "krzyzanowskim/CryptoSwift" == 0.15.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index dbb483b6..9dc32c98 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,5 @@ github "dexman/Minizip" "1.4.0" github "edrlab/Fuzi" "2.2.2" github "krzyzanowskim/CryptoSwift" "0.15.0" -github "readium/r2-shared-swift" "1.2.11" +github "readium/r2-shared-swift" "1.2.12" github "swisspol/GCDWebServer" "3.5.2"