Skip to content

Commit

Permalink
feat: suggest users contribute translations
Browse files Browse the repository at this point in the history
  • Loading branch information
ShlomoCode committed Jul 12, 2024
1 parent 97a2ec4 commit f0833aa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
12 changes: 12 additions & 0 deletions DockDoor/Utilities/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ extension Color {
)
}
}

extension String {
func isLocalizedStringAvailable(for languageCode: String) -> Bool {
guard let path = Bundle.main.path(forResource: languageCode, ofType: "lproj"),
let bundle = Bundle(path: path) else {
return false
}

let localizedString = NSLocalizedString(self, tableName: "Localizable", bundle: bundle, value: "", comment: "")
return localizedString != self
}
}
4 changes: 2 additions & 2 deletions DockDoor/Utilities/WindowUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ final class WindowUtil {
config.ignoreShadowsDisplay = true
config.shouldBeOpaque = false
if #available(macOS 14.2, *) { config.includeChildWindows = false }
config.width = Int(window.frame.width)
config.height = Int(window.frame.height)
config.width = Int(window.frame.width * 2.0)
config.height = Int(window.frame.height * 2.0)
config.showsCursor = false
config.captureResolution = .best

Expand Down
12 changes: 12 additions & 0 deletions DockDoor/Views/Settings/MainSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ struct MainSettingsView: View {
Text("Want to support development?")
Link("Buy me a coffee here, thank you!", destination: URL(string: "https://www.buymeacoffee.com/keplercafe")!)
}

HStack {
let userPreferedLangCode = Bundle.main.preferredLocalizations[0]
let localeIsProbablyReady = "Want to see the app in \("")?".isLocalizedStringAvailable(for:userPreferedLangCode)

if let languageName = Locale(identifier: localeIsProbablyReady ? userPreferedLangCode : "en-US").localizedString(forLanguageCode: userPreferedLangCode) {
Text("Want to see the app in \(languageName)?")
} else {
Text("Want to see the app in your language?")
}
Link("Contribute translation here!", destination: URL(string: "https://crowdin.com/project/dockdoor/invite?h=895e3c085646d3c07fa36a97044668e02149115")!)
}
}

Divider()
Expand Down

0 comments on commit f0833aa

Please sign in to comment.