Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Rename the app to NX2Apple, and let the interface language be picked

LNPANDYe82f60bc983e
diff --git a/.github/workflows/build-mac-app.yml b/.github/workflows/build-mac-app.yml
index 5e8c956c..9310a529 100644
--- a/.github/workflows/build-mac-app.yml
+++ b/.github/workflows/build-mac-app.yml
@@ -58,7 +58,7 @@ jobs:
# The .app is in .gitignore (it is a build product), so a fresh checkout has none: the
# bundle is generated here. That is the point of this workflow — the previous hand-built
# bundle is exactly what went missing from a release.
- APP="nxnative.app"
+ APP="NX2Apple.app"
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp .build/release/NSPortBuilder "$APP/Contents/MacOS/NSPortBuilder"
@@ -72,8 +72,8 @@ jobs:
<key>CFBundleExecutable</key><string>NSPortBuilder</string>
<key>CFBundleIconFile</key><string>AppIcon</string>
<key>CFBundleIdentifier</key><string>org.nxnative.NSPortBuilder</string>
- <key>CFBundleName</key><string>nxnative</string>
- <key>CFBundleDisplayName</key><string>nxnative</string>
+ <key>CFBundleName</key><string>NX2Apple</string>
+ <key>CFBundleDisplayName</key><string>NX2Apple</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>$V</string>
<key>CFBundleVersion</key><string>$V</string>
diff --git a/frontend/Sources/NSPortBuilder/ContentView.swift b/frontend/Sources/NSPortBuilder/ContentView.swift
index 11a0e320..e566b06e 100644
--- a/frontend/Sources/NSPortBuilder/ContentView.swift
+++ b/frontend/Sources/NSPortBuilder/ContentView.swift
@@ -136,7 +136,7 @@ final class BuildModel: ObservableObject {
@Published var dotnetPath = ""
/// Interface language: the system's, read at every launch.
- @Published var lang: Lang = Lang.device()
+ @Published var lang: Lang = Lang.initial()
func t(_ key: String) -> String { L10n.string(key, lang) }
private var proc: Process?
@@ -235,6 +235,7 @@ final class BuildModel: ObservableObject {
for base in ["/ZCodeProject/", "/", "/Documents/", "/Desktop/"] {
seeds.append(NSHomeDirectory() + base + "nxnative")
seeds.append(NSHomeDirectory() + base + "NX2Apple")
+ seeds.append(NSHomeDirectory() + base + "NX2Apple")
seeds.append(NSHomeDirectory() + base + "nxnative-romfs-archive") // clones made before the rename still resolve
}
var seen = Set<String>()
@@ -286,7 +287,7 @@ final class BuildModel: ObservableObject {
func cloneRepo() {
guard !running, !repoBusy else { return }
guard let git = Self.gitBinary() else { repoStatus = t("repo.gitMissing"); return }
- let dest = NSHomeDirectory() + "/nxnative"
+ let dest = NSHomeDirectory() + "/NX2Apple"
if FileManager.default.fileExists(atPath: dest) {
if Self.isRepo(dest) { repoPath = dest; repoStatus = ""; checkRepoUpdates() }
else { repoStatus = String(format: t("repo.destBusy"), shortPath(dest)) }
@@ -425,7 +426,7 @@ final class BuildModel: ObservableObject {
if Self.isNewer(tag, than: Self.appVersion),
let assets = obj["assets"] as? [[String: Any]] {
// nxnative-macOS-arm64.zip; releases from before the rename name it NS-Port-Builder-macOS-arm64.zip
- for name in ["nxnative-macOS-arm64.zip", "NS-Port-Builder-macOS-arm64.zip"] where found == nil {
+ for name in ["NX2Apple-macOS-arm64.zip", "nxnative-macOS-arm64.zip", "NS-Port-Builder-macOS-arm64.zip"] where found == nil {
for a in assets where (a["name"] as? String) == name {
if let u = a["browser_download_url"] as? String { found = (tag, u) }
}
@@ -472,7 +473,7 @@ final class BuildModel: ObservableObject {
try? unzip.run(); unzip.waitUntilExit()
// The archive holds one app: nxnative.app, or NS Port Builder.app in a release from before the rename
let newApp = ((try? FileManager.default.contentsOfDirectory(at: dir, includingPropertiesForKeys: nil)) ?? [])
- .first { $0.pathExtension == "app" } ?? dir.appendingPathComponent("nxnative.app")
+ .first { $0.pathExtension == "app" } ?? dir.appendingPathComponent("NX2Apple.app")
guard unzip.terminationStatus == 0, FileManager.default.fileExists(atPath: newApp.path) else {
DispatchQueue.main.async { self.appBusy = false; self.appStatus = self.t("app.netFail") }
return
@@ -480,7 +481,7 @@ final class BuildModel: ObservableObject {
// Copy the new bundle in beside the running one first: from there on every step is a
// same-volume move, and a failure anywhere leaves a working app on disk.
let cur = Bundle.main.bundleURL
- let staging = cur.deletingLastPathComponent().appendingPathComponent("nxnative (new).app")
+ let staging = cur.deletingLastPathComponent().appendingPathComponent("NX2Apple (new).app")
try? FileManager.default.removeItem(at: staging)
do {
try FileManager.default.copyItem(at: newApp, to: staging)
@@ -1811,7 +1812,24 @@ struct BuilderView: View {
}
tools
group(m.t("section.app"), footnote: m.appStatus) {
- row("nxnative", detail: String(format: m.t("app.version"), BuildModel.appVersion)) {
+ // The interface language: the device default unless someone picks one here. Stored as
+ // "" (follow), "zh" or "en" so a later system-language change still applies.
+ row(m.t("settings.language"),
+ detail: Lang.saved.map { $0 == .zh ? m.t("settings.language.zh") : m.t("settings.language.en") }
+ ?? m.t("settings.language.system"), dot: LauncherPalette.ready, help: "") {
+ Picker("", selection: Binding(
+ get: { Lang.saved.map { $0.rawValue } ?? "" },
+ set: { v in
+ Lang.saved = v.isEmpty ? nil : Lang(rawValue: v)
+ m.lang = Lang.initial()
+ })) {
+ Text(m.t("settings.language.system")).tag("")
+ Text(m.t("settings.language.zh")).tag("zh")
+ Text(m.t("settings.language.en")).tag("en")
+ }
+ .pickerStyle(.menu).labelsHidden().frame(width: 150)
+ }
+ row("NX2Apple", detail: String(format: m.t("app.version"), BuildModel.appVersion)) {
if let u = m.appUpdate {
Button(String(format: m.t("app.updateBtn"), u.tag)) { m.performAppUpdate() }.disabled(m.appBusy)
} else {
diff --git a/frontend/Sources/NSPortBuilder/LauncherView.swift b/frontend/Sources/NSPortBuilder/LauncherView.swift
index 2c1a643a..17ee83b5 100644
--- a/frontend/Sources/NSPortBuilder/LauncherView.swift
+++ b/frontend/Sources/NSPortBuilder/LauncherView.swift
@@ -122,8 +122,14 @@ struct ContentView: View {
private var topBar: some View {
HStack(spacing: 6) {
- Text("nxnative").font(.manrope(27, .bold)).tracking(-0.8)
- .padding(.trailing, 34)
+ // The project is NX2Apple (the user's call: what this fork produces is NX2Apple);
+ // "by nxnative" credits the engine it stands on, which the sketch kept.
+ VStack(alignment: .leading, spacing: -2) {
+ Text("NX2Apple").font(.manrope(27, .bold)).tracking(-0.8)
+ Text("— by nxnative").font(.manrope(10.5, .medium))
+ .foregroundStyle(LauncherPalette.unbuilt).tracking(0.2)
+ }
+ .padding(.trailing, 34)
ForEach(LauncherPage.allCases, id: \.self) { destination in
Button { page = destination } label: {
Label(m.t("nav." + destination.rawValue), systemImage: destination.symbol)
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index a19bb4e4..7be40a5b 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -16,6 +16,26 @@ enum Lang: String {
guard let first = Locale.preferredLanguages.first?.lowercased() else { return .en }
return first.hasPrefix("zh") ? .zh : .en
}
+
+ /// What the app starts in: the language picked in Settings, else the device's.
+ ///
+ /// The picker exists because the device language is not always the one someone wants to read
+ /// this app in (a Chinese Windows display language on hardware bought abroad, a Mac kept in
+ /// English by habit). "Follow the system" stays the default; the three states are stored as
+ /// "" (follow), "zh", "en".
+ static func initial() -> Lang {
+ switch UserDefaults.standard.string(forKey: "appLanguage") ?? "" {
+ case "zh": return .zh
+ case "en": return .en
+ default: return device()
+ }
+ }
+
+ /// The stored choice, or nil when following the system.
+ static var saved: Lang? {
+ get { Lang(rawValue: UserDefaults.standard.string(forKey: "appLanguage") ?? "") }
+ set { UserDefaults.standard.set(newValue?.rawValue ?? "", forKey: "appLanguage") }
+ }
}
enum L10n {
@@ -68,6 +88,11 @@ enum L10n {
"nav.library": ("\u{6e38}\u{620f}\u{5e93}", "Library"),
"nav.builds": ("\u{6784}\u{5efa}", "Builds"),
"nav.settings": ("\u{8bbe}\u{7f6e}", "Settings"),
+ "settings.language": ("界面语言", "Language"),
+ "settings.language.system": ("跟随系统", "Follow system"),
+ "settings.language.zh": ("中文", "\u{4e2d}\u{6587}"),
+ "settings.language.en": ("English", "English"),
+ "settings.appNote2": ("构建你自己的 Switch 游戏", "Build your own Switch games"),
"library.setupHint": ("\u{9996}\u{6b21}\u{6784}\u{5efa}\u{524d}\u{ff0c}\u{8bf7}\u{5b8c}\u{6210}\u{4ee5}\u{4e0b}\u{8bbe}\u{7f6e}\u{3002}", "Before your first build, finish the setup below."),
"library.ready": ("\u{53ef}\u{5728} Mac \u{4e0a}\u{8fd0}\u{884c}", "Ready on Mac"),
"library.building": ("\u{6b63}\u{5728}\u{6784}\u{5efa}", "Building"),
diff --git a/frontend/Sources/NSPortBuilder/NSPortBuilderApp.swift b/frontend/Sources/NSPortBuilder/NSPortBuilderApp.swift
index 3c810a17..99326f63 100644
--- a/frontend/Sources/NSPortBuilder/NSPortBuilderApp.swift
+++ b/frontend/Sources/NSPortBuilder/NSPortBuilderApp.swift
@@ -3,7 +3,7 @@ import SwiftUI
@main
struct NSPortBuilderApp: App {
var body: some Scene {
- WindowGroup("nxnative") { ContentView() }
+ WindowGroup("NX2Apple") { ContentView() }
.windowStyle(.hiddenTitleBar)
.defaultSize(width: 1280, height: 900)
.windowResizability(.automatic)