Skip to content

Commit

Permalink
Add Localization. (eu-digital-green-certificates#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen authored May 6, 2021
1 parent a8275f6 commit b44ab96
Show file tree
Hide file tree
Showing 18 changed files with 898 additions and 23 deletions.
44 changes: 36 additions & 8 deletions DGCAVerifier.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@

/* Begin PBXBuildFile section */
CE13CF00262DCC180070C80E /* FloatingPanel in Frameworks */ = {isa = PBXBuildFile; productRef = CE13CEFF262DCC180070C80E /* FloatingPanel */; };
CE13CF05262DCDCD0070C80E /* CertificateViewer.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE13CF04262DCDCD0070C80E /* CertificateViewer.storyboard */; };
CE13CF0A262DCDDA0070C80E /* CertificateViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE13CF09262DCDDA0070C80E /* CertificateViewer.swift */; };
CE13CF0F262DD0D80070C80E /* FullFloatingPanelLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE13CF0E262DD0D80070C80E /* FullFloatingPanelLayout.swift */; };
CE13CF23262DDF810070C80E /* RoundedButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE13CF22262DDF810070C80E /* RoundedButton.swift */; };
CE1D1EF6263597A2004C8919 /* LocalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1D1EF5263597A2004C8919 /* LocalData.swift */; };
CE1F155C2639F9E700736D48 /* SwiftyJSON in Frameworks */ = {isa = PBXBuildFile; productRef = CE1F155B2639F9E700736D48 /* SwiftyJSON */; };
CE345FAC26446694003B457E /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE345FAE26446694003B457E /* Settings.storyboard */; };
CE345FAF264466AA003B457E /* CertificateViewer.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE345FB1264466AA003B457E /* CertificateViewer.storyboard */; };
CE345FB426446817003B457E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = CE345FB626446817003B457E /* Localizable.strings */; };
CE37B643263867D700DEE13D /* SecureBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE37B642263867D700DEE13D /* SecureBackground.swift */; };
CE41B7E226445092005013C4 /* AppVersionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE41B7E126445092005013C4 /* AppVersionCell.swift */; };
CE56B5052639F48E00FB31B1 /* SwiftDGC in Frameworks */ = {isa = PBXBuildFile; productRef = CE56B5042639F48E00FB31B1 /* SwiftDGC */; };
CE59D1B426428782004EBDD6 /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE59D1B326428782004EBDD6 /* Settings.storyboard */; };
CE59D1B626428D78004EBDD6 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE59D1B526428D78004EBDD6 /* Settings.swift */; };
CE8096D9263B07BB00A65AD6 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE8096D8263B07BB00A65AD6 /* UIColor.swift */; };
CE81533C263FF8FE0030D777 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = CE81533B263FF8FE0030D777 /* README.md */; };
Expand Down Expand Up @@ -57,14 +58,15 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
CE13CF04262DCDCD0070C80E /* CertificateViewer.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CertificateViewer.storyboard; sourceTree = "<group>"; };
CE13CF09262DCDDA0070C80E /* CertificateViewer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CertificateViewer.swift; sourceTree = "<group>"; };
CE13CF0E262DD0D80070C80E /* FullFloatingPanelLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FullFloatingPanelLayout.swift; sourceTree = "<group>"; };
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>"; };
CE345FAD26446694003B457E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Settings.storyboard; sourceTree = "<group>"; };
CE345FB0264466AA003B457E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/CertificateViewer.storyboard; sourceTree = "<group>"; };
CE345FB526446817003B457E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
CE37B642263867D700DEE13D /* SecureBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureBackground.swift; sourceTree = "<group>"; };
CE41B7E126445092005013C4 /* AppVersionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppVersionCell.swift; sourceTree = "<group>"; };
CE59D1B326428782004EBDD6 /* Settings.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = "<group>"; };
CE59D1B526428D78004EBDD6 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
CE8096D8263B07BB00A65AD6 /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = "<group>"; };
CE81533B263FF8FE0030D777 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -127,8 +129,8 @@
children = (
CEA6D6F6261F8D2900715333 /* LaunchScreen.storyboard */,
CEA6D6F1261F8D2700715333 /* Main.storyboard */,
CE13CF04262DCDCD0070C80E /* CertificateViewer.storyboard */,
CE59D1B326428782004EBDD6 /* Settings.storyboard */,
CE345FB1264466AA003B457E /* CertificateViewer.storyboard */,
CE345FAE26446694003B457E /* Settings.storyboard */,
);
path = Storyboards;
sourceTree = "<group>";
Expand Down Expand Up @@ -183,6 +185,7 @@
CEA6D6ED261F8D2700715333 /* SceneDelegate.swift */,
CEA6D6F4261F8D2900715333 /* Assets.xcassets */,
CEA6D6F9261F8D2900715333 /* Info.plist */,
CE345FB626446817003B457E /* Localizable.strings */,
);
path = SupportingFiles;
sourceTree = "<group>";
Expand Down Expand Up @@ -380,12 +383,13 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CE13CF05262DCDCD0070C80E /* CertificateViewer.storyboard in Resources */,
CE345FAF264466AA003B457E /* CertificateViewer.storyboard in Resources */,
CEA6D6F8261F8D2900715333 /* LaunchScreen.storyboard in Resources */,
CE81533C263FF8FE0030D777 /* README.md in Resources */,
CE345FB426446817003B457E /* Localizable.strings in Resources */,
CEA6D6F5261F8D2900715333 /* Assets.xcassets in Resources */,
CEA6D6F3261F8D2700715333 /* Main.storyboard in Resources */,
CE59D1B426428782004EBDD6 /* Settings.storyboard in Resources */,
CE345FAC26446694003B457E /* Settings.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -463,6 +467,30 @@
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
CE345FAE26446694003B457E /* Settings.storyboard */ = {
isa = PBXVariantGroup;
children = (
CE345FAD26446694003B457E /* Base */,
);
name = Settings.storyboard;
sourceTree = "<group>";
};
CE345FB1264466AA003B457E /* CertificateViewer.storyboard */ = {
isa = PBXVariantGroup;
children = (
CE345FB0264466AA003B457E /* Base */,
);
name = CertificateViewer.storyboard;
sourceTree = "<group>";
};
CE345FB626446817003B457E /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
CE345FB526446817003B457E /* en */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
CEA6D6F1261F8D2700715333 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
Expand Down
3 changes: 2 additions & 1 deletion DGCAVerifier/Components/AppVersionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class AppVersionCell: UITableViewCell {
super.layoutSubviews()

let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
versionLabel.text = "App Version \(version ?? "?")"
let format = l10n("app-version")
versionLabel.text = String(format: format, version ?? "?")
}
}
3 changes: 2 additions & 1 deletion DGCAVerifier/Models/LocalData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ struct LocalData: Codable {
guard let result = success else {
return
}
print("\(result.encodedPublicKeys.count) certs loaded.")
let format = l10n("log.keys-loaded")
print(String.localizedStringWithFormat(format, result.encodedPublicKeys.count))
LocalData.sharedInstance = result
completion()
}
Expand Down
2 changes: 1 addition & 1 deletion DGCAVerifier/Services/GatewayConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
//
// GatewayConnection.swift
// PatientScannerDemo
// DGCAVerifier
//
// Created by Yannick Spreen on 4/24/21.
//
Expand Down
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="DGCAVerifier" customModuleProvider="target">
<rect key="frame" x="303" y="664.66666666666663" width="56" height="53.333333333333371"/>
<rect key="frame" x="279" y="664.66666666666663" width="80" height="53.333333333333371"/>
<color key="backgroundColor" systemColor="systemBlueColor"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
<state key="normal" title="Retry">
Expand Down Expand Up @@ -208,7 +208,7 @@
</scenes>
<designables>
<designable name="a9u-Ia-KEX">
<size key="intrinsicContentSize" width="56" height="39"/>
<size key="intrinsicContentSize" width="80" height="51"/>
</designable>
</designables>
<resources>
Expand Down
31 changes: 31 additions & 0 deletions DGCAVerifier/SupportingFiles/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-app-ios
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*/
/*
Localizable.strings
DGCAVerifier

Created by Yannick Spreen on 5/6/21.

*/
"log.keys-loaded" = "%d pub keys loaded.";
"app-version" = "App Version %@";
"btn.done" = "Done";
"btn.retry" = "Retry";
"settings.last-updated" = "Last Updated: %@";
10 changes: 3 additions & 7 deletions DGCAVerifier/ViewControllers/CertificateViewer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ import SwiftDGC

