ce55be4a-fb5f-4981-b507-0f4.../Sources/support/Localization.swift
徐翔宇 c4080b5cb9 v1.0.0: initial AirDrop plugin for MioIsland
Quick-access AirDrop from the notch panel. Tap the card body, pick
files via NSOpenPanel, hand off to NSSharingService(.sendViaAirDrop).
No private APIs, no entitlements, no network — just a thin wrapper
around the same AirDrop API Finder uses.

Design constraint: drag-and-drop is intentionally not implemented.
MioIsland's notch panel auto-collapses on click-outside, which
breaks the Cmd-Tab-to-Finder / grab / drag-back workflow before
the drop target reaches. Tap-to-choose is rock solid by comparison.

Requires MioIsland host v2.2.0+ (panel size clamp floor was
lowered to 120pt in that release).
2026-04-22 08:20:47 +08:00

88 lines
2.3 KiB
Swift

//
// Localization.swift
// MioIsland AirDrop Plugin
//
// zh/en string map. Host's `appLanguage` UserDefault is the source
// of truth, with "auto" falling back to system locale.
//
import Foundation
enum L10n {
static var isChinese: Bool {
let setting = UserDefaults.standard.string(forKey: "appLanguage") ?? "auto"
switch setting {
case "zh": return true
case "en": return false
default:
if let code = Locale.current.language.languageCode?.identifier,
code.hasPrefix("zh") {
return true
}
if let pref = Locale.preferredLanguages.first,
pref.hasPrefix("zh") {
return true
}
return false
}
}
// MARK: - Title / primary CTA
static var title: String {
isChinese ? "隔空投送" : "AirDrop"
}
static var chooseFiles: String {
isChinese ? "选择文件" : "Choose files"
}
static var clickToChoose: String {
isChinese ? "点击选择要发送的文件" : "Tap to pick files to send"
}
static var choose: String {
isChinese ? "选择" : "Choose"
}
static var chooseFilesTitle: String {
isChinese ? "选择要通过隔空投送发送的文件" : "Choose files to AirDrop"
}
// MARK: - Status
static var opening: String {
isChinese ? "正在打开隔空投送…" : "Opening AirDrop…"
}
static func sentCount(_ n: Int) -> String {
isChinese ? "✓ 已发送 \(n) 个文件" : "✓ Sent \(n) file\(n == 1 ? "" : "s")"
}
// MARK: - Errors
static var errServiceUnavailable: String {
isChinese
? "隔空投送服务不可用(系统可能未开启)"
: "AirDrop service unavailable (check System Settings)"
}
static var errCannotPerform: String {
isChinese
? "这些文件无法通过隔空投送发送"
: "These files cannot be sent via AirDrop"
}
// MARK: - Host upgrade hint
static var hostUpgradeTitle: String {
isChinese ? "需要 Mio Island v2.2.0+" : "Mio Island v2.2.0+ required"
}
static var hostUpgradeHint: String {
isChinese
? "请升级主 app 以启用本插件"
: "Please upgrade Mio Island to unlock this plugin"
}
}