Skip to content

Commit

Permalink
Replace localizations in project files
Browse files Browse the repository at this point in the history
  • Loading branch information
BPerlakiH authored and kelson42 committed Jan 26, 2025
1 parent 385d473 commit 54b6bf9
Show file tree
Hide file tree
Showing 54 changed files with 302 additions and 302 deletions.
8 changes: 4 additions & 4 deletions App/App_macOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ struct Kiwix: App {
}.commands {
SidebarCommands()
CommandGroup(replacing: .importExport) {
OpenFileButton(context: .command) { Text("app_macos_commands.open_file".localized) }
OpenFileButton(context: .command) { Text(LocalString.app_macos_commands_open_file) }
}
CommandGroup(replacing: .newItem) {
Button("app_macos_commands.new".localized) {
Button(LocalString.app_macos_commands_new) {
guard let currentWindow = NSApp.keyWindow,
let controller = currentWindow.windowController else { return }
controller.newWindowForTab(nil)
Expand Down Expand Up @@ -85,7 +85,7 @@ struct Kiwix: App {
}
.frame(width: 550, height: 400)
}
Window("payment.donate.title".localized, id: "donation") {
Window(LocalString.payment_donate_title, id: "donation") {
Group {
if let selectedAmount {
PaymentSummary(selectedAmount: selectedAmount, onComplete: {
Expand Down Expand Up @@ -187,7 +187,7 @@ struct RootView: View {
Label(navigationItem.name, systemImage: navigationItem.icon)
}
if FeatureFlags.hasLibrary {
Section("app_macos_navigation.button.library".localized) {
Section(LocalString.app_macos_navigation_button_library) {
ForEach(libraryItems, id: \.self) { navigationItem in
Label(navigationItem.name, systemImage: navigationItem.icon)
}
Expand Down
12 changes: 6 additions & 6 deletions App/CompactViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ final class CompactViewController: UIHostingController<AnyView>, UISearchControl
searchController.delegate = self
searchController.hidesNavigationBarDuringPresentation = false
searchController.showsSearchResultsController = true
searchController.searchBar.searchTextField.placeholder = "common.search".localized
searchController.searchBar.searchTextField.placeholder = LocalString.common_search

searchTextObserver = searchViewModel.$searchText.sink { [weak self] searchText in
guard self?.searchController.searchBar.text != searchText else { return }
Expand All @@ -107,7 +107,7 @@ final class CompactViewController: UIHostingController<AnyView>, UISearchControl
trailingNavItemGroups = navigationItem.trailingItemGroups
navigationItem.setRightBarButton(
UIBarButtonItem(
title: "common.button.cancel".localized,
title: LocalString.common_button_cancel,
style: .done,
target: self,
action: #selector(onSearchCancelled)
Expand Down Expand Up @@ -185,14 +185,14 @@ private struct CompactView: View {
Button {
presentedSheet = .library
} label: {
Label("common.tab.menu.library".localized, systemImage: "folder")
Label(LocalString.common_tab_menu_library, systemImage: "folder")
}
Spacer()
}
Button {
presentedSheet = .settings
} label: {
Label("common.tab.menu.settings".localized, systemImage: "gear")
Label(LocalString.common_tab_menu_settings, systemImage: "gear")
}
Spacer()
}
Expand All @@ -209,7 +209,7 @@ private struct CompactView: View {
Button {
self.presentedSheet = nil
} label: {
Text("common.button.done".localized).fontWeight(.semibold)
Text(LocalString.common_button_done).fontWeight(.semibold)
}
}
}
Expand Down Expand Up @@ -285,7 +285,7 @@ private struct Content<LaunchModel>: View where LaunchModel: LaunchProtocol {
}
.toolbar {
ToolbarItemGroup(placement: .primaryAction) {
Button("article_shortcut.random.button.title.ios".localized,
Button(LocalString.article_shortcut_random_button_title_ios,
systemImage: "die.face.5",
action: { browser.loadRandomArticle() })
.disabled(zimFiles.isEmpty)
Expand Down
12 changes: 6 additions & 6 deletions App/SidebarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class SidebarViewController: UICollectionViewController, NSFetchedResultsControl
},
menu: UIMenu(children: [
UIAction(
title: "sidebar_view.navigation.button.close".localized,
title: LocalString.sidebar_view_navigation_button_close,
image: UIImage(systemName: "xmark.square"),
attributes: .destructive
) { [unowned self] _ in
Expand All @@ -114,7 +114,7 @@ class SidebarViewController: UICollectionViewController, NSFetchedResultsControl
navigationViewModel.deleteTab(tabID: tabID)
},
UIAction(
title: "sidebar_view.navigation.button.close_all".localized,
title: LocalString.sidebar_view_navigation_button_close_all,
image: UIImage(systemName: "xmark.square.fill"),
attributes: .destructive
) { [unowned self] _ in
Expand Down Expand Up @@ -196,7 +196,7 @@ class SidebarViewController: UICollectionViewController, NSFetchedResultsControl
if case let .tab(objectID) = item,
let tab = try? Database.shared.viewContext.existingObject(with: objectID) as? Tab {
var config = cell.defaultContentConfiguration()
config.text = tab.title ?? "common.tab.menu.new_tab".localized
config.text = tab.title ?? LocalString.common_tab_menu_new_tab
if let zimFile = tab.zimFile, let category = Category(rawValue: zimFile.category) {
config.textProperties.numberOfLines = 1
if let imgData = zimFile.faviconData {
Expand Down Expand Up @@ -224,11 +224,11 @@ class SidebarViewController: UICollectionViewController, NSFetchedResultsControl
switch section {
case .tabs:
var config = UIListContentConfiguration.sidebarHeader()
config.text = "common.tab.navigation.title".localized
config.text = LocalString.common_tab_navigation_title
headerView.contentConfiguration = config
case .library:
var config = UIListContentConfiguration.sidebarHeader()
config.text = "common.tab.menu.library".localized
config.text = LocalString.common_tab_menu_library
headerView.contentConfiguration = config
default:
headerView.contentConfiguration = nil
Expand All @@ -239,7 +239,7 @@ class SidebarViewController: UICollectionViewController, NSFetchedResultsControl
guard let navigationViewModel,
let item = dataSource.itemIdentifier(for: indexPath),
case let .tab(tabID) = item else { return nil }
let title = "sidebar_view.navigation.button.close".localized
let title = LocalString.sidebar_view_navigation_button_close
let action = UIContextualAction(style: .destructive,
title: title) { [weak navigationViewModel] _, _, _ in
navigationViewModel?.deleteTab(tabID: tabID)
Expand Down
2 changes: 1 addition & 1 deletion Model/Brand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum Brand {
static let loadingLogoImage: String = "welcomeLogo"
static var loadingLogoSize: CGSize = ImageInfo.sizeOf(imageName: loadingLogoImage)!

static let aboutText: String = Config.value(for: .aboutText) ?? "settings.about.description".localized
static let aboutText: String = Config.value(for: .aboutText) ?? LocalString.settings_about_description
static let aboutWebsite: String = Config.value(for: .aboutWebsite) ?? "https://www.kiwix.org"
// currently only used under the Kiwix brand
// if this is set to true in Support/Info.plist the support/donation button is hidden (for macOS FTP)
Expand Down
4 changes: 2 additions & 2 deletions Model/DownloadService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ final class DownloadService: NSObject, URLSessionDelegate, URLSessionTaskDelegat
Database.shared.performBackgroundTask { context in
// configure notification content
let content = UNMutableNotificationContent()
content.title = "download_service.complete.title".localized
content.title = LocalString.download_service_complete_title
content.sound = .default
if let zimFile = try? context.fetch(ZimFile.fetchRequest(fileID: zimFileID)).first {
content.body = "download_service.complete.description".localizedWithFormat(withArgs: zimFile.name)
content.body = LocalString.download_service_complete_description(withArgs: zimFile.name)
}

// schedule notification
Expand Down
6 changes: 3 additions & 3 deletions Model/Entities/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public enum LibraryRefreshError: LocalizedError {
public var errorDescription: String? {
switch self {
case .retrieve(let description):
let prefix = "library_refresh_error.retrieve.description".localized
let prefix = LocalString.library_refresh_error_retrieve_description
return [prefix, description].compactMap({ $0 }).joined(separator: " ")
case .parse:
return "library_refresh_error.parse.description".localized
return LocalString.library_refresh_error_parse_description
case .process:
return "library_refresh_error.process.description".localized
return LocalString.library_refresh_error_process_description
}
}
}
6 changes: 3 additions & 3 deletions Model/Payment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ struct Payment {
request.supportedNetworks = Self.supportedNetworks
request.requiredBillingContactFields = [.emailAddress]
let recurring: PKRecurringPaymentRequest? = if selectedAmount.isMonthly {
PKRecurringPaymentRequest(paymentDescription: "payment.description.label".localized,
regularBilling: .init(label: "payment.monthly_support.label".localized,
PKRecurringPaymentRequest(paymentDescription: LocalString.payment_description_label,
regularBilling: .init(label: LocalString.payment_monthly_support_label,
amount: NSDecimalNumber(value: selectedAmount.value),
type: .final),
managementURL: URL(string: Self.paymentSubscriptionManagingURL)!)
Expand All @@ -157,7 +157,7 @@ struct Payment {
request.recurringPaymentRequest = recurring
request.paymentSummaryItems = [
PKPaymentSummaryItem(
label: "payment.summary.title".localized,
label: LocalString.payment_summary_title,
amount: NSDecimalNumber(value: selectedAmount.value),
type: .final
)
Expand Down
72 changes: 36 additions & 36 deletions SwiftUI/Model/Enum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,29 @@ enum Category: String, CaseIterable, Identifiable, LosslessStringConvertible, Ha
var name: String {
switch self {
case .wikipedia:
return "enum.category.wikipedia".localized
return LocalString.enum_category_wikipedia
case .wikibooks:
return "enum.category.wikibooks".localized
return LocalString.enum_category_wikibooks
case .wikinews:
return "enum.category.wikinews".localized
return LocalString.enum_category_wikinews
case .wikiquote:
return "enum.category.wikiquote".localized
return LocalString.enum_category_wikiquote
case .wikisource:
return "enum.category.wikisource".localized
return LocalString.enum_category_wikisource
case .wikiversity:
return "enum.category.wikiversity".localized
return LocalString.enum_category_wikiversity
case .wikivoyage:
return "enum.category.wikivoyage".localized
return LocalString.enum_category_wikivoyage
case .wiktionary:
return "enum.category.wiktionary".localized
return LocalString.enum_category_wiktionary
case .ted:
return "enum.category.ted".localized
return LocalString.enum_category_ted
case .vikidia:
return "enum.category.vikidia".localized
return LocalString.enum_category_vikidia
case .stackExchange:
return "enum.category.stackexchange".localized
return LocalString.enum_category_stackexchange
case .other:
return "enum.category.other".localized
return LocalString.enum_category_other
}
}

Expand Down Expand Up @@ -129,11 +129,11 @@ enum ExternalLinkLoadingPolicy: String, CaseIterable, Identifiable, Defaults.Ser
var name: String {
switch self {
case .alwaysAsk:
return "enum.external_link_loading_policy.always_ask".localized
return LocalString.enum_external_link_loading_policy_always_ask
case .alwaysLoad:
return "enum.external_link_loading_policy.always_load".localized
return LocalString.enum_external_link_loading_policy_always_load
case .neverLoad:
return "enum.external_link_loading_policy.never_load".localized
return LocalString.enum_external_link_loading_policy_never_load
}
}
}
Expand Down Expand Up @@ -162,11 +162,11 @@ enum Flavor: String, CustomStringConvertible {
var description: String {
switch self {
case .max:
return "enum.flavor.max".localized
return LocalString.enum_flavor_max
case .noPic:
return "enum.flavor.no_pic".localized
return LocalString.enum_flavor_no_pic
case .mini:
return "enum.flavor.mini".localized
return LocalString.enum_flavor_mini
}
}
}
Expand All @@ -179,9 +179,9 @@ enum LibraryLanguageSortingMode: String, CaseIterable, Identifiable, Defaults.Se
var name: String {
switch self {
case .alphabetically:
return "enum.library_language_sorting_model.a-z".localized
return LocalString.enum_library_language_sorting_model_a_z
case .byCounts:
return "enum.library_language_sorting_model.by_count".localized
return LocalString.enum_library_language_sorting_model_by_count
}
}
}
Expand All @@ -194,13 +194,13 @@ enum LibraryTabItem: String, CaseIterable, Identifiable {
var name: String {
switch self {
case .opened:
return "enum.libray_tab_item.opened".localized
return LocalString.enum_libray_tab_item_opened.localized
case .categories:
return "enum.libray_tab_item.categories".localized
return LocalString.enum_libray_tab_item_categories
case .downloads:
return "enum.libray_tab_item.downloads".localized
return LocalString.enum_libray_tab_item_downloads
case .new:
return "enum.libray_tab_item.new".localized
return LocalString.enum_libray_tab_item_new
}
}

Expand Down Expand Up @@ -229,27 +229,27 @@ enum NavigationItem: Hashable, Identifiable {
var name: String {
switch self {
case .loading:
return "enum.navigation_item.loading".localized
return LocalString.enum_navigation_item_loading
case .bookmarks:
return "enum.navigation_item.bookmarks".localized
return LocalString.enum_navigation_item_bookmarks.localized
case .map:
return "enum.navigation_item.map".localized
return LocalString.enum_navigation_item_map
case .tab:
#if os(macOS)
return "enum.navigation_item.reading".localized
return LocalString.enum_navigation_item_reading
#else
return "enum.navigation_item.new_tab".localized
return LocalString.enum_navigation_item_new_tab
#endif
case .opened:
return "enum.navigation_item.opened".localized
return LocalString.enum_navigation_item_opened
case .categories:
return "enum.navigation_item.categories".localized
return LocalString.enum_navigation_item_categories.localized
case .new:
return "enum.navigation_item.new".localized
return LocalString.enum_navigation_item_new
case .downloads:
return "enum.navigation_item.downloads".localized
return LocalString.enum_navigation_item_downloads
case .settings:
return "enum.navigation_item.settings".localized
return LocalString.enum_navigation_item_settings
}
}

Expand Down Expand Up @@ -294,9 +294,9 @@ enum SearchResultSnippetMode: String, CaseIterable, Identifiable, Defaults.Seria
var name: String {
switch self {
case .disabled:
return "enum.search_result_snippet_mode.disabled".localized
return LocalString.enum_search_result_snippet_mode_disabled
case .matches:
return "enum.search_result_snippet_mode.matches".localized
return LocalString.enum_search_result_snippet_mode_matches
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions ViewModel/BrowserViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,13 @@ final class BrowserViewModel: NSObject, ObservableObject,

// open url
actions.append(
UIAction(title: "common.dialog.button.open".localized,
UIAction(title: LocalString.common_dialog_button_open,
image: UIImage(systemName: "doc.text")) { [weak self] _ in
self?.webView.load(URLRequest(url: url))
}
)
actions.append(
UIAction(title: "common.dialog.button.open_in_new_tab".localized,
UIAction(title: LocalString.common_dialog_button_open_in_new_tab,
image: UIImage(systemName: "doc.badge.plus")) { [weak self] _ in
guard let self else { return }
Task { @MainActor in
Expand All @@ -611,13 +611,13 @@ final class BrowserViewModel: NSObject, ObservableObject,

if let bookmarks = try? context.fetch(request),
!bookmarks.isEmpty {
return UIAction(title: "common.dialog.button.remove_bookmark".localized,
return UIAction(title: LocalString.common_dialog_button_remove_bookmark,
image: UIImage(systemName: "star.slash.fill")) { [weak self] _ in
self?.deleteBookmark(url: url)
}
} else {
return UIAction(
title: "common.dialog.button.bookmark".localized,
title: LocalString.common_dialog_button_bookmark,
image: UIImage(systemName: "star")
) { [weak self] _ in
Task { @MainActor [weak self] in self?.createBookmark(url: url) }
Expand Down
Loading

0 comments on commit 54b6bf9

Please sign in to comment.