Skip to content

Commit

Permalink
Merge branch 'Lakr233:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach677 authored Sep 12, 2024
2 parents c45f112 + c26ac83 commit 53bd026
Show file tree
Hide file tree
Showing 5 changed files with 424 additions and 24 deletions.
9 changes: 5 additions & 4 deletions NotchDrop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
"zh-Hans",
"zh-Hant",
ja,
fr,
);
mainGroup = 504381772C3A86EA000ED325;
packageReferences = (
Expand Down Expand Up @@ -419,7 +420,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 35;
CURRENT_PROJECT_VERSION = 38;
DEVELOPMENT_TEAM = 964G86XT2P;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
Expand All @@ -433,7 +434,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.12;
MARKETING_VERSION = 2.14;
PRODUCT_BUNDLE_IDENTIFIER = wiki.qaq.NotchDrop;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -450,7 +451,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 35;
CURRENT_PROJECT_VERSION = 38;
DEVELOPMENT_TEAM = 964G86XT2P;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
Expand All @@ -464,7 +465,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.12;
MARKETING_VERSION = 2.14;
PRODUCT_BUNDLE_IDENTIFIER = wiki.qaq.NotchDrop;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
18 changes: 18 additions & 0 deletions NotchDrop/InfoPlist.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"value" : "NotchDrop"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "NotchDrop"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
Expand Down Expand Up @@ -40,6 +46,12 @@
"value" : "NotchDrop"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "NotchDrop"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
Expand Down Expand Up @@ -70,6 +82,12 @@
"value" : "Copyright © 2024 Lakr Aream. All rights reserved."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Copyright © 2024 Lakr Aream. All rights reserved."
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
Expand Down
36 changes: 25 additions & 11 deletions NotchDrop/Language.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum Language: String, CaseIterable, Identifiable, Codable {
case simplifiedChinese = "Simplified Chinese"
case traditionalChinese = "Traditional Chinese"
case japanese = "Japanese"
case french = "French"

var id: String { rawValue }

Expand All @@ -34,6 +35,8 @@ enum Language: String, CaseIterable, Identifiable, Codable {
languageCode = "zh-Hant"
} else if region == "CN" {
languageCode = "zh-Hans"
} else if region == "FR" {
languageCode = "fr"
} else {
languageCode = "en"
}
Expand All @@ -47,31 +50,42 @@ enum Language: String, CaseIterable, Identifiable, Codable {
languageCode = "zh-Hant"
case .japanese:
languageCode = "ja"
case .french:
languageCode = "fr"
}

Bundle.setLanguage(languageCode)

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
NSAlert.popRestart(
NSLocalizedString("The language has been changed. The app will restart for the changes to take effect.", comment: ""),
completion: restartApp
completion: relaunchApp
)
}
}
}

private func restartApp() {
guard let appPath = Bundle.main.executablePath else { return }
NSApp.terminate(nil)

DispatchQueue.global().asyncAfter(deadline: .now() + 0.5) {
let process = Process()
process.executableURL = URL(fileURLWithPath: appPath)
try? process.run()
exit(0)
}
private func relaunchApp() {
let path = Bundle.main.bundlePath
let task = Process()
task.launchPath = "/usr/bin/open"
task.arguments = ["-n", path]
task.launch()
exit(0)
}

// private func restartApp() {
// guard let appPath = Bundle.main.executablePath else { return }
// NSApp.terminate(nil)

// DispatchQueue.global().asyncAfter(deadline: .now() + 0.5) {
// let process = Process()
// process.executableURL = URL(fileURLWithPath: appPath)
// try? process.run()
// exit(0)
// }
// }

private extension Bundle {
private static var onLanguageDispatchOnce: () -> Void = {
object_setClass(Bundle.main, PrivateBundle.self)
Expand Down
Loading

0 comments on commit 53bd026

Please sign in to comment.