import SwiftUI @main struct RouterOSAssistantApp: App { @StateObject private var connectionService = ConnectionService() /// Manual language override — independent of the system locale, per the user's explicit /// request for an in-app toggle button. `.environment(\.locale, ...)` does NOT make /// `Text(LocalizedStringKey)` re-resolve against Localizable.xcstrings at runtime (confirmed /// live: toggling had no visible effect), so views read this same AppStorage key directly and /// translate via `L10n.t(_:_:)` instead. @AppStorage("appLanguage") private var appLanguage: String = "de" var body: some Scene { WindowGroup { TabView { ConnectView(connectionService: connectionService) .tabItem { Label(L10n.t("Verbinden", appLanguage), systemImage: "network") } SetupView(connectionService: connectionService) .tabItem { Label(L10n.t("Einrichten", appLanguage), systemImage: "checklist") } OverviewView(connectionService: connectionService) .tabItem { Label(L10n.t("Übersicht", appLanguage), systemImage: "point.3.connected.trianglepath.dotted") } DevicesView(connectionService: connectionService) .tabItem { Label(L10n.t("LAN-Scanner", appLanguage), systemImage: "laptopcomputer.and.iphone") } ExpertView(connectionService: connectionService) .tabItem { Label(L10n.t("Experte", appLanguage), systemImage: "wrench.and.screwdriver") } BackupListView(connectionService: connectionService) .tabItem { Label(L10n.t("Sicherungen", appLanguage), systemImage: "clock.arrow.circlepath") } } .toolbar { ToolbarItem { Button { appLanguage = (appLanguage == "de") ? "en" : "de" } label: { // Flag of the language a tap switches TO — matches the "DE"/"EN" text // labels this replaces, which showed the same "switch to" target. Text(appLanguage == "de" ? "🇬🇧" : "🇩🇪") } .help(appLanguage == "de" ? "Switch to English" : "Auf Deutsch umschalten") } } } .environment(\.locale, Locale(identifier: appLanguage)) } }