Browse Source

First stab at Hindi localization!

pull/92/head
Abhishek 5 years ago
parent
commit
651176a304
  1. 5
      Clocker/Clocker.xcodeproj/project.pbxproj
  2. 16
      Clocker/Clocker/en.lproj/Localizable.strings
  3. 10
      Clocker/Clocker/hi.lproj/InfoPlist.strings
  4. 38
      Clocker/Clocker/hi.lproj/Localizable.strings
  5. 4
      Clocker/Dependencies/Date Additions/Date+TimeAgo.swift
  6. 7
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  7. 9
      Clocker/Panel/ParentPanelController.swift
  8. 3
      Clocker/Preferences/About/AboutViewController.swift
  9. 10
      Clocker/Preferences/General/PreferencesViewController.swift
  10. 57
      Clocker/Preferences/Permissions/PermissionsViewController.swift

5
Clocker/Clocker.xcodeproj/project.pbxproj

@ -216,6 +216,8 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
352AF497232E07B400D96FA7 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/InfoPlist.strings; sourceTree = "<group>"; };
352AF499232E07B400D96FA7 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/Localizable.strings; sourceTree = "<group>"; };
3545C52A22612BCC00121E25 /* RateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RateTests.swift; sourceTree = "<group>"; }; 3545C52A22612BCC00121E25 /* RateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RateTests.swift; sourceTree = "<group>"; };
3595FACF227F88BC0044A12A /* UserDefaults + KVOExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults + KVOExtensions.swift"; sourceTree = "<group>"; }; 3595FACF227F88BC0044A12A /* UserDefaults + KVOExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults + KVOExtensions.swift"; sourceTree = "<group>"; };
35C36EE022595EFD002FA5C6 /* StatusContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusContainerView.swift; sourceTree = "<group>"; }; 35C36EE022595EFD002FA5C6 /* StatusContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusContainerView.swift; sourceTree = "<group>"; };
@ -970,6 +972,7 @@
English, English,
en, en,
Base, Base,
hi,
); );
mainGroup = DD4F7BF913C30F9F00825C6E; mainGroup = DD4F7BF913C30F9F00825C6E;
productRefGroup = DD4F7C0513C30F9F00825C6E /* Products */; productRefGroup = DD4F7C0513C30F9F00825C6E /* Products */;
@ -1251,6 +1254,7 @@
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (
9A13BAE11CA882FA007C6CBE /* en */, 9A13BAE11CA882FA007C6CBE /* en */,
352AF497232E07B400D96FA7 /* hi */,
); );
name = InfoPlist.strings; name = InfoPlist.strings;
path = Clocker; path = Clocker;
@ -1260,6 +1264,7 @@
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (
9A13BAEB1CA88A76007C6CBE /* en */, 9A13BAEB1CA88A76007C6CBE /* en */,
352AF499232E07B400D96FA7 /* hi */,
); );
name = Localizable.strings; name = Localizable.strings;
path = Clocker; path = Clocker;

16
Clocker/Clocker/en.lproj/Localizable.strings

@ -20,3 +20,19 @@
"start-at-login" = "Start At Login"; "start-at-login" = "Start At Login";
"setup-steps" = "It only takes 3 steps to set up Clocker"; "setup-steps" = "It only takes 3 steps to set up Clocker";
"Permissions-Header" = "Permissions"; "Permissions-Header" = "Permissions";
"See your next Calendar event here." = "See your next Calendar event here.";
"Click here to start." = "Click here to start.";
"Reminders Access" = "Reminders Access";
"Calendar Access" = "Calendar Access";
"Permissions" = "Permissions";
"Calendar Detail" = "Upcoming events from your personal and shared calendars can be shown in the menubar and the panel.";
"Reminders Detail" = "Set reminders in the timezone of the location of your choice. Your reminders are stored in the default Reminders app.";
"Privacy Text" = "You can change this later in the Privacy section of the System Preferences.";
"Granted Button Text" = "Granted";
"Denied Button Text" = "Denied";
"Grant Button Text" = "Grant";
"Start at Login" = "Start Clocker at Login";
"Selected Timezones" = "Selected Timezones";
"Sort by Time Difference" = "Sort by Time Difference";
"Sort by Name" = "Sort by Name";
"Sort by Label" = "Sort by Label";

10
Clocker/Clocker/hi.lproj/InfoPlist.strings

@ -0,0 +1,10 @@
/*
InfoPlist.strings
Clocker
Created by Abhishek Banthia on 3/27/16.
*/
"CFBundleDisplayName" = "विव क समय";
"CFBundleName" = "विव क समय";

