codeburn/mac/Package.swift
Resham Joshi 43608c2558
desktop and menu bar: six-language localization (#1493)
The desktop app and the macOS menu bar can now run in English, French, Japanese, Korean, Simplified Chinese and Traditional Chinese. A Language setting in the desktop Settings picks the language or follows the system, and the choice is shared so the menu bar switches with it, relaunching to pick up the language with a retry so a switch never leaves it down.

Every user-facing string in the desktop renderer goes through a local lookup table, 1,249 keys per language, no framework and no network. The menu bar gains four .lproj to join English and Simplified Chinese, 626 keys each. A completeness gate fails the build if any language is missing a key, in both the desktop catalogs and the menu bar coverage suite. Fonts fall back per language so Japanese, Korean and both Chinese render their correct glyph forms, and dates and numbers format for the locale with values unchanged. English output is byte-identical.

Strings produced by the CLI engine stay English until the CLI is localized, a separate effort. Validated live in all six languages: no missing text, no clipping, correct fonts, numbers unchanged, and the menu bar switching for every language.
2026-09-19 03:25:46 -07:00

56 lines
2.3 KiB
Swift

// swift-tools-version: 6.0
import PackageDescription
let package = Package(
name: "CodeBurnMenubar",
// English is the development language: every key in Localizable.strings *is*
// its English copy, so a key with no translation renders as correct English
// instead of a dotted identifier. Declaring it here is also what lets SwiftPM
// treat Resources/<locale>.lproj as localized resources at all.
defaultLocalization: "en",
platforms: [
// macOS 14 (Sonoma) is the floor: matches Info.plist LSMinimumSystemVersion,
// the CLI install guard (MIN_MACOS_MAJOR=14), and mac/README. The earlier .v15
// bump for NSAttributedString(attachment:) was a misdiagnosis, that initializer
// is AppKit since macOS 10.0, so the binary's minos must not exclude Sonoma users.
.macOS(.v14)
],
products: [
.executable(name: "CodeBurnMenubar", targets: ["CodeBurnMenubar"])
],
targets: [
.executableTarget(
name: "CodeBurnMenubar",
path: "Sources/CodeBurnMenubar",
resources: [
.process("Resources/ProviderIcons"),
// Emitted into the target resource bundle as `<locale>.lproj/
// Localizable.strings`, which is the layout NSBundle needs to
// resolve a table per localization. Lookups go through
// `L(_:)` / `Bundle.module`, never `Bundle.main`: the strings
// live in the SwiftPM resource bundle inside Contents/Resources,
// not at the app bundle's resource root.
.process("Resources/en.lproj"),
.process("Resources/fr.lproj"),
.process("Resources/ja.lproj"),
.process("Resources/ko.lproj"),
.process("Resources/zh-Hans.lproj"),
.process("Resources/zh-Hant.lproj")
],
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency")
],
linkerSettings: [
.linkedLibrary("sqlite3")
]
),
.testTarget(
name: "CodeBurnMenubarTests",
dependencies: ["CodeBurnMenubar"],
path: "Tests/CodeBurnMenubarTests",
linkerSettings: [
.linkedLibrary("sqlite3")
]
)
]
)