Skip to content

Commit

Permalink
Feature/localization (#24)
Browse files Browse the repository at this point in the history
* Add localization.

* Add l10n for authentication.

* Export files.
  • Loading branch information
yspreen authored May 7, 2021
1 parent 52c72c6 commit 6ce792d
Show file tree
Hide file tree
Showing 19 changed files with 542 additions and 392 deletions.
8 changes: 4 additions & 4 deletions DGCAWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
CE1D1EF6263597A2004C8919 /* LocalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1D1EF5263597A2004C8919 /* LocalData.swift */; };
CE1F155C2639F9E700736D48 /* SwiftyJSON in Frameworks */ = {isa = PBXBuildFile; productRef = CE1F155B2639F9E700736D48 /* SwiftyJSON */; };
CE260F56263DD1720083A200 /* WalletCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE260F55263DD1720083A200 /* WalletCell.swift */; };
CE345FB826447A9F003B457E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = CE345FB726447A9F003B457E /* Localizable.strings */; };
CE37B643263867D700DEE13D /* SecureBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE37B642263867D700DEE13D /* SecureBackground.swift */; };
CE56B5052639F48E00FB31B1 /* SwiftDGC in Frameworks */ = {isa = PBXBuildFile; productRef = CE56B5042639F48E00FB31B1 /* SwiftDGC */; };
CE56BC07264068110044FD3F /* GatewayConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE56BC06264068110044FD3F /* GatewayConnection.swift */; };
CE8096D9263B07BB00A65AD6 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE8096D8263B07BB00A65AD6 /* UIColor.swift */; };
CE81533A263FF7EC0030D777 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = CE815339263FF7EC0030D777 /* README.md */; };
CE8912FB2634C6B900CB92AF /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = CE8912FA2634C6B900CB92AF /* Alamofire */; };
CE891305263581D900CB92AF /* Home.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE891304263581D900CB92AF /* Home.swift */; };
CEA1555D262F63B30024B7AC /* EuDgcSchema.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA1555C262F63B30024B7AC /* EuDgcSchema.swift */; };
CEA15563262F6DAB0024B7AC /* CertViewerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA15562262F6DAB0024B7AC /* CertViewerDelegate.swift */; };
CEA1556B262F784E0024B7AC /* SelfSizedTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA1556A262F784E0024B7AC /* SelfSizedTableView.swift */; };
CEA15570262F79DE0024B7AC /* InfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA1556F262F79DE0024B7AC /* InfoCell.swift */; };
Expand Down Expand Up @@ -68,12 +68,12 @@
CE13CF22262DDF810070C80E /* RoundedButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundedButton.swift; sourceTree = "<group>"; };
CE1D1EF5263597A2004C8919 /* LocalData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalData.swift; sourceTree = "<group>"; };
CE260F55263DD1720083A200 /* WalletCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletCell.swift; sourceTree = "<group>"; };
CE345FB726447A9F003B457E /* Localizable.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = "<group>"; };
CE37B642263867D700DEE13D /* SecureBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureBackground.swift; sourceTree = "<group>"; };
CE56BC06264068110044FD3F /* GatewayConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GatewayConnection.swift; sourceTree = "<group>"; };
CE8096D8263B07BB00A65AD6 /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = "<group>"; };
CE815339263FF7EC0030D777 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; };
CE891304263581D900CB92AF /* Home.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Home.swift; sourceTree = "<group>"; };
CEA1555C262F63B30024B7AC /* EuDgcSchema.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EuDgcSchema.swift; sourceTree = "<group>"; };
CEA15562262F6DAB0024B7AC /* CertViewerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CertViewerDelegate.swift; sourceTree = "<group>"; };
CEA1556A262F784E0024B7AC /* SelfSizedTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfSizedTableView.swift; sourceTree = "<group>"; };
CEA1556F262F79DE0024B7AC /* InfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -197,7 +197,7 @@
CEA6D6ED261F8D2700715333 /* SceneDelegate.swift */,
CEA6D6F4261F8D2900715333 /* Assets.xcassets */,
CEA6D6F9261F8D2900715333 /* Info.plist */,
CEA1555C262F63B30024B7AC /* EuDgcSchema.swift */,
CE345FB726447A9F003B457E /* Localizable.strings */,
);
path = SupportingFiles;
sourceTree = "<group>";
Expand Down Expand Up @@ -396,6 +396,7 @@
buildActionMask = 2147483647;
files = (
CE13CF05262DCDCD0070C80E /* CertificateViewer.storyboard in Resources */,
CE345FB826447A9F003B457E /* Localizable.strings in Resources */,
CEA6D6F8261F8D2900715333 /* LaunchScreen.storyboard in Resources */,
CE81533A263FF7EC0030D777 /* README.md in Resources */,
CEA6D6F5261F8D2900715333 /* Assets.xcassets in Resources */,
Expand Down Expand Up @@ -436,7 +437,6 @@
CED2726026398683003D47A9 /* UIFont.swift in Sources */,
CEE9DA55263C7D4000A31532 /* CertCode.swift in Sources */,
CE56BC07264068110044FD3F /* GatewayConnection.swift in Sources */,
CEA1555D262F63B30024B7AC /* EuDgcSchema.swift in Sources */,
CEA6D6F0261F8D2700715333 /* Scan.swift in Sources */,
CE13CF23262DDF810070C80E /* RoundedButton.swift in Sources */,
CEA6E561264058B50066DC8E /* UIViewController.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion DGCAWallet/Components/WalletCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ class WalletCell: UITableViewCell {

typeLabel.text = cert.certTypeString
nameLabel.text = cert.fullName
dateLabel.text = "scanned \(dated.date.dateString)"
dateLabel.text = String(format: l10n("list.cell.scanned-at"), dated.date.dateString)
}
}
7 changes: 4 additions & 3 deletions DGCAWallet/Extensions/UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@


import UIKit
import SwiftDGC

extension UIViewController {
func showInputDialog(
title: String? = nil,
subtitle: String? = nil,
actionTitle: String? = "Okay",
cancelTitle: String? = "Cancel",
actionTitle: String? = l10n("btn.okay"),
cancelTitle: String? = l10n("btn.cancel"),
inputPlaceholder: String? = nil,
inputKeyboardType: UIKeyboardType = UIKeyboardType.default,
handler: ((_ text: String?) -> Void)? = nil
Expand All @@ -59,7 +60,7 @@ extension UIViewController {
func showAlert(
title: String? = nil,
subtitle: String? = nil,
actionTitle: String? = "Okay",
actionTitle: String? = l10n("btn.okay"),
cancelTitle: String? = nil,
handler: ((Bool) -> Void)? = nil
) {
Expand Down
3 changes: 2 additions & 1 deletion DGCAWallet/Models/LocalData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ struct LocalData: Codable {
guard let result = success else {
return
}
print("\(result.certStrings.count) certs loaded.")
let format = l10n("log.certs-loaded")
print(String.localizedStringWithFormat(format, result.certStrings.count))
LocalData.sharedInstance = result
completion()
}
Expand Down
2 changes: 1 addition & 1 deletion DGCAWallet/Services/GatewayConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct GatewayConnection {
let status = $0.response?.statusCode,
status == 204
else {
completion?(false, nil)
completion?(true, nil)
return
}

Expand Down
5 changes: 3 additions & 2 deletions DGCAWallet/Services/SecureBackground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import Foundation
import UIKit
import LocalAuthentication
import SwiftDGC

struct SecureBackground {
static var imageView: UIImageView?
Expand Down Expand Up @@ -66,8 +67,8 @@ struct SecureBackground {
}
paused = true
let context = LAContext()
context.localizedCancelTitle = "Try Later"
let reason = "Confirm Identity"
context.localizedCancelTitle = l10n("auth.later")
let reason = l10n("auth.confirm")
var error: NSError?
guard context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) else {
paused = false
Expand Down
12 changes: 6 additions & 6 deletions DGCAWallet/Storyboards/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<color key="backgroundColor" name="blue"/>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MID-ne-Jur" customClass="RoundedButton" customModule="DGCAWallet" customModuleProvider="target">
<rect key="frame" x="149.5" y="800" width="115" height="46"/>
<rect key="frame" x="161.5" y="812" width="91" height="34"/>
<color key="backgroundColor" name="green"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
<state key="normal" title="Scan Code">
Expand All @@ -75,7 +75,7 @@
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="emV-oh-VSt">
<rect key="frame" x="0.0" y="130.5" width="414" height="653.5"/>
<rect key="frame" x="0.0" y="130.5" width="414" height="665.5"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="none" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="walletCell" rowHeight="164" id="JcT-Kw-bMh" customClass="WalletCell" customModule="DGCAWallet" customModuleProvider="target">
Expand Down Expand Up @@ -126,16 +126,16 @@
</prototypes>
</tableView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="W03-Gm-CHU">
<rect key="frame" x="0.0" y="130.5" width="414" height="669.5"/>
<rect key="frame" x="0.0" y="130.5" width="414" height="681.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Wallet Empty" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f0r-gi-rzF">
<rect key="frame" x="145" y="271" width="124" height="24"/>
<rect key="frame" x="145" y="277" width="124" height="24"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" name="disabledText"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Press the button below to scan your code." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xvs-y5-Iav">
<rect key="frame" x="83" y="311" width="248" height="48"/>
<rect key="frame" x="83" y="317" width="248" height="48"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<color key="textColor" name="disabledText"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -252,7 +252,7 @@
</scenes>
<designables>
<designable name="MID-ne-Jur">
<size key="intrinsicContentSize" width="115" height="46"/>
<size key="intrinsicContentSize" width="91" height="34"/>
</designable>
</designables>
<resources>
Expand Down
4 changes: 2 additions & 2 deletions DGCAWallet/Storyboards/CertificateViewer.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<rect key="frame" x="0.0" y="44" width="375" height="734"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a9u-Ia-KEX" customClass="RoundedButton" customModule="DGCAWallet" customModuleProvider="target">
<rect key="frame" x="281" y="664.66666666666663" width="78" height="53.333333333333371"/>
<rect key="frame" x="305" y="664.66666666666663" width="54" height="53.333333333333371"/>
<color key="backgroundColor" name="blue"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
<state key="normal" title="Done">
Expand Down Expand Up @@ -247,7 +247,7 @@
</scenes>
<designables>
<designable name="a9u-Ia-KEX">
<size key="intrinsicContentSize" width="78" height="51"/>
<size key="intrinsicContentSize" width="54" height="39"/>
</designable>
</designables>
<resources>
Expand Down
Loading

0 comments on commit 6ce792d

Please sign in to comment.