From 1ae5e405dbaaf57ff5c631791d01bd0dbc6a9de6 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 15 Sep 2019 12:21:20 -0700 Subject: [PATCH] Tab title localization! --- Clocker/Clocker/en.lproj/Localizable.strings | 16 ++++++++ Clocker/Clocker/hi.lproj/Localizable.strings | 15 +++++++ .../General/PreferencesViewController.swift | 41 +++++++++++++------ Clocker/Preferences/OneWindowController.swift | 13 +++++- Clocker/Preferences/Preferences.storyboard | 11 ++--- 5 files changed, 78 insertions(+), 18 deletions(-) diff --git a/Clocker/Clocker/en.lproj/Localizable.strings b/Clocker/Clocker/en.lproj/Localizable.strings index 26fd763..61efd45 100644 --- a/Clocker/Clocker/en.lproj/Localizable.strings +++ b/Clocker/Clocker/en.lproj/Localizable.strings @@ -31,8 +31,24 @@ "Granted Button Text" = "Granted"; "Denied Button Text" = "Denied"; "Grant Button Text" = "Grant"; + +// Tab Item Titles +"Preferences Tab" = "Preferences"; +"Appearance Tab" = "Appearance"; +"Calendar Tab" = "Calendar"; +"About Tab" = "About"; +"Permissions Tab" = "Permissions"; + +// General Preferences Screen "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"; +"Search Field Placeholder" = "Enter a city, state or country name"; +"No Timezone Selected Error Message" = "Please select a timezone!"; +"Max Timezones Selected Error Message" = "Maximum 100 timezones allowed!"; +"Max Search Characters Error Message" = "Only 50 characters allowed!"; +"Add Button Title" = "Add"; +"Close Button Title" = "Close"; + diff --git a/Clocker/Clocker/hi.lproj/Localizable.strings b/Clocker/Clocker/hi.lproj/Localizable.strings index 7ab1579..a1c72f4 100644 --- a/Clocker/Clocker/hi.lproj/Localizable.strings +++ b/Clocker/Clocker/hi.lproj/Localizable.strings @@ -31,8 +31,23 @@ "Granted Button Text" = "स्वीकृत"; "Denied Button Text" = "इनकार किया"; "Grant Button Text" = "अनुदान"; + +// Tab Item Titles +"Preferences Tab" = "प्रिफ्रेंसेज"; +"Appearance Tab" = "दिखावट"; +"Calendar Tab" = "कैलेंडर"; +"About Tab" = "अबाउट"; +"Permissions Tab" = "अनुमति"; + +// General Preferencess "Start at Login" = "लॉगिन पर शुरू करें"; "Selected Timezones" = "चयनित स्थान"; "Sort by Time Difference" = "समय अंतर द्वारा सॉर्ट करें"; "Sort by Name" = "नाम द्वारा सॉर्ट करें"; "Sort by Label" = "लेबल द्वारा सॉर्ट करें"; +"Search Field Placeholder" = "Enter a city, state or country name"; +"No Timezone Selected Error Message" = "Please select a timezone!"; +"Max Timezones Selected Error Message" = "Maximum 100 timezones allowed!"; +"Max Search Characters Error Message" = "Only 50 characters allowed!"; +"Add Button Title" = "ऐड "; +"Close Button Title" = "बंद करे"; diff --git a/Clocker/Preferences/General/PreferencesViewController.swift b/Clocker/Preferences/General/PreferencesViewController.swift index dd384c6..7fb3076 100644 --- a/Clocker/Preferences/General/PreferencesViewController.swift +++ b/Clocker/Preferences/General/PreferencesViewController.swift @@ -3,9 +3,12 @@ import Cocoa struct PreferencesConstants { - static let noTimezoneSelectedErrorMessage = "Please select a timezone!" - static let maxTimezonesErrorMessage = "Maximum 100 timezones allowed!" - static let maxCharactersAllowed = "Only 50 characters allowed!" + static let noTimezoneSelectedErrorMessage = NSLocalizedString("No Timezone Selected", + comment: "Message shown when the user taps on Add without selecting a timezone") + static let maxTimezonesErrorMessage = NSLocalizedString("Max Timezones Selected", + comment: "Max Timezones Error Message") + static let maxCharactersAllowed = NSLocalizedString("Max Search Characters Error Message", + comment: "Max Character Count Allowed Error Message") static let noInternetConnectivityError = "You're offline, maybe?" static let tryAgainMessage = "Try again, maybe?" static let offlineErrorMessage = "The Internet connection appears to be offline." @@ -48,6 +51,7 @@ class PreferencesViewController: ParentViewController { @IBOutlet private var progressIndicator: NSProgressIndicator! @IBOutlet private var addButton: NSButton! @IBOutlet private var recorderControl: SRRecorderControl! + @IBOutlet private var closeButton: NSButton! @IBOutlet private var timezoneSortButton: NSButton! @IBOutlet private var timezoneNameSortButton: NSButton! @@ -122,11 +126,20 @@ class PreferencesViewController: ParentViewController { } private func setupLocalizedText() { - startAtLoginLabel.stringValue = NSLocalizedString("Start at Login", comment: "Start at Login") - headerLabel.stringValue = NSLocalizedString("Selected Timezones", comment: "Start at Login") - timezoneSortButton.title = NSLocalizedString("Sort by Time Difference", comment: "Start at Login") - timezoneNameSortButton.title = NSLocalizedString("Sort by Name", comment: "Start at Login") - labelSortButton.title = NSLocalizedString("Sort by Label", comment: "Start at Login") + startAtLoginLabel.stringValue = NSLocalizedString("Start at Login", + comment: "Start at Login") + headerLabel.stringValue = NSLocalizedString("Selected Timezones", + comment: "Start at Login") + timezoneSortButton.title = NSLocalizedString("Sort by Time Difference", + comment: "Start at Login") + timezoneNameSortButton.title = NSLocalizedString("Sort by Name", + comment: "Start at Login") + labelSortButton.title = NSLocalizedString("Sort by Label", + comment: "Start at Login") + addButton.title = NSLocalizedString("Add Button Title", + comment: "Button to add a location") + closeButton.title = NSLocalizedString("Close Button Title", + comment: "Button to close the panel") } @objc func refreshTimezoneTableView() { @@ -694,7 +707,8 @@ extension PreferencesViewController { private func setErrorPlaceholders() { placeholderLabel.placeholderString = "No timezone found! Try entering an exact name." - searchField.placeholderString = "Enter a city, state or country name" + searchField.placeholderString = NSLocalizedString("Search Field Placeholder", + comment: "Search Field Placeholder") isActivityInProgress = false } @@ -705,7 +719,8 @@ extension PreferencesViewController { refreshMainTable() timezonePanel.close() placeholderLabel.placeholderString = CLEmptyString - searchField.placeholderString = "Enter a city, state or country name" + searchField.placeholderString = NSLocalizedString("Search Field Placeholder", + comment: "Search Field Placeholder") availableTimezoneTableView.isHidden = false isActivityInProgress = false } @@ -824,7 +839,8 @@ extension PreferencesViewController { refreshMainTable() timezonePanel.close() - searchField.placeholderString = "Enter a city, state or country name" + searchField.placeholderString = NSLocalizedString("Search Field Placeholder", + comment: "Search Field Placeholder") availableTimezoneTableView.isHidden = false isActivityInProgress = false } @@ -844,7 +860,8 @@ extension PreferencesViewController { searchResultsDataSource.timezoneFilteredArray = [] searchField.stringValue = CLEmptyString placeholderLabel.placeholderString = CLEmptyString - searchField.placeholderString = "Enter a city, state or country name" + searchField.placeholderString = NSLocalizedString("Search Field Placeholder", + comment: "Search Field Placeholder") reloadSearchResults() diff --git a/Clocker/Preferences/OneWindowController.swift b/Clocker/Preferences/OneWindowController.swift index 4ae97b6..6feb019 100644 --- a/Clocker/Preferences/OneWindowController.swift +++ b/Clocker/Preferences/OneWindowController.swift @@ -15,9 +15,20 @@ class CenteredTabViewController: NSTabViewController { } toolbarItems.append(NSToolbarItem.Identifier.flexibleSpace) - return toolbarItems } + + override func viewDidLoad() { + super.viewDidLoad() + + // Setup localized tab labels + tabViewItems.forEach { item in + if let identifier = item.identifier as? String { + print(identifier) + item.label = NSLocalizedString(identifier, comment: "Tab View Item Label for \(identifier)") + } + } + } } class OneWindowController: NSWindowController { diff --git a/Clocker/Preferences/Preferences.storyboard b/Clocker/Preferences/Preferences.storyboard index 6a2d39a..d31c7f3 100644 --- a/Clocker/Preferences/Preferences.storyboard +++ b/Clocker/Preferences/Preferences.storyboard @@ -33,11 +33,11 @@ - - - - - + + + + + @@ -1620,6 +1620,7 @@ CA +