38
Clocker/Clocker/hi.lproj/Localizable.strings

@ -0,0 +1,38 @@
/*
Localizable.strings
Clocker
Created by Abhishek Banthia on 3/27/16.
*/
"Thank you for helping make Clocker even better!" = "Thank you for helping make Clocker even better!";
"iRateMessageTitle" = "Rate %@";
"iRateAppMessage" = "If you enjoy using %@, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!";
"iRateGameMessage" = "If you enjoy playing %@, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!";
"iRateCancelButton" = "No, Thanks";
"iRateRateButton" = "Rate It Now";
"iRateRemindButton" = "Remind Me Later";
"iRateUpdateMessage" = "Update now?";
"ClockerVersion" = "Version %@";
"CLFeedbackAlertTitle" = "Thank you for helping make Clocker even better!";
"app-name" = "Clocker";
"start-at-login" = "Start At Login";
"setup-steps" = "It only takes 3 steps to set up Clocker";
"Permissions-Header" = "अनमति";
"See your next Calendar event here." = "अपन अगलडर कयकरम यह।";
"Click here to start." = "श करनिए यहिक कर।";
"Reminders Access" = "रिडर अनमति";
"Calendar Access" = "कडर अनमति";
"Permissions" = "अनमति";
"Reminders Detail" = "अपन पसद कन क समय कर मिडर सट कर। आपकिडर डिट रिडर ऐप मरहत किए ज।";
"Calendar Detail" = "अपनि और सडर स आन घटनर और पनल मि सकत।";
"Privacy Text" = "आप आपक पसद भविय मिटम पिज कइवस अनग म बदल सकत।";
"Granted Button Text" = "सत";
"Denied Button Text" = "इनकर कि";
"Grant Button Text" = "अनन";
"Start at Login" = "लिन पर श कर";
"Selected Timezones" = "चयनित सन";
"Sort by Time Difference" = "समय अतर दट कर";
"Sort by Name" = "नम दट कर";
"Sort by Label" = "लबल दट कर";

4
Clocker/Dependencies/Date Additions/Date+TimeAgo.swift

@ -129,7 +129,9 @@ public extension Date {
return DateToolsLocalizedStrings("1 second ago") return DateToolsLocalizedStrings("1 second ago")
} }
return DateToolsLocalizedStrings("Just now") // Instead of returning "Just now" or the equivalent localized version; let's return an empty string
// Previously, we returned DateToolsLocalizedStrings("Just now")
return CLEmptyString
} }
} }

