Skip to content

Commit

Permalink
Add #207: Automated localisation using bebelish
Browse files Browse the repository at this point in the history
  • Loading branch information
Mumthasir mohammed committed Jan 11, 2024
1 parent 82be3ee commit 72cc271
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 153 deletions.
4 changes: 3 additions & 1 deletion PrivacyDashboardiOS/Classes/PrivacyDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class PrivacyDashboard {
}
}

public static func configure(withApiKey: String, withUserId: String, withOrgId: String, withBaseUrl: String, accessToken: String = "") {
public static func configure(withApiKey: String, withUserId: String, withOrgId: String, withBaseUrl: String, withLocale: String, accessToken: String = "") {
let frameworkBundle = Bundle(for: BBConsentOrganisationViewController.self)
let bundleURL = frameworkBundle.resourceURL?.appendingPathComponent("PrivacyDashboardiOS.bundle")
var storyboard = UIStoryboard()
Expand All @@ -75,6 +75,8 @@ public class PrivacyDashboard {
let myBundle = Bundle(for: BBConsentOrganisationViewController.self)
storyboard = UIStoryboard(name: "PrivacyDashboard", bundle: myBundle)
}

BBConsentPrivacyDashboardiOS.shared.languageCode = withLocale == "" ? "en" : withLocale
BBConsentPrivacyDashboardiOS.shared.userId = withUserId
BBConsentPrivacyDashboardiOS.shared.accessToken = accessToken
let sharingVC = storyboard.instantiateViewController(withIdentifier: "BBConsentDataSharingVC") as? BBConsentDataSharingVC ?? BBConsentDataSharingVC()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class BBConsentDataAgreementVC: UITableViewController {
}

self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "DAcell")
self.navigationItem.title = "Data Agreement"
self.navigationItem.title = "bb_consent_data_agreement_policy_data_agreement".localized
self.navigationItem.leftItemsSupplementBackButton = true
self.navigationItem.largeTitleDisplayMode = .always
navigationController?.navigationBar.tintColor = .black
Expand All @@ -55,20 +55,20 @@ class BBConsentDataAgreementVC: UITableViewController {
func setData() {
if dataAgreement?.count ?? 0 > 0 {
let years = (Int(dataAgreement?[0].retentionPeriod ?? "") ?? 0)/365
let retenetionPeriod = (years > 1) ? "\(years) Years" : "\(years) Year"
let retenetionPeriod = (years > 1) ? "\(years )" + "bb_consent_data_agreement_years".localized : "\(years )" + "bb_consent_data_agreement_years".localized

purposeSectionDic = ["Purpose": dataAgreement?[0].name ?? "", "Purpose Description": dataAgreement?[0].descriptionField ?? "", "Lawful basis of processing": dataAgreement?[0].lawfulBasis ?? ""]
policySectionDict = ["Policy URL": dataAgreement?[0].policyURL ?? "", "Jurisdiction": dataAgreement?[0].jurisdiction ?? "", "Third party data sharing": dataAgreement?[0].thirdPartyDisclosure ?? "", "Industry scope": dataAgreement?[0].industryScope ?? "", "Geographic restriction": dataAgreement?[0].geaographicRestriction ?? "", "Retention period": retenetionPeriod, "Storage Location": dataAgreement?[0].storageLocation ?? ""]
DPIASectionDic = ["DPIA Date": dataAgreement?[0].DPIAdate ?? "", "DPIA Summary": dataAgreement?[0].DPIASummary ?? ""]
purposeSectionDic = ["bb_consent_data_agreement_policy_purpose": dataAgreement?[0].name ?? "", "bb_consent_data_agreement_policy_purpose_description": dataAgreement?[0].descriptionField ?? "", "bb_consent_data_agreement_policy_lawful_basis_of_processing": dataAgreement?[0].lawfulBasis ?? ""]
policySectionDict = ["bb_consent_data_agreement_policy_policy_url": dataAgreement?[0].policyURL ?? "", "bb_consent_data_agreement_policy_jurisdiction": dataAgreement?[0].jurisdiction ?? "", "bb_consent_data_agreement_policy_third_party_disclosure": dataAgreement?[0].thirdPartyDisclosure ?? "", "bb_consent_data_agreement_policy_industry_scope": dataAgreement?[0].industryScope ?? "", "bb_consent_data_agreement_policy_geographic_restriction": dataAgreement?[0].geaographicRestriction ?? "", "bb_consent_data_agreement_policy_retention_period": retenetionPeriod, "bb_consent_data_agreement_policy_storage_location": dataAgreement?[0].storageLocation ?? ""]
DPIASectionDic = ["bb_consent_data_agreement_policy_dpia_date": dataAgreement?[0].DPIAdate ?? "", "bb_consent_data_agreement_policy_dpia_summary": dataAgreement?[0].DPIASummary ?? ""]
dataAgreementDic = [purposeSectionDic, policySectionDict, DPIASectionDic]

} else {
let years = Int(instance?.policy?.dataRetentionPeriodDays ?? 0)/365
let retenetionPeriod = (years > 1) ? "\(years) Years" : "\(years) Year"
let retenetionPeriod = (years > 1) ? "\(years )"+"bb_consent_data_agreement_years".localized : "\(years )" + "bb_consent_data_agreement_years".localized

purposeSectionDic = ["Purpose": instance?.purpose ?? "", "Purpose Description": instance?.purposeDescription ?? "", "Lawful basis of processing": instance?.lawfulBasis ?? ""]
policySectionDict = ["Policy URL": instance?.policy?.url ?? "", "Jurisdiction": instance?.policy?.jurisdiction ?? "", "Third party data sharing": instance?.policy?.thirdPartyDataSharing ?? 0, "Industry scope": instance?.policy?.industrySector ?? "", "Geographic restriction": instance?.policy?.geographicRestriction ?? "", "Retention period": retenetionPeriod, "Storage Location": instance?.policy?.storageLocation ?? ""]
DPIASectionDic = ["DPIA Date":instance?.dpiaDate ?? "", "DPIA Summary": instance?.dpiaSummaryUrl ?? ""]
purposeSectionDic = ["bb_consent_data_agreement_policy_purpose": instance?.purpose ?? "", "bb_consent_data_agreement_policy_purpose_description": instance?.purposeDescription ?? "", "bb_consent_data_agreement_policy_lawful_basis_of_processing": instance?.lawfulBasis ?? ""]
policySectionDict = ["Policy URL": instance?.policy?.url ?? "", "bb_consent_data_agreement_policy_jurisdiction": instance?.policy?.jurisdiction ?? "", "bb_consent_data_agreement_policy_third_party_disclosure": instance?.policy?.thirdPartyDataSharing ?? 0, "bb_consent_data_agreement_policy_industry_scope": instance?.policy?.industrySector ?? "", "bb_consent_data_agreement_policy_geographic_restriction": instance?.policy?.geographicRestriction ?? "", "bb_consent_data_agreement_policy_retention_period": retenetionPeriod, "bb_consent_data_agreement_policy_storage_location": instance?.policy?.storageLocation ?? ""]
DPIASectionDic = ["bb_consent_data_agreement_policy_dpia_date":instance?.dpiaDate ?? "", "bb_consent_data_agreement_policy_dpia_summary": instance?.dpiaSummaryUrl ?? ""]
dataAgreementDic = [purposeSectionDic, policySectionDict, DPIASectionDic]
}
}
Expand Down Expand Up @@ -133,9 +133,9 @@ class BBConsentDataAgreementVC: UITableViewController {
let item = dataAgreementDic[indexPath.section]
let keys = item.map({ $0.key })
let values = item.map({ $0.value })
cell.titleLabel.text = keys[indexPath.row]
cell.titleLabel.text = keys[indexPath.row].localized
let val = "\(values[indexPath.row])"
cell.descLabel.text = val
cell.descLabel.text = val.localized
return cell
}
}
128 changes: 81 additions & 47 deletions PrivacyDashboardiOS/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,47 +1,81 @@
/*
Localizable.strings
Pods

Created by Mumthasir mohammed on 14/09/23.

*/
"bb_consent_cancel" = "Cancel";
"bb_consent_general_more" = "More" ;
"bb_consent_dashboard_overview" = "Overview" ;
"bb_consent_dashboard_usage_purpose" = "Usage Purposes" ;
"bb_consent_dashboard_data_agreements" = "DATA AGREEMENTS" ;
"bb_consent_dashboard_disallow" = "Disallow" ;
"bb_consent_dashboard_allow" = "Allow : %1$d of %2$d" ;
"bb_consent_dashboard_read_less" = "Read less" ;
"bb_consent_dashboard_read_more" = "Read more" ;
"bb_consent_dashboard_empty_message" = "No active data agreements available." ;
"bb_consent_data_attribute_allow" = "Allow" ;
"bb_consent_data_attribute_my_data_consents" = "My data consents" ;
"bb_consent_data_attribute_data_attributes" = "DATA ATTRIBUTES" ;
"bb_consent_data_attribute_read_policy" = "Read policy" ;
"bb_consent_web_view_privacy_policy" = "Privacy Policy" ;
"bb_consent_web_view_policy" = "Policy" ;
"bb_consent_history_consent_history" = "Consent history" ;
"bb_consent_history_empty_consent_history" = "No history available" ;
"bb_consent_data_attribute_detail_ask_me" = "Ask Me" ;
"bb_consent_data_attribute_detail_allow_consent_rule" = "If you choose \"Allow\", you are consenting to the use of your personal data permanently for any analytic or third party usage beyond the purposes you have signed up with." ;
"bb_consent_data_attribute_detail_disallow_consent_rule" = "If you choose \"Disallow\", you are disabling the use of your personal data for any analytic or third party usage beyond the purposes you have signed up with." ;
"bb_consent_data_attribute_detail_askme_consent_rule" = "If you choose \"Ask me\", you consent to the use of your data for the selected period. When time period expires, you get notified in real time requesting for consent when the data provider is using your data." ;
"bb_consent_data_attribute_detail_consent" = "Consent" ;
"bb_consent_data_attribute_detail_days_with_count" = "Days" ;
"bb_consent_error_internet" = "Network not available." ;
"bb_consent_error_unexpected" = "Unexpected error, Please try again." ;
"bb_consent_user_request_new_request" = "New Request" ;
"bb_consent_user_request_user_request" = "User Requests" ;
"bb_consent_user_request_download_data" = "Download data" ;
"bb_consent_user_request_forget_me" = "Forget me" ;
"bb_consent_user_request_cancel_request" = "Cancel request" ;
"bb_consent_user_request_request_initiated" = "Request Initiated" ;
"bb_consent_user_request_request_acknowledged" = "Request Acknowledged" ;
"bb_consent_user_request_request_processed" = "Request processed" ;
"bb_consent_user_request_confirmation" = "Confirmation" ;
"bb_consent_user_request_confirmation_message" = "A new request to %1$s will be sent to the %2$s" ;
"bb_consent_user_request_data_delete" = "Data delete" ;
"bb_consent_user_request_confirm" = "Confirm" ;
"bb_consent_user_request_request_cancelled" = "Request cancelled successfully." ;
"bb_consent_user_request_delete_data" = "Delete Data" ;

/* General */
"bb_consent_cancel" = "Cancel";
"bb_consent_general_more" = "More";

/* Dashboard */
"bb_consent_dashboard_overview" = "Overview";
"bb_consent_dashboard_usage_purpose" = "Usage Purposes";
"bb_consent_dashboard_data_agreements" = "DATA AGREEMENTS";
"bb_consent_dashboard_disallow" = "Disallow";
"bb_consent_dashboard_allow" = "Allow : %1$d of %2$d";
"bb_consent_dashboard_read_less" = "Read less";
"bb_consent_dashboard_read_more" = "Read more";
"bb_consent_dashboard_empty_message" = "No active data agreements available.";

/* Data attribute */
"bb_consent_data_attribute_allow" = "Allow";
"bb_consent_data_attribute_my_data_consents" = "My data consents";
"bb_consent_data_attribute_data_attributes" = "DATA ATTRIBUTES";
"bb_consent_data_attribute_read_policy" = "Read policy";

/* Webview */
"bb_consent_web_view_privacy_policy" = "Privacy Policy";
"bb_consent_web_view_policy" = "";

/* Consent history */
"bb_consent_history_consent_history" = "Consent history";
"bb_consent_history_empty_consent_history" = "No history available";

/* Data attrribute detail */
"bb_consent_data_attribute_detail_ask_me" = "Ask Me";
"bb_consent_data_attribute_detail_allow_consent_rule" = "If you choose \"Allow\", you are consenting to the use of your personal data permanently for any analytic or third party usage beyond the purposes you have signed up with.";
"bb_consent_data_attribute_detail_disallow_consent_rule" = "If you choose \"Disallow\", you are disabling the use of your personal data for any analytic or third party usage beyond the purposes you have signed up with.";
"bb_consent_data_attribute_detail_askme_consent_rule" = "If you choose \"Ask me\", you consent to the use of your data for the selected period. When time period expires, you get notified in real time requesting for consent when the data provider is using your data.";
"bb_consent_data_attribute_detail_consent" = "Consent";
"bb_consent_data_attribute_detail_days_with_count" = "%1$d Days";

/* Error */
"bb_consent_error_internet" = "Network not available.";
"bb_consent_error_unexpected" = "Unexpected error, Please try again.";

/* User request */
"bb_consent_user_request_new_request" = "New Request";
"bb_consent_user_request_user_request" = "User Requests";
"bb_consent_user_request_download_data" = "Download data";
"bb_consent_user_request_forget_me" = "Forget me";
"bb_consent_user_request_cancel_request" = "Cancel request";
"bb_consent_user_request_request_initiated" = "Request Initiated";
"bb_consent_user_request_request_acknowledged" = "Request Acknowledged";
"bb_consent_user_request_request_processed" = "Request processed";
"bb_consent_user_request_confirmation" = "Confirmation";
"bb_consent_user_request_confirmation_message" = "A new request to %1$s will be sent to the %2$s";
"bb_consent_user_request_data_delete" = "Data delete";
"bb_consent_user_request_confirm" = "Confirm";
"bb_consent_user_request_request_cancelled" = "Request cancelled successfully.";
"bb_consent_user_request_delete_data" = "Delete Data";

/* Data sharing UI */
"bb_consent_data_sharing_main_desc" = "%1$s wants to access the following data from %2$s for %3$s";
"bb_consent_data_sharing_sensitive_info_see_data_agreement_details_and_terms_of_services" = "You may be sharing sensitive info with this site or app. See the Data Agreement details and Terms of Services";
"bb_consent_data_sharing_make_sure_that_you_trust" = "Make sure that you trust %1$s";
"bb_consent_data_sharing_by_authrizing_text" = "By clicking authorize, %1$s App will be able to read the following data attributes";
"bb_consent_data_sharing_authorize" = "Authorize";
"bb_consent_data_sharing_cancel" = "Cancel";

/* Data Agreement Policy */
"bb_consent_data_agreement_policy_data_agreement" = "Data Agreement";
"bb_consent_data_agreement_policy_purpose" = "Purpose";
"bb_consent_data_agreement_policy_purpose_description" = "Purpose description";
"bb_consent_data_agreement_policy_lawful_basis_of_processing" = "Lawful usage of processing";
"bb_consent_data_agreement_policy_policy_url" = "Policy URL";
"bb_consent_data_agreement_policy_jurisdiction" = "Jurisdiction";
"bb_consent_data_agreement_policy_third_party_disclosure" = "Third party disclosure";
"bb_consent_data_agreement_policy_industry_scope" = "Industry scope";
"bb_consent_data_agreement_policy_geographic_restriction" = "Geographic restriction";
"bb_consent_data_agreement_policy_retention_period" = "Retention period";
"bb_consent_data_agreement_policy_storage_location" = "Storage location";
"bb_consent_data_agreement_policy_dpia_date" = "DPIA Date";
"bb_consent_data_agreement_policy_dpia_summary" = "DPIA Summary";
"bb_consent_data_agreement_policy_version" = "Version";
"bb_consent_data_agreement_years" = "<year> years";
Loading

0 comments on commit 72cc271

Please sign in to comment.