Skip to content

Commit

Permalink
Merge pull request #181 from decentralised-dataexchange/feature/144-U…
Browse files Browse the repository at this point in the history
…pdate-Localisation-strings-and-add-SDK-config-
  • Loading branch information
georgepadayatti authored Nov 17, 2023
2 parents f424fea + 944e1aa commit 80f1dbd
Show file tree
Hide file tree
Showing 18 changed files with 224 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class BBConsentPrivacyDashboardiOS: UIViewController {
public var turnOnUserRequests = false
public var turnOnAskMeSection = false
public var turnOnAttributeDetailScreen = false
public var languageCode = "en"
// Demo server by default
public var baseUrl = "https://demo-consent-bb-api.igrant.io/v2"

Expand Down
48 changes: 24 additions & 24 deletions PrivacyDashboardiOS/Classes/Constatnts/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ struct Constant {
static let KPromptMsgNotConfigured = "Not Configured"

static let areYouSureYouWantToAllow = "Are you sure you want to allow?"
static let allow = "Allow"
static let allow = "bb_consent_data_attribute_allow".localized
static let areYouSureYouWantToDisAllow = "Are you sure you want to disallow?"
static let disallow = "Disallow"
static let disallow = "bb_consent_dashboard_disallow".localized
static let areYouWantToDisallowAll = "Are you sure you want to disallow all ?"
static let disallowAll = "Disallow All"
static let invalidURL = "Invalid URL"

static let cancelRequest = "Cancel request"
static let cancelRequest = "bb_consent_user_request_cancel_request".localized
static let yourRequestCancelled = "Your request cancelled successfully"
static let OK = "OK"
static let cancel = "Cancel"
static let cancel = "bb_consent_cancel".localized
static let doYouWantToCancelThisRequest = "Do you want to cancel this request?"
}

Expand Down Expand Up @@ -133,30 +133,30 @@ struct Constant {
}

struct Strings {
static let days = "Days"
static let consent = "CONSENT"
static let consentAllowedNoteOne = "If you choose “Allow”, you are consenting to the use of your personal data "
static let days = "bb_consent_data_attribute_detail_days_with_count".localized
static let consent = "bb_consent_data_attribute_detail_consent".localized
static let consentAllowedNoteOne = "bb_consent_data_attribute_detail_allow_consent_rule".localized
static let consentAllowedNoteTwo = " permanently for any analytics or third party usage beyond the purposes you have signed up with."
static let consentDisAllowedNote = "If you choose “Disallow”, you are disabling the use of your personal data for any analytics or third party usage beyond the purposes you have signed up with."
static let consentDefaultNote = "If you choose “Ask me”, you consent to use your data for the selected period. When the time period expires, you get notified in real time requesting for consent when the data provider is using your data."
static let cancel = "Cancel"
static let privacyPolicy = "Privacy Policy"
static let policy = "Policy"
static let userRequests = "User Requests"
static let consentHistory = "Consent History"
static let allow = "Allow"
static let disallow = "Disallow"
static let consentDisAllowedNote = "bb_consent_data_attribute_detail_disallow_consent_rule".localized
static let consentDefaultNote = "bb_consent_data_attribute_detail_askme_consent_rule".localized
static let cancel = "bb_consent_cancel".localized
static let privacyPolicy = "bb_consent_web_view_privacy_policy".localized
static let policy = "bb_consent_web_view_policy".localized
static let userRequests = "bb_consent_user_request_user_request".localized
static let consentHistory = "bb_consent_history_consent_history".localized
static let allow = "bb_consent_data_attribute_allow".localized
static let disallow = "bb_consent_dashboard_disallow".localized
static let askMe = "AskMe"
static let noHistoryAbailable = "No history available"
static let downloadData = "Download Data"
static let deleteData = "Delete Data"
static let requestInitiated = "Request Initiated"
static let requestAcknowledged = "Request Acknowledged"
static let requestProcessed = "Request Processed"
static let noHistoryAbailable = "bb_consent_history_empty_consent_history".localized
static let downloadData = "bb_consent_user_request_download_data".localized
static let deleteData = "bb_consent_user_request_delete_data".localized
static let requestInitiated = "bb_consent_user_request_request_initiated".localized
static let requestAcknowledged = "bb_consent_user_request_request_acknowledged".localized
static let requestProcessed = "bb_consent_user_request_request_processed".localized
static let downloadDataRequestStatus = "Download Data Request Status"
static let deleteDataRequestStatus = "Delete Data Request Status"
static let dataAgreements = "DATA AGREEMENTS"
static let dataAttributes = "DATA ATTRIBUTES"
static let dataAgreements = "bb_consent_dashboard_data_agreements".localized
static let dataAttributes = "bb_consent_data_attribute_data_attributes" .localized
}

struct URLStrings {
Expand Down
8 changes: 8 additions & 0 deletions PrivacyDashboardiOS/Classes/Extension/ExtensionMethods.swift
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,11 @@ extension NSMutableAttributedString {
return false
}
}

extension String {
var localized: String {
let languageCode = BBConsentPrivacyDashboardiOS.shared.languageCode
let bundle = Bundle(url: Bundle.main.bundleURL.appendingPathComponent("Frameworks").appendingPathComponent("PrivacyDashboardiOS.framework").appendingPathComponent("/\(languageCode).lproj")) ?? Bundle.main
return NSLocalizedString(self, tableName: nil, bundle: bundle, value: "", comment: "")
}
}
3 changes: 2 additions & 1 deletion PrivacyDashboardiOS/Classes/PrivacyDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class PrivacyDashboard {
public static var receiveDataBackFromPrivacyDashboard : (([String: Any]) -> Void)?

// MARK: - Invoking 'PrivacyDashboard' iOS SDK
public static func showPrivacyDashboard(withApiKey: String, withUserId: String, withOrgId: String, withBaseUrl: String, accessToken: String = "", turnOnAskme: Bool, turnOnUserRequest: Bool, turnOnAttributeDetail: Bool) {
public static func showPrivacyDashboard(withApiKey: String, withUserId: String, withOrgId: String, withBaseUrl: String, withLocale: String?, accessToken: String = "", turnOnAskme: Bool, turnOnUserRequest: Bool, turnOnAttributeDetail: Bool) {
BBConsentPrivacyDashboardiOS.shared.languageCode = withLocale ?? "en"
BBConsentPrivacyDashboardiOS.shared.turnOnUserRequests = turnOnUserRequest
BBConsentPrivacyDashboardiOS.shared.turnOnAskMeSection = turnOnAskme
BBConsentPrivacyDashboardiOS.shared.turnOnAttributeDetailScreen = turnOnAttributeDetail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ extension BBConsentAttributesDetailViewController: UITableViewDelegate,UITableVi
if indexPath.row != 2 {
let allowCell = tableView.dequeueReusableCell(withIdentifier:Constant.CustomTabelCell.KOrgDetailedConsentAllowCellID,for: indexPath)
if indexPath.row == 0 {
allowCell.textLabel?.text = NSLocalizedString(Constant.Alert.allow, comment: "")
allowCell.textLabel?.text = Constant.Alert.allow
if consent?.status?.consented == .Allow {
allowCell.accessoryType = .checkmark
preIndexPath = indexPath
} else {
allowCell.accessoryType = .none
}
} else {
allowCell.textLabel?.text = NSLocalizedString(Constant.Alert.disallow, comment: "")
allowCell.textLabel?.text = Constant.Alert.disallow
if consent?.status?.consented == .Disallow {
preIndexPath = indexPath
allowCell.accessoryType = .checkmark
Expand All @@ -108,22 +108,22 @@ extension BBConsentAttributesDetailViewController: UITableViewDelegate,UITableVi
if consent?.status?.consented == .AskMe {
askMeCell.tickImage.isHidden = false
let days : Int = (consent?.status?.days)!
askMeCell.selectedDaysLbl.text = "\(days) " + NSLocalizedString(Constant.Strings.days, comment: "")
askMeCell.selectedDaysLbl.text = "\(days) " + Constant.Strings.days
askMeCell.askMeSlider.setValue(Float(days), animated: false)
preIndexPath = indexPath

} else {
let days = 30
askMeCell.tickImage.isHidden = true
askMeCell.selectedDaysLbl.text = "\(days) " + NSLocalizedString(Constant.Strings.days, comment: "")
askMeCell.selectedDaysLbl.text = "\(days) " + Constant.Strings.days
askMeCell.askMeSlider.setValue(Float(days), animated: false)
}
return askMeCell
}
}

func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return NSLocalizedString(Constant.Strings.consent, comment: "")
return Constant.Strings.consent
}

func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
Expand All @@ -133,11 +133,11 @@ extension BBConsentAttributesDetailViewController: UITableViewDelegate,UITableVi
}

if consent?.status?.consented == .Allow {
return NSLocalizedString(Constant.Strings.consentAllowedNoteOne, comment: "") + (consentTitle) + NSLocalizedString(Constant.Strings.consentAllowedNoteTwo, comment: "")
return Constant.Strings.consentAllowedNoteOne + (consentTitle) + Constant.Strings.consentAllowedNoteTwo
} else if consent?.status?.consented == .Disallow {
return NSLocalizedString(Constant.Strings.consentDisAllowedNote, comment: "")
return Constant.Strings.consentDisAllowedNote
} else {
return NSLocalizedString(Constant.Strings.consentDefaultNote, comment: "")
return Constant.Strings.consentDefaultNote
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ class BBConsentAttributesViewController: BBConsentBaseViewController {
}

func showConfirmationAlert() {
let alerController = UIAlertController(title: Constant.AppSetupConstant.KAlertTitle, message: NSLocalizedString(Constant.Alert.areYouWantToDisallowAll, comment: ""), preferredStyle: .alert)
alerController.addAction(UIAlertAction(title: NSLocalizedString(Constant.Alert.disallowAll, comment: ""), style: .destructive, handler: {(action:UIAlertAction) in
let alerController = UIAlertController(title: Constant.AppSetupConstant.KAlertTitle, message: Constant.Alert.areYouWantToDisallowAll, preferredStyle: .alert)
alerController.addAction(UIAlertAction(title: Constant.Alert.disallowAll, style: .destructive, handler: {(action:UIAlertAction) in
self.callDisallowAllApi()
}));
alerController.addAction(UIAlertAction(title: NSLocalizedString(Constant.Strings.cancel, comment: ""), style: .cancel, handler: {(action:UIAlertAction) in
alerController.addAction(UIAlertAction(title: Constant.Strings.cancel, style: .cancel, handler: {(action:UIAlertAction) in
}));
present(alerController, animated: true, completion: nil)
}
Expand Down Expand Up @@ -246,7 +246,7 @@ extension BBConsentAttributesViewController : UITableViewDelegate,UITableViewDa
consentCell.consent = consentVal
consentCell.showData()
if isFromQR {
consentCell.consentTypeLbl.text = NSLocalizedString(Constant.Alert.allow, comment: "")
consentCell.consentTypeLbl.text = Constant.Alert.allow
// consentCell.rightArrow.isHidden = true
}
return consentCell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class BBConsentAttributeTableViewCell: UITableViewCell {
self.titleLbl.text = self.consentInfo?.name
self.dataLbl.text = ""
if consent == true {
self.consentTypeLbl.text = NSLocalizedString(Constant.Strings.allow, comment: "")
self.consentTypeLbl.text = Constant.Strings.allow
} else{
self.consentTypeLbl.text = NSLocalizedString(Constant.Strings.disallow, comment: "")
self.consentTypeLbl.text = Constant.Strings.disallow
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BBConsentHistoryViewController: BBConsentBaseViewController {

override func viewWillAppear(_ animated: Bool) {
navigationController?.navigationBar.isHidden = false
navigationItem.title = NSLocalizedString(Constant.Strings.consentHistory, comment: "")
navigationItem.title = Constant.Strings.consentHistory
}


Expand Down Expand Up @@ -74,7 +74,7 @@ extension BBConsentHistoryViewController: WebServiceTaskManagerProtocol {
} else {
self.histories = data.consentHistory
if (self.histories?.count ?? 0) < 1 {
self.historyListTable.setState(.withImage(image: nil, title: "", message: NSLocalizedString(Constant.Strings.noHistoryAbailable, comment: "")))
self.historyListTable.setState(.withImage(image: nil, title: "", message: Constant.Strings.noHistoryAbailable))
}
}
self.historyListTable.reloadData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class BBConsentOrganisationViewController: BBConsentBaseViewController {
let actionSheetController: UIAlertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

// Create an action
let firstAction: UIAlertAction = UIAlertAction(title: NSLocalizedString(Constant.Strings.privacyPolicy, comment: ""), style: .default) { action -> Void in
let firstAction: UIAlertAction = UIAlertAction(title: Constant.Strings.privacyPolicy, style: .default) { action -> Void in

if let privacyPolicy = self.organization?.privacyPolicy {
if self.verifyUrl(urlString: privacyPolicy) {
Expand All @@ -135,15 +135,15 @@ class BBConsentOrganisationViewController: BBConsentBaseViewController {
}
}

let secondAction: UIAlertAction = UIAlertAction(title: NSLocalizedString(Constant.Strings.userRequests, comment: ""), style: .default) { action -> Void in
let secondAction: UIAlertAction = UIAlertAction(title: Constant.Strings.userRequests, style: .default) { action -> Void in
self.showRequestedStatus()
}

let thirdAction: UIAlertAction = UIAlertAction(title: NSLocalizedString(Constant.Strings.consentHistory, comment: ""), style: .default) { action -> Void in
let thirdAction: UIAlertAction = UIAlertAction(title: Constant.Strings.consentHistory, style: .default) { action -> Void in
self.showConsentHistory()
}

let cancelAction: UIAlertAction = UIAlertAction(title: NSLocalizedString(Constant.Strings.cancel, comment: ""), style: .cancel) { action -> Void in }
let cancelAction: UIAlertAction = UIAlertAction(title: Constant.Strings.cancel, style: .cancel) { action -> Void in }

// Add actions
actionSheetController.addAction(firstAction)
Expand Down Expand Up @@ -476,12 +476,12 @@ extension BBConsentOrganisationViewController: ExpandableLabelDelegate ,PurposeC
serviceManager.updatePurpose(dataAgreementRecordId: filteredRecord?[0].id ?? "", dataAgreementId: filteredRecord?[0].dataAgreementId ?? "", status: status)
}
}));
alerController.addAction(UIAlertAction(title: NSLocalizedString(Constant.Strings.cancel, comment: ""), style: .cancel, handler: {(action:UIAlertAction) in
alerController.addAction(UIAlertAction(title: Constant.Strings.cancel, style: .cancel, handler: {(action:UIAlertAction) in
cell.statusSwitch.isOn = !cell.statusSwitch.isOn
}));

} else {
alerController.addAction(UIAlertAction(title: NSLocalizedString(Constant.Strings.cancel, comment: ""), style: .destructive, handler: {(action:UIAlertAction) in
alerController.addAction(UIAlertAction(title: Constant.Strings.cancel, style: .destructive, handler: {(action:UIAlertAction) in
cell.statusSwitch.isOn = !cell.statusSwitch.isOn
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class BBConsentDashBoardOverviewCell: UITableViewCell {

override func awakeFromNib() {
super.awakeFromNib()
let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: "Read More")
let colorRange = NSMakeRange(0,"Read More".count)
let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: "bb_consent_dashboard_read_more".localized)
let colorRange = NSMakeRange(0,"bb_consent_dashboard_read_more".localized.count)
attributeString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor(red:0.59, green:0.59, blue:0.61, alpha:1), range:colorRange)
overViewLbl.collapsedAttributedLink = attributeString

let readLessattributeString: NSMutableAttributedString = NSMutableAttributedString(string: "Read Less")
let colorRangeReadLess = NSMakeRange(0,"Read Less".count)
let readLessattributeString: NSMutableAttributedString = NSMutableAttributedString(string: "bb_consent_dashboard_read_less".localized)
let colorRangeReadLess = NSMakeRange(0,"bb_consent_dashboard_read_less".localized.count)
readLessattributeString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor(red:1, green:0.53, blue:0.54, alpha:1), range:colorRangeReadLess)
overViewLbl.expandedAttributedLink = readLessattributeString
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BBConsentDashboardUsagePurposeCell: UITableViewCell {
self.titleLbl.text = self.consentInfo?.name

if consentedCount ?? 0 > 0 {
var valueString = "Allow "
var valueString = "bb_consent_data_attribute_allow".localized
valueString.append(": ")
let consentedStr = String(consentedCount ?? 0)
valueString.append(consentedStr)
Expand All @@ -56,7 +56,7 @@ class BBConsentDashboardUsagePurposeCell: UITableViewCell {
}
self.dataLbl.text = valueString
} else {
self.dataLbl.text = "Disallow"
self.dataLbl.text = "bb_consent_dashboard_disallow".localized
}
}

Expand Down
Loading

0 comments on commit 80f1dbd

Please sign in to comment.