Skip to content

Commit

Permalink
Add Untitled tab title (#2650)
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx authored Apr 23, 2024
1 parent 442aa19 commit ac42cb8
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
1 change: 1 addition & 0 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ struct UserText {
static let addFolder = NSLocalizedString("menu.add.folder", value: "Add Folder…", comment: "Menu item to add a folder")

static let tabHomeTitle = NSLocalizedString("tab.home.title", value: "New Tab", comment: "Tab home title")
static let tabUntitledTitle = NSLocalizedString("tab.empty.title", value: "Untitled", comment: "Title for an empty tab without a title")
static let tabPreferencesTitle = NSLocalizedString("tab.preferences.title", value: "Settings", comment: "Tab preferences title")
static let tabBookmarksTitle = NSLocalizedString("tab.bookmarks.title", value: "Bookmarks", comment: "Tab bookmarks title")
static let tabOnboardingTitle = NSLocalizedString("tab.onboarding.title", value: "Welcome", comment: "Tab onboarding title")
Expand Down
67 changes: 66 additions & 1 deletion DuckDuckGo/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -20060,6 +20060,7 @@
},
"Hide" : {
"comment" : "Main Menu > View > Home Button > None item\n Preferences > Home Button > None item",
"extractionState" : "extracted_with_value",
"localizations" : {
"de" : {
"stringUnit" : {
Expand Down Expand Up @@ -48009,6 +48010,7 @@
},
"Show left of the back button" : {
"comment" : "Preferences > Home Button > left position item",
"extractionState" : "extracted_with_value",
"localizations" : {
"de" : {
"stringUnit" : {
Expand Down Expand Up @@ -48062,6 +48064,7 @@
},
"Show Left of the Back Button" : {
"comment" : "Main Menu > View > Home Button > left position item",
"extractionState" : "extracted_with_value",
"localizations" : {
"de" : {
"stringUnit" : {
Expand Down Expand Up @@ -48327,6 +48330,7 @@
},
"Show right of the reload button" : {
"comment" : "Preferences > Home Button > right position item",
"extractionState" : "extracted_with_value",
"localizations" : {
"de" : {
"stringUnit" : {
Expand Down Expand Up @@ -48380,6 +48384,7 @@
},
"Show Right of the Reload Button" : {
"comment" : "Main Menu > View > Home Button > right position item",
"extractionState" : "extracted_with_value",
"localizations" : {
"de" : {
"stringUnit" : {
Expand Down Expand Up @@ -49868,6 +49873,66 @@
}
}
},
"tab.empty.title" : {
"comment" : "Title for an empty tab without a title",
"extractionState" : "extracted_with_value",
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ohne Titel"
}
},
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Untitled"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Sin título"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Sans titre"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ohne Titel"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Naamloos"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Bez tytułu"
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
"value" : "Sem título"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Без названия"
}
}
}
},
"tab.error.title" : {
"comment" : "Tab error title",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -53180,4 +53245,4 @@
}
},
"version" : "1.0"
}
}
5 changes: 4 additions & 1 deletion DuckDuckGo/Tab/ViewModel/TabViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ final class TabViewModel {
}

private func updateTitle() { // swiftlint:disable:this cyclomatic_complexity
let title: String
var title: String
switch tab.content {
// keep an old tab title for web page terminated page, display "Failed to open page" for loading errors
case _ where isShowingErrorPage && (tab.error?.code != .webContentProcessTerminated || tab.title == nil):
Expand Down Expand Up @@ -324,6 +324,9 @@ final class TabViewModel {
title = addressBarString
}
}
if title.isEmpty {
title = UserText.tabUntitledTitle
}
if self.title != title {
self.title = title
}
Expand Down

0 comments on commit ac42cb8

Please sign in to comment.