let DISMISS_TIMEOUT = 15.0

let validityString = [
HCertValidity.valid: "Valid",
HCertValidity.invalid: "Invalid",
]
let validityIcon = [
HCertValidity.valid: UIImage(named: "check")!,
HCertValidity.invalid: UIImage(named: "error")!,
]
let buttonText = [
HCertValidity.valid: "Done",
HCertValidity.invalid: "Retry",
HCertValidity.valid: l10n("btn.done"),
HCertValidity.invalid: l10n("btn.retry"),
]
let backgroundColor = [
HCertValidity.valid: UIColor(named: "green")!,
Expand Down Expand Up @@ -78,7 +74,7 @@ class CertificateViewerVC: UIViewController {
let validity = hCert.validity
dismissButton.setTitle(buttonText[validity], for: .normal)
dismissButton.backgroundColor = backgroundColor[validity]
validityLabel.text = validityString[validity]
validityLabel.text = validity.l10n
headerBackground.backgroundColor = backgroundColor[validity]
validityImage.image = validityIcon[validity]
}
Expand Down
2 changes: 1 addition & 1 deletion DGCAVerifier/ViewControllers/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
//
// Home.swift
// PatientScannerDemo
// DGCAVerifier
//
// Created by Yannick Spreen on 4/25/21.
//
Expand Down
6 changes: 4 additions & 2 deletions DGCAVerifier/ViewControllers/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ class SettingsTableVC: UITableViewController {
var loading = false

override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
[
"Last Updated: \(LocalData.sharedInstance.lastFetch.dateTimeString)",
let format = l10n("settings.last-updated")

return [
String(format: format, LocalData.sharedInstance.lastFetch.dateTimeString),
"",
"",
][section]
Expand Down
Loading

0 comments on commit b44ab96

Please sign in to comment.