diff --git a/MiniScanner/Extensions/Localization.swift b/MiniScanner/Extensions/Localization.swift index ade5cf3c5202c1d3684f854aa93a75d44f6a4e84..23af00f370706727063069875dcd0ecd2194139e 100644 --- a/MiniScanner/Extensions/Localization.swift +++ b/MiniScanner/Extensions/Localization.swift @@ -42,4 +42,8 @@ extension String { // // return NSLocalizedString(self, comment: "") } + + func localizedPlural(argument: CVarArg) -> String { + String.localizedStringWithFormat(localized, [argument]) + } } diff --git a/MiniScanner/Extensions/String+StringKeys.swift b/MiniScanner/Extensions/String+StringKeys.swift index 409746f91b4f3dd0359728d5f4ca6d161c74d5d4..1a44af29dd90d962ad8ddfb813de5c68ec04aab9 100644 --- a/MiniScanner/Extensions/String+StringKeys.swift +++ b/MiniScanner/Extensions/String+StringKeys.swift @@ -81,4 +81,12 @@ extension String { static let deleteImageMsg = "delete_image_msg" static let ok = "ok" + + static let dPages = "%d pages" + + static let directShare = "direct_share" + static let crop = "crop" + static let edit = "edit" + static let exportText = "export_text" + static let signature = "signature" } diff --git a/MiniScanner/Extensions/URL+Extensions.swift b/MiniScanner/Extensions/URL+Extensions.swift index f2c25982e0695162c9f789fba28f39e4d8b75813..28a471120ab4048b93580d7f544e66ca2b783d9e 100644 --- a/MiniScanner/Extensions/URL+Extensions.swift +++ b/MiniScanner/Extensions/URL+Extensions.swift @@ -52,7 +52,7 @@ extension URL { /// This function will return a current date in format ""Jan 23, 2017, 14:59:09"" private func getDateInCurrentLocaleWithHour(_ date: Date = Date()) -> String { - let currentLocale = Locale.current + let currentLocale = SupportedLanguage.currentLanguage.locale let dateFormatter = DateFormatter() let dateComponents = "y-MMM-d - H'-'ms" let dateFormat = DateFormatter.dateFormat(fromTemplate: dateComponents, options: 0, locale: currentLocale) diff --git a/MiniScanner/Features/Common/Data/Model/SupportedLanguage.swift b/MiniScanner/Features/Common/Data/Model/SupportedLanguage.swift index a8e9bc09cb8c8b2090de4290a6853eba52c72b1f..da299b15816c72983d686cb548a9a7563f5ad02f 100644 --- a/MiniScanner/Features/Common/Data/Model/SupportedLanguage.swift +++ b/MiniScanner/Features/Common/Data/Model/SupportedLanguage.swift @@ -50,6 +50,17 @@ enum SupportedLanguage: CaseIterable, CustomMenuPickerItem { isRTL ? .forceRightToLeft : .forceLeftToRight } + var locale: Locale { + switch self { + case .device: + SupportedLanguage.currentLanguage.locale + case .english: + Locale(identifier: "en") + case .arabic: + Locale(identifier: "ar") + } + } + var id: Self { self } var displayedName: String { diff --git a/MiniScanner/Modules/DocumentPreview/DocumentPreview.storyboard b/MiniScanner/Modules/DocumentPreview/DocumentPreview.storyboard index c66d3920b1925575ab2c25996a48bc481453b396..beadaa17bc8879d55de6cfa45ab19580985aca48 100644 --- a/MiniScanner/Modules/DocumentPreview/DocumentPreview.storyboard +++ b/MiniScanner/Modules/DocumentPreview/DocumentPreview.storyboard @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="b1K-XK-mdX"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="b1K-XK-mdX"> <device id="retina6_1" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> @@ -161,6 +161,7 @@ <barButtonItem key="rightBarButtonItem" title="Item" image="printer" catalog="system" hidden="YES" id="Z0H-Ze-WXm"/> </navigationItem> <connections> + <outlet property="directShareLabel" destination="GR8-HI-C1V" id="586-VP-rx9"/> <outlet property="pdfView" destination="HkK-Fc-Rgz" id="3sS-2Q-v88"/> </connections> </viewController> diff --git a/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift b/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift index 7b3b977e077f7046adea1713f9630a3c6f7bd011..f00efe194e9182302c8d9e12b37fe576a70dda49 100644 --- a/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift +++ b/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift @@ -18,6 +18,7 @@ final class DocumentPreviewViewController: UIViewController { } @IBOutlet private weak var pdfView: CustomPDFView! + @IBOutlet weak var directShareLabel: UILabel! var file: File? private var scannedItem: ScannedItem! @@ -42,6 +43,7 @@ final class DocumentPreviewViewController: UIViewController { payload = [url] } + directShareLabel.set(localized: .directShare) } @IBAction func whatsappTapped(_ sender: UIButton) { diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift index 1f9b3c19a13a5ada4fa5973db1101e145ef0b05c..dadb44ad87dd60c9aee5e380173447e4a018acd9 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift @@ -76,7 +76,11 @@ class ShareSheetViewController: UIViewController { let _ = self.session?.scannedItems[0].render(completion: { image in self.pdfImage.image = image?.retrieveImage() }) - pagesCountLabel.set(text: "\(self.session?.scannedItems.count ?? 0) pages") + + let pagesCount = self.session?.scannedItems.count ?? 0 + let text = String.dPages.localizedPlural(argument: pagesCount) + + pagesCountLabel.set(text: text) } diff --git a/MiniScanner/Modules/Documents/Model/File.swift b/MiniScanner/Modules/Documents/Model/File.swift index 0320c027ea64c2b8661b217400a184090a8356b9..13698b31fa85863614ee59ff1ad27670bf8978b8 100644 --- a/MiniScanner/Modules/Documents/Model/File.swift +++ b/MiniScanner/Modules/Documents/Model/File.swift @@ -31,6 +31,10 @@ class File: NSObject { self.fileExtension = fileURL.pathExtension self.date = fileURL.getDate pdfDocument = PDFDocument(url: fileURL) - self.pagesCount = "\(pdfDocument?.pageCount ?? 1) pages" + + let pagesCount = pdfDocument?.pageCount ?? 1 + let text = String.dPages.localizedPlural(argument: pagesCount) + + self.pagesCount = text // "\(pdfDocument?.pageCount ?? 1) pages" } } diff --git a/MiniScanner/Modules/EditViewController/EditViewController.swift b/MiniScanner/Modules/EditViewController/EditViewController.swift index ad407225186c6ca8e483e401966d9fdc8a688689..71931283f90f8eb38b4139a7d103df49852fc8c5 100644 --- a/MiniScanner/Modules/EditViewController/EditViewController.swift +++ b/MiniScanner/Modules/EditViewController/EditViewController.swift @@ -25,6 +25,12 @@ public class EditViewController: UIViewController { @IBOutlet weak var banner: BannerView! @IBOutlet weak var pageIndex: UILabel! @IBOutlet weak var continueButton: UIButton! + @IBOutlet weak var directShareLabel: UILabel! + + @IBOutlet weak var signatureLabel: UILabel! + @IBOutlet weak var cropLabel: UILabel! + @IBOutlet weak var editLabel: UILabel! + @IBOutlet weak var exportTextLabel: UILabel! // MARK: - Properties private var scanSession:MultiPageScanSession? @@ -79,6 +85,12 @@ public class EditViewController: UIViewController { let backButton = UIBarButtonItem(title: .back.localized, style: .plain, target: self, action: #selector(backTapped)) self.navigationItem.leftBarButtonItem = backButton + directShareLabel.set(localized: .directShare) + + signatureLabel.text = .signature.localized + exportTextLabel.text = .exportText.localized + editLabel.text = .edit.localized + cropLabel.text = .crop.localized } public override func viewWillAppear(_ animated: Bool) { diff --git a/MiniScanner/Modules/EditViewController/EditViewController.xib b/MiniScanner/Modules/EditViewController/EditViewController.xib index 417be6149ac2191c36d2334dec296a5c78072fae..7e465bc20d223f7e9bdbe504c679bab320f41aa3 100644 --- a/MiniScanner/Modules/EditViewController/EditViewController.xib +++ b/MiniScanner/Modules/EditViewController/EditViewController.xib @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <device id="retina6_72" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> @@ -21,7 +21,12 @@ <connections> <outlet property="banner" destination="4ep-ST-cZS" id="WFR-ov-H7F"/> <outlet property="continueButton" destination="jE5-UT-fB1" id="v74-7i-T0B"/> + <outlet property="cropLabel" destination="fB8-gh-FgW" id="Lm5-hr-Iol"/> + <outlet property="directShareLabel" destination="Kl7-O6-xwc" id="64C-0v-w2g"/> + <outlet property="editLabel" destination="qsI-va-wrT" id="bgi-CV-nVT"/> + <outlet property="exportTextLabel" destination="7JD-iL-DeH" id="rkg-DS-xq4"/> <outlet property="pageIndex" destination="cqF-h7-7PR" id="KbK-o3-cPN"/> + <outlet property="signatureLabel" destination="wyA-kN-C8j" id="MsC-hs-DpR"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> </connections> </placeholder> diff --git a/MiniScanner/Supporting Files/Localization/Localizable.xcstrings b/MiniScanner/Supporting Files/Localization/Localizable.xcstrings index 7088675674472d687ae617cb1e06b5c5174d128f..b2b50f1d019419c3172c0d0117af3c87141f65af 100644 --- a/MiniScanner/Supporting Files/Localization/Localizable.xcstrings +++ b/MiniScanner/Supporting Files/Localization/Localizable.xcstrings @@ -1,6 +1,77 @@ { "sourceLanguage" : "en", "strings" : { + "%d pages" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "variations" : { + "plural" : { + "few" : { + "stringUnit" : { + "state" : "translated", + "value" : "%d صفحات" + } + }, + "many" : { + "stringUnit" : { + "state" : "translated", + "value" : "%d صفحة" + } + }, + "one" : { + "stringUnit" : { + "state" : "translated", + "value" : "صفحة واحدة" + } + }, + "other" : { + "stringUnit" : { + "state" : "translated", + "value" : "%d صفحات" + } + }, + "two" : { + "stringUnit" : { + "state" : "translated", + "value" : "صفحتان" + } + }, + "zero" : { + "stringUnit" : { + "state" : "translated", + "value" : "لا يوجد صفحات" + } + } + } + } + }, + "en" : { + "variations" : { + "plural" : { + "one" : { + "stringUnit" : { + "state" : "translated", + "value" : "%d Page" + } + }, + "other" : { + "stringUnit" : { + "state" : "translated", + "value" : "%d Pages" + } + }, + "zero" : { + "stringUnit" : { + "state" : "translated", + "value" : "No pages" + } + } + } + } + } + } + }, "add_folder" : { "extractionState" : "manual", "localizations" : { @@ -145,6 +216,12 @@ "continue" : { "extractionState" : "manual", "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "متابعة" + } + }, "en" : { "stringUnit" : { "state" : "translated", @@ -153,6 +230,23 @@ } } }, + "crop" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "قص" + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Crop" + } + } + } + }, "current_page" : { "extractionState" : "manual", "localizations" : { @@ -277,6 +371,23 @@ } } }, + "direct_share" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "مشاركة فورية" + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Direct Share" + } + } + } + }, "discard" : { "extractionState" : "manual", "localizations" : { @@ -342,6 +453,23 @@ } } }, + "edit" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "تعديل" + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Edit" + } + } + } + }, "entire_document" : { "extractionState" : "manual", "localizations" : { @@ -359,6 +487,23 @@ } } }, + "export_text" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "استخراج النص" + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Export text" + } + } + } + }, "file_manager" : { "extractionState" : "manual", "localizations" : { @@ -681,6 +826,23 @@ } } }, + "signature" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "توقيع" + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Signature" + } + } + } + }, "telegram" : { "extractionState" : "manual", "localizations" : {