7
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -8,6 +8,7 @@ class TimezoneDataOperations: NSObject {
private lazy var nsCalendar: Calendar = Calendar.autoupdatingCurrent private lazy var nsCalendar: Calendar = Calendar.autoupdatingCurrent
private static var gregorianCalendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian) private static var gregorianCalendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian)
private static var swiftyCalendar = Calendar(identifier: .gregorian) private static var swiftyCalendar = Calendar(identifier: .gregorian)
private static let currentLocale = Locale.current.identifier
init(with timezone: TimezoneData) { init(with timezone: TimezoneData) {
dataObject = timezone dataObject = timezone
@ -222,7 +223,7 @@ extension TimezoneDataOperations {
let timeDifference = local.timeAgo(since: timezoneDate) let timeDifference = local.timeAgo(since: timezoneDate)
if timeDifference.contains("Just now") { if timeDifference.isEmpty {
return CLEmptyString return CLEmptyString
} }
@ -232,6 +233,10 @@ extension TimezoneDataOperations {
let agoString = timezoneDate.timeAgo(since: local, numericDates: true) let agoString = timezoneDate.timeAgo(since: local, numericDates: true)
replaceAgo.append(agoString.replacingOccurrences(of: "ago", with: CLEmptyString)) replaceAgo.append(agoString.replacingOccurrences(of: "ago", with: CLEmptyString))
if !TimezoneDataOperations.currentLocale.contains("en") {
return replaceAgo
}
let minuteDifference = calculateTimeDifference(with: local as NSDate, timezoneDate: timezoneDate as NSDate) let minuteDifference = calculateTimeDifference(with: local as NSDate, timezoneDate: timezoneDate as NSDate)
minuteDifference == 0 ? replaceAgo.append("ahead") : replaceAgo.append("\(minuteDifference) mins ahead") minuteDifference == 0 ? replaceAgo.append("ahead") : replaceAgo.append("\(minuteDifference) mins ahead")
return replaceAgo.lowercased() return replaceAgo.lowercased()

9
Clocker/Panel/ParentPanelController.swift

@ -256,8 +256,10 @@ class ParentPanelController: NSWindowController {
if eventCenter.calendarAccessGranted() { if eventCenter.calendarAccessGranted() {
// Nice. Events will be retrieved when we open the panel // Nice. Events will be retrieved when we open the panel
} else if eventCenter.calendarAccessNotDetermined() { } else if eventCenter.calendarAccessNotDetermined() {
nextEventLabel.stringValue = "See your next Calendar event here." nextEventLabel.stringValue = NSLocalizedString("See your next Calendar event here.",
setCalendarButtonTitle(buttonTitle: "Click here to start.") comment: "Next Event Label for no Calendar access")
setCalendarButtonTitle(buttonTitle: NSLocalizedString("Click here to start.",
comment: "Button Title for no Calendar access"))
} else { } else {
removeUpcomingEventView() removeUpcomingEventView()
} }
@ -641,7 +643,8 @@ class ParentPanelController: NSWindowController {
} }
@IBAction func calendarButtonAction(_: NSButton) { @IBAction func calendarButtonAction(_: NSButton) {
if calendarButton.title == "Click here to start." { if calendarButton.title == NSLocalizedString("Click here to start.",
comment: "Button Title for no Calendar access") {
showPermissionsWindow() showPermissionsWindow()
} else { } else {
retrieveCalendarEvents() retrieveCalendarEvents()

3
Clocker/Preferences/About/AboutViewController.swift

@ -26,10 +26,11 @@ class AboutViewController: ParentViewController {
privateFeedback.setAccessibilityIdentifier("ClockerPrivateFeedback") privateFeedback.setAccessibilityIdentifier("ClockerPrivateFeedback")
let appDisplayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") ?? "Clocker"
let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "N/A" let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "N/A"
let longVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") ?? "N/A" let longVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") ?? "N/A"
versionField.stringValue = "Clocker \(shortVersion) (\(longVersion))" versionField.stringValue = "\(appDisplayName) \(shortVersion) (\(longVersion))"
setup() setup()

10
Clocker/Preferences/General/PreferencesViewController.swift

@ -122,11 +122,11 @@ class PreferencesViewController: ParentViewController {
} }
private func setupLocalizedText() { private func setupLocalizedText() {
startAtLoginLabel.stringValue = "Start Clocker at Login" startAtLoginLabel.stringValue = NSLocalizedString("Start at Login", comment: "Start at Login")
headerLabel.stringValue = "Selected Timezones" headerLabel.stringValue = NSLocalizedString("Selected Timezones", comment: "Start at Login")
timezoneSortButton.title = "Sort by Time Difference" timezoneSortButton.title = NSLocalizedString("Sort by Time Difference", comment: "Start at Login")
timezoneNameSortButton.title = "Sort by Name" timezoneNameSortButton.title = NSLocalizedString("Sort by Name", comment: "Start at Login")
labelSortButton.title = "Sort by Label" labelSortButton.title = NSLocalizedString("Sort by Label", comment: "Start at Login")
} }
@objc func refreshTimezoneTableView() { @objc func refreshTimezoneTableView() {

57
Clocker/Preferences/Permissions/PermissionsViewController.swift

@ -50,16 +50,20 @@ class PermissionsViewController: ParentViewController {
} }
private func setupLocalizedText() { private func setupLocalizedText() {
headerLabel.stringValue = "Permissions" headerLabel.stringValue = NSLocalizedString("Permissions", comment: "Permissions Tab Titles")
reminderHeaderLabel.stringValue = "Reminders Access" reminderHeaderLabel.stringValue = NSLocalizedString("Reminders Access",
reminderDetailLabel.stringValue = "Set reminders in the timezone of the location of your choice. Your reminders are stored in the default Reminders app. " comment: "Reminders Permission Title")
reminderDetailLabel.stringValue = NSLocalizedString("Reminders Detail",
comment: "Reminders Detail Text")
calendarHeaderLabel.stringValue = "Calendar Access" calendarHeaderLabel.stringValue = NSLocalizedString("Calendar Access",
calendarDetailLabel.stringValue = "Upcoming events from your personal and shared calendars can be shown in the menubar and the panel." comment: "Calendar Permission Title")
calendarDetailLabel.stringValue = NSLocalizedString("Calendar Detail",
privacyLabel.stringValue = "You can change this later in the Privacy section of the System Preferences." comment: "Calendar Detail Text")
privacyLabel.stringValue = NSLocalizedString("Privacy Text",
comment: "Text explaining options can be changed in the future through System Preferences")
[calendarHeaderLabel, calendarDetailLabel, privacyLabel, reminderDetailLabel, reminderHeaderLabel, headerLabel].forEach { $0?.textColor = Themer.shared().mainTextColor() [calendarHeaderLabel, calendarDetailLabel, privacyLabel, reminderDetailLabel, reminderHeaderLabel, headerLabel].forEach { $0?.textColor = Themer.shared().mainTextColor()
} }
} }
@ -77,21 +81,27 @@ class PermissionsViewController: ParentViewController {
} */ } */
if EventCenter.sharedCenter().calendarAccessGranted() { if EventCenter.sharedCenter().calendarAccessGranted() {
calendarButton.title = "Granted" calendarButton.title = NSLocalizedString("Granted Button Text",
comment: "Granted Button Text")
} else if EventCenter.sharedCenter().calendarAccessDenied() { } else if EventCenter.sharedCenter().calendarAccessDenied() {
calendarButton.title = "Denied" calendarButton.title = NSLocalizedString("Denied Button Text",
comment: "Denied Button Text")
} else if EventCenter.sharedCenter().calendarAccessNotDetermined() { } else if EventCenter.sharedCenter().calendarAccessNotDetermined() {
calendarButton.title = "Grant" calendarButton.title = NSLocalizedString("Grant Button Text",
comment: "Grant Button Text")
} else { } else {
calendarButton.title = "Unexpected" calendarButton.title = "Unexpected"
} }
if EventCenter.sharedCenter().reminderAccessGranted() { if EventCenter.sharedCenter().reminderAccessGranted() {
remindersButton.title = "Granted" remindersButton.title = NSLocalizedString("Granted Button Text",
comment: "Granted Button Text")
} else if EventCenter.sharedCenter().reminderAccessDenied() { } else if EventCenter.sharedCenter().reminderAccessDenied() {
remindersButton.title = "Denied" remindersButton.title = NSLocalizedString("Denied Button Text",
comment: "Denied Button Text")
} else if EventCenter.sharedCenter().reminderAccessNotDetermined() { } else if EventCenter.sharedCenter().reminderAccessNotDetermined() {
remindersButton.title = "Grant" remindersButton.title = NSLocalizedString("Grant Button Text",
comment: "Grant Button Text")
} else { } else {
remindersButton.title = "Unexpected" remindersButton.title = "Unexpected"
} }
@ -131,19 +141,23 @@ class PermissionsViewController: ParentViewController {
self.view.window?.orderBack(nil) self.view.window?.orderBack(nil)
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
self.calendarButton.title = "Granted" self.calendarButton.title = NSLocalizedString("Granted Button Text",
comment: "Granted Button Text")
// Used to update CalendarViewController's view // Used to update CalendarViewController's view
NotificationCenter.default.post(name: .calendarAccessGranted, object: nil) NotificationCenter.default.post(name: .calendarAccessGranted, object: nil)
} }
} else { } else {
Logger.log(object: ["Reminder Access Not Granted": "YES"], for: "Reminder Access Not Granted") Logger.log(object: ["Reminder Access Not Granted": "YES"],
for: "Reminder Access Not Granted")
} }
}) })
} else if eventCenter.calendarAccessGranted() { } else if eventCenter.calendarAccessGranted() {
calendarButton.title = "Granted" calendarButton.title = NSLocalizedString("Granted Button Text",
comment: "Granted Button Text")
} else { } else {
calendarButton.title = "Denied" calendarButton.title = NSLocalizedString("Denied Button Text",
comment: "Denied Button Text")
} }
} }
@ -164,16 +178,19 @@ class PermissionsViewController: ParentViewController {
self.view.window?.orderBack(nil) self.view.window?.orderBack(nil)
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
self.remindersButton.title = "Granted" self.remindersButton.title = NSLocalizedString("Granted Button Text",
comment: "Granted Button Text")
} }
} else { } else {
Logger.log(object: ["Reminder Access Not Granted": "YES"], for: "Reminder Access Not Granted") Logger.log(object: ["Reminder Access Not Granted": "YES"], for: "Reminder Access Not Granted")
} }
}) })
} else if eventCenter.reminderAccessGranted() { } else if eventCenter.reminderAccessGranted() {
remindersButton.title = "Granted" remindersButton.title = NSLocalizedString("Granted Button Text",
comment: "Granted Button Text")
} else { } else {
remindersButton.title = "Denied" remindersButton.title = NSLocalizedString("Denied Button Text",
comment: "Denied Button Text")
} }
} }
} }

Loading…
Cancel
Save