From e95be1902ce6330e26c4aa8cc16cc9c175d778a4 Mon Sep 17 00:00:00 2001 From: REMIXPLAYER <2957871186@QQ.com> Date: Fri, 23 Oct 2026 00:04:06 +0800 Subject: [PATCH 1/3] Add Simplified Chinese (zh-Hans) localization for the macOS app UI. Wire user-visible String values through a small L10n helper and ship zh-Hans Localizable/InfoPlist strings so the menu bar app follows the system language. English remains the source keys and development region. --- .../Resources/zh-Hans.lproj/InfoPlist.strings | 1 + .../zh-Hans.lproj/Localizable.strings | 362 ++++++++++++++++++ apple/Shared/ADB/ADBConnection.swift | 31 +- apple/Shared/ADB/ADBKey.swift | 12 +- apple/Shared/ADB/ADBSync.swift | 6 +- apple/Shared/Localization.swift | 16 + apple/Shared/PerformanceProfile.swift | 24 +- apple/Shared/ZipExtractor.swift | 33 +- apple/Subsystem/Model/AndroidImage.swift | 12 +- .../Subsystem/Model/AndroidPermissions.swift | 64 ++-- apple/Subsystem/Model/AndroidSetup.swift | 8 +- apple/Subsystem/Model/GrubEnvironment.swift | 2 +- apple/Subsystem/Model/LauncherGenerator.swift | 4 +- apple/Subsystem/Model/PackageInstaller.swift | 16 +- apple/Subsystem/Model/StorageJanitor.swift | 4 +- apple/Subsystem/Model/Subsystem.swift | 107 +++--- apple/Subsystem/Model/SubsystemSettings.swift | 12 +- apple/Subsystem/Model/VirtualMachine.swift | 8 +- apple/Subsystem/SubsystemApp.swift | 22 +- apple/Subsystem/Views/MenuBarView.swift | 9 +- .../Subsystem/Views/PrivacySettingsView.swift | 22 +- apple/Subsystem/Views/SettingsChrome.swift | 65 ++-- apple/Subsystem/Views/SettingsView.swift | 65 ++-- apple/Subsystem/Views/SetupView.swift | 8 +- apple/project.yml | 5 + 25 files changed, 664 insertions(+), 254 deletions(-) create mode 100644 apple/Resources/zh-Hans.lproj/InfoPlist.strings create mode 100644 apple/Resources/zh-Hans.lproj/Localizable.strings create mode 100644 apple/Shared/Localization.swift diff --git a/apple/Resources/zh-Hans.lproj/InfoPlist.strings b/apple/Resources/zh-Hans.lproj/InfoPlist.strings new file mode 100644 index 0000000..8692689 --- /dev/null +++ b/apple/Resources/zh-Hans.lproj/InfoPlist.strings @@ -0,0 +1 @@ +"NSMicrophoneUsageDescription" = "你允许的 Android 应用可以使用本机麦克风。请在本 App 的“设置”›“系统”中开启。"; diff --git a/apple/Resources/zh-Hans.lproj/Localizable.strings b/apple/Resources/zh-Hans.lproj/Localizable.strings new file mode 100644 index 0000000..c2c562d --- /dev/null +++ b/apple/Resources/zh-Hans.lproj/Localizable.strings @@ -0,0 +1,362 @@ +/* Mac Android Subsystem - Simplified Chinese (zh-Hans). + Keys are the English source text. */ + +/* Sections and common actions */ +"System" = "系统"; +"Performance" = "性能"; +"Apps" = "应用"; +"Privacy" = "隐私"; +"Files" = "文件"; +"Storage" = "储存"; +"Advanced" = "高级"; +"About" = "关于"; +"Resources" = "资源"; +"Integration" = "集成"; +"Mode" = "模式"; +"Limits" = "资源上限"; +"Game controllers" = "游戏手柄"; +"Developer" = "开发者"; +"App windows" = "应用窗口"; +"Clean-up" = "清理"; +"Credits" = "致谢"; +"Search" = "搜索"; +"OK" = "好"; +"Done" = "完成"; +"Start" = "启动"; +"Restart" = "重启"; +"Turn Off" = "关闭"; +"Later" = "稍后"; +"Restart Now" = "立即重启"; +"Copy" = "复制"; +"Open" = "打开"; +"Show in Finder" = "在访达中显示"; +"Install" = "安装"; +"Uninstall" = "卸载"; +"Send" = "发送"; +"Use Image" = "使用镜像"; +"Replace" = "替换"; +"Cancel" = "取消"; +"None" = "无"; +"Running" = "正在运行"; +"Image" = "镜像"; + +/* System */ +"Always ready" = "始终就绪"; +"Start with your Mac and keep Android running in the background, so Android apps open instantly. %@ stays in the menu bar." = "登录后启动,并使 Android 在后台保持运行,以便应用迅速打开。%@ 仍显示在菜单栏。"; +"When the last Android app closes" = "最后一个 Android 应用关闭之后"; +"Automatic" = "自动"; +"As needed" = "需要时"; +"Continuous" = "保持运行"; +"Follows the performance mode: Smart, Standard and Performance keep Android ready (Smart lets it idle at the lowest level). Power Saver turns it off as soon as no app is open." = "智能、标准和性能保持运行,智能空闲时降到省电档。省电模式在没有 Android App 打开时关闭 Android。"; +"Android starts when you open an Android app and turns off a few minutes after you close the last one. Apps take longer to open the first time." = "打开 Android App 时启动。达到设定的分钟数后关闭。首次打开等待更长。"; +"Android stays ready in the background, so apps open quickly. Uses more memory and battery. Power Saver still turns it off when no app is open." = "Android 在后台保持运行,应用可以迅速打开,但会占用更多内存和电量。没有应用打开时,省电模式仍会关闭 Android。"; +"Power Saver is on: Android turns off 30 seconds after the last Android app closes." = "省电模式开启时:最后一个 Android 应用关闭 30 秒后,Android 也会关闭。"; +"Turn off after %@ minutes without open apps" = "没有应用打开时,%@ 分钟后关闭 Android"; +"Start %@ when you log in" = "登录时启动 %@"; +"Show Android notifications on the Mac" = "在本机显示 Android 通知"; +"Let Android apps use the microphone" = "允许 Android 应用使用本机麦克风"; +"Android is %@" = "Android %@"; +"Starting" = "正在启动"; +"Turning off" = "正在关闭"; +"Off" = "已关闭"; +"Not set up" = "尚未设置"; +"Stopped with an error" = "因错误停止"; +"Running · %@" = "正在运行 · %@"; +"Starting…" = "正在启动…"; +"Turning off…" = "正在关闭…"; +"Start Android, keep it ready in the background, and choose what happens when the last app closes." = "启动 Android,使其在后台保持运行,并选择最后一个应用关闭后的行为。"; +"Start Android" = "启动 Android"; +"Turn off Android" = "关闭 Android"; + +/* Performance */ +"Power Saver" = "省电"; +"Smart" = "智能"; +"Standard" = "标准"; +"Saving power" = "省电"; +"Balanced" = "均衡"; +"Android only runs while an Android app is open, and adapts while it does: frugal by default, a little faster for the app in front when your Mac has power to spare." = "仅在 Android 应用打开时运行。默认省电档。本机资源充足时,前台应用使用均衡档。"; +"Stays ready so apps open instantly, and adapts all the time: full speed for the app you're using, and power saving as soon as other apps need your Mac or the battery runs low." = "后台保持运行,应用可迅速打开。前台使用性能档;其他应用需要资源或电量偏低时改为省电档。"; +"Android runs as it is, with nothing tuned: every processor core, all of its memory and its own power settings. Stays ready in the background." = "用满「设置」中为 Android 指定的核心和内存,不改 Android 的电源设置,后台保持就绪。"; +"Maximum performance, all the time: every core and all of Android's memory, its game optimizations, up to 120 fps and lower input latency." = "用满「设置」中为 Android 指定的核心和内存,启用游戏优化。窗口最高 120 fps,输入延迟更低。"; +"Right now: %@. App windows stream at up to %@ fps; windows opened from now on use it." = "当前档位:%@。应用窗口最高 %@ fps,此后新打开的窗口使用此帧率。"; +"The mode applies whenever Android is running." = "Android 运行期间使用此模式。"; +"Processor cores for Android" = "Android 的处理器核心"; +"Memory for Android" = "Android 的内存"; +"%@ GB" = "%@ GB"; +"These are the most Android can use. Power Saver and Smart lend part of them back to macOS while Android runs. Changes take effect the next time Android starts." = "这是上限。省电和智能运行时,实际占用低于此上限。更改后,下次启动 Android 时生效。"; +"Connected controllers" = "已连接的手柄"; +"Pair a controller in System Settings › Bluetooth (Xbox, PlayStation, Switch Pro and MFi controllers work). It appears in the Android app whose window is in front." = "在“系统设置”›“蓝牙”中配对 Xbox、PlayStation、Switch Pro 或 MFi 手柄。配对后,手柄出现在当前最前面的 Android 应用中。"; +"How much of your Mac Android may use, and game controllers." = "Android 可使用的资源,以及游戏手柄。"; +"Use game controllers in Android games" = "在 Android 游戏中使用手柄"; + +/* Apps */ +"No Android apps yet" = "还没有 Android 应用"; +"Install an APK, or get F-Droid to browse free and open-source apps." = "安装一个 APK,或获取 F-Droid,浏览自由及开源应用。"; +"Start Android to see its apps, or install an APK (Android starts automatically)." = "请先启动 Android,再查看已安装的应用。直接安装 APK 也会启动 Android。"; +"Install APK…" = "安装 APK…"; +"Get F-Droid" = "获取 F-Droid"; +"Privacy…" = "隐私…"; +"Uninstall…" = "卸载…"; +"%@ apps" = "%@ 个应用"; +"Each app is also in Launchpad and Applications › %@" = "每个应用也会出现在“启动台”和“应用程序”› %@ 中"; +"Uninstall %@?" = "卸载 %@?"; +"The app and its data are removed from Android and its Mac launcher is deleted." = "会从 Android 中删除此应用及其数据,并删除本机上的图标。"; +"Your Android apps, installing apps and app stores." = "已安装的 Android 应用,以及安装新应用和商店。"; + +/* Files */ +"Drop files here to send them to Android" = "将文件拖到此处,以发送到 Android"; +"They're copied into Android's Download folder, where Android apps can open them." = "文件会复制到 Android 的 Download 文件夹,Android 应用可以打开这些文件。"; +"Choose Files…" = "选择文件…"; +"Open Android's Files app" = "打开 Android 的 Files 应用"; +"To move files the other way, share them from an Android app, or use ADB (Advanced › Developer mode)." = "从 Android 传出文件时,可在 Android 应用中分享,或打开“高级”›“开发者模式”后使用 ADB。"; +"Share files between your Mac and Android." = "在本机与 Android 之间传输文件。"; + +/* Storage */ +"Android image" = "Android 镜像"; +"Android apps and data" = "Android 应用和数据"; +"App launchers" = "应用启动器"; +"Downloads, logs and other" = "下载、日志和其他"; +"Space used: %@" = "已使用 %@"; +"Clean up automatically" = "自动清理"; +"Removes finished downloads, leftovers from installs and updates, icons of removed apps and old logs, and releases space Android no longer uses. When your Mac is low on space it also clears Android apps' caches, and once a week (on power, while Android is off) it compacts Android's disks." = "清除已完成的下载,以及安装和更新留下的文件、已删除应用的图标和旧日志,并释放 Android 不再使用的空间。本机空间不足时,还会清除 Android 应用的缓存。每周一次,在接通电源且 Android 已关闭时,压缩 Android 的磁盘。"; +"Cleaning Up…" = "正在清理…"; +"Clean Up Now" = "立即清理"; +"Compacting Android's disks needs Android to be off; Clean Up Now does everything else while it runs." = "压缩磁盘前需关闭 Android。Android 运行期间,“立即清理”仍会完成除此之外的清理。"; +"Space Android uses on your Mac, and automatic clean-up." = "Android 在本机占用的空间,以及自动清理。"; +"Freed %@ on %@." = "在 %2$@ 释放了 %1$@。"; +"Nothing to clean up on %@." = "%@,没有可清理的内容。"; + +/* Advanced */ +"Developer mode" = "开发者模式"; +"ADB address" = "ADB 地址"; +"Run `adb connect %@` in Terminal, or use Android Studio. ADB only listens on this Mac. The first time, Android asks to allow this computer only if the image requires it." = "在“终端”运行 `adb connect %@`,或用 Android Studio 连接。ADB 仅监听本机。部分镜像在首次连接时,要求在 Android 系统中允许本机。"; +"Show Android's own screen in a window" = "在单独窗口中显示 Android 桌面"; +"For troubleshooting: shows Android's home screen in a separate window. Takes effect when Android restarts." = "供排查问题使用。会另外打开一个窗口以显示 Android 桌面,重启 Android 后生效。"; +"App size" = "显示大小"; +"Show Android's on-screen keyboard" = "显示 Android 屏幕键盘"; +"Both apply to app windows opened from now on." = "仅影响此后新打开的应用窗口。"; +"Download Latest Android…" = "下载最新版 Android…"; +"Use an Image File…" = "使用镜像文件…"; +"Rebuild App Launchers" = "重建应用启动器"; +"Show Log" = "显示日志"; +"Show Android Console" = "显示 Android 控制台"; +"Show Data Folder" = "显示数据文件夹"; +"Reset Android…" = "重置 Android…"; +"Removes every Android app and all their data, like a factory reset." = "清除所有 Android 应用和数据,相当于恢复出厂设置。"; +"Reset Android?" = "重置 Android?"; +"Reset" = "重置"; +"All Android apps and their data will be erased. This can't be undone." = "所有 Android 应用和数据都会被清除。此操作无法撤销。"; +"Download the latest Android?" = "下载最新版 Android?"; +"Download and Replace" = "下载并替换"; +"Installing a new Android image erases all Android apps and their data." = "更换为新的 Android 镜像后,现有的应用和数据都会被清除。"; +"Developer mode, ADB, the Android image, logs and reset." = "开发者模式、ADB、Android 镜像、日志和重置。"; +"Running version" = "正在运行的版本"; + +/* About */ +"Version %@" = "版本 %@"; +"Device name" = "设备名称"; +"Mac app" = "Mac 应用"; +"Source code (GPLv3)" = "源代码(GPLv3)"; +"Guide" = "指南"; +"Android apps on your Mac: Android runs in a virtual machine with Apple's Hypervisor framework, and every Android app gets its own Mac window. Built on LineageOS, QEMU and scrcpy. An independent project, not made or endorsed by Google or the LineageOS project. Android is a trademark of Google LLC. The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License." = "在本机运行 Android 应用。Android 在虚拟机中运行,使用 Apple 的 Hypervisor,每个应用有各自的窗口。基于 LineageOS、QEMU 和 scrcpy。这是独立项目,不是 Google 或 LineageOS 项目制作的,也未获它们认可。Android 是 Google LLC 的商标。机器人形象来自 Google 创作并共享的作品,按 Creative Commons 3.0 署名许可复制或修改后使用。"; +"Version, licences and acknowledgements." = "版本、许可和致谢。"; + +/* Sidebar and restart banner */ +"Which Android apps may use the camera, microphone, location and more." = "Android 应用的权限。麦克风为本机麦克风。"; +"Restart Android to apply your changes" = "这些更改在重启 Android 后生效"; +"Changes to %@ take effect when Android restarts. Open Android apps close while it restarts." = "更改“%@”将在重启 Android 后生效。重启时,正在运行的 Android 应用会关闭。"; + +/* Setup */ +"Set up %@" = "设置 %@"; +"Android apps on your Mac: every Android app in its own window, with its own icon in Launchpad and the Dock." = "在本机打开 Android 应用。每个应用有各自的窗口,也会出现在“启动台”和“程序坞”中。"; +"Downloads Android 17 (LineageOS 24, no Google apps), about 1.5 GB." = "下载 Android 17(LineageOS 24,不含 Google 应用),大约 1.5 GB。"; +"Android runs in a lightweight virtual machine on Apple silicon, at close to native speed." = "Android 在 Apple 芯片的轻量虚拟机中运行,速度接近原生。"; +"Everything stays on this Mac. Android only talks to the Mac through 127.0.0.1." = "数据保留在本机。Android 仅通过 127.0.0.1 与本机通信。"; +"Install F-Droid, the free and open-source app store" = "安装 F-Droid,自由及开源应用商店"; +"Always ready: start with my Mac and keep Android running in the background" = "始终就绪:登录后启动,并使 Android 在后台保持运行"; +"Download Android" = "下载 Android"; +"What's in the image, and how to build your own" = "镜像包含的内容,以及如何自行制作"; + +/* Privacy */ +"Android is off" = "Android 已关闭"; +"Start Android to see which apps can use your camera, microphone, location and other private data." = "启动 Android 后,可查看哪些应用申请过摄像头、麦克风、位置信息和其他权限。"; +"Apps ask for access when they need it. Here you can see which apps asked and turn access on or off at any time." = "应用会在需要时申请权限,可在此处查看和开关。除本机麦克风外,其余都是 Android 系统中的权限,不是“系统设置”中“隐私与安全性”的开关。"; +"Let Android use this Mac's microphone" = "允许 Android 使用本机麦克风"; +"Android has no microphone when this is off, whatever apps are allowed. A change takes effect the next time Android starts." = "关闭后,Android 将没有麦克风。即使应用已获得允许,也无法使用。下次启动 Android 后生效。"; +"Android has no microphone when this is off, whatever apps are allowed." = "关闭后,Android 将没有麦克风。即使应用已获得允许,也无法使用。"; +"Android doesn't have a camera on this Mac yet, so apps can't take photos even when allowed." = "本机尚未向 Android 系统提供摄像头。即使允许,应用也无法拍照或录像。"; +"Android has no location source on this Mac, so apps can't find where you are even when allowed." = "Android 系统在本机上没有位置来源。即使允许,也无法获得位置,也不会使用“系统设置”中的“定位服务”。"; +"Android has no phone service on this Mac." = "本机上的 Android 系统没有蜂窝网络,无法拨打电话,也没有通话记录和短信。"; +"Android has no body or motion sensors on this Mac." = "本机没有向 Android 系统提供心率或运动数据。即使允许,应用也无法读取。"; +"Checking apps…" = "正在查看应用…"; +"No apps have asked to %@." = "还没有应用申请%@。"; +"Apps that asked to %@" = "申请%@的应用"; +"Turning access on allows it while the app is in use. Turning it off also removes access in the background." = "打开后,应用仅能在使用时获取位置。关闭后,后台的位置权限也会一并关闭。"; +"Checking…" = "正在查看…"; +"%@ hasn't asked for access to any private data." = "%@ 还没有申请任何权限。"; +"Android manages this permission for %@." = "%@ 的这项权限由 Android 系统锁定,无法在此更改。"; +"%@ for %@" = "%2$@ 的%1$@"; +"Couldn't change access" = "未能更改这项权限"; +"Camera" = "摄像头"; +"Microphone" = "麦克风"; +"Location" = "位置信息"; +"Contacts" = "通讯录"; +"Calendars" = "日历"; +"Photos & Videos" = "照片与视频"; +"Music & Audio" = "音乐与音频"; +"Notifications" = "通知"; +"Phone" = "电话"; +"Call Logs" = "通话记录"; +"Messages" = "短信"; +"Nearby Devices" = "附近设备"; +"Body Sensors" = "身体传感器"; +"Physical Activity" = "身体活动"; +"take photos and record video" = "使用摄像头"; +"record audio" = "使用麦克风"; +"know where you are" = "获取位置"; +"read and change your contacts" = "读取或修改通讯录"; +"read and change your calendars" = "读取或修改日历"; +"see photos and videos" = "查看照片和视频"; +"see music and other audio" = "查看音乐和音频"; +"read and change shared files" = "读取或修改文件"; +"send notifications" = "发送通知"; +"make and manage calls" = "拨打或管理电话"; +"read and change the call history" = "读取或修改通话记录"; +"send and read text messages" = "读取或发送短信"; +"find and connect to nearby devices" = "查找并连接附近设备"; +"read heart rate and other body sensors" = "读取心率等身体传感器"; +"know when you walk, run or cycle" = "识别步行、跑步或骑行"; +"Android didn't change %1$@ for %2$@: %3$@" = "未能更改 %2$@ 的%1$@权限:%3$@"; + +/* Menu bar */ +"Android: %@" = "Android:%@"; +" · %@" = " · %@"; +"Restart Android to Apply Changes" = "重启 Android 使更改生效"; +"Turn Off Android" = "关闭 Android"; +"Set Up Android…" = "设置 Android…"; +"Performance Mode" = "性能模式"; +"Always Ready (Start with Mac)" = "始终就绪(登录时启动)"; +"Open Android App" = "打开 Android 应用"; +"Install Android App…" = "安装 Android 应用…"; +"Settings…" = "设置…"; +"Quit %@" = "退出 %@"; +"Restart Android" = "重启 Android"; + +/* File pickers and alerts */ +"Install Android Apps" = "安装 Android 应用"; +"Choose an Android Image" = "选择 Android 镜像"; +"Choose a UTM-VM-lineage-…-virtio_arm64only.zip file or a .utm folder." = "选择 UTM-VM-lineage-…-virtio_arm64only.zip,或一个 .utm 文件夹。"; +"Send Files to Android" = "发送文件到 Android"; +"Replace Android with %@?" = "用 %@ 替换 Android?"; +"All Android apps and their data will be erased." = "所有 Android 应用和数据都会被清除。"; + +/* Subsystem status, notices and busy messages */ +"memory" = "内存"; +"processor cores" = "处理器核心"; +"microphone" = "麦克风"; +"Android screen window" = "Android 桌面窗口"; +"Android isn't set up yet" = "Android 尚未设置"; +"Download Android first in %@ settings." = "请先在 %@ 的“设置”中下载 Android。"; +"Finishing a storage clean-up…" = "正在完成清理…"; +"Starting Android…" = "正在启动 Android…"; +"Restarting Android…" = "正在重启 Android…"; +"Setting up Android for the first time…" = "正在首次设置 Android…"; +"Preparing apps…" = "正在准备应用…"; +"Android didn't start" = "Android 未能启动"; +"In the Android window, tick “Always allow from this computer” and click Allow." = "在 Android 窗口中勾选“Always allow from this computer”,然后点按 Allow。这是在允许本机连接。"; +"Android stopped unexpectedly (QEMU exit code %@).%@\nThe full log is in Settings › Advanced › Show Log." = "Android 意外停止了(QEMU 退出代码 %@)。%@\n完整日志在“设置”›“高级”›“显示日志”。"; +"Can't install this file" = "无法安装此文件"; +"Choose an .apk, .apks, .apkm or .xapk file." = "请选择 .apk、.apks、.apkm 或 .xapk 文件。"; +"Starting Android to install %@…" = "正在启动 Android 以安装 %@…"; +"Finish setting up %@, then install the app again." = "请先完成 %@ 的设置,然后重新安装此应用。"; +"Installing %@…" = "正在安装 %@…"; +"%@ installed" = "%@ 已安装"; +"Find it in Launchpad, Spotlight and Applications › %@." = "可在“启动台”、“聚焦”和“应用程序”› %@ 中找到。"; +"Start Android to uninstall apps." = "请先启动 Android,再卸载应用。"; +"Removing %@…" = "正在卸载 %@…"; +"Couldn't remove %@" = "未能卸载 %@"; +"Downloading F-Droid…" = "正在下载 F-Droid…"; +"Couldn't download F-Droid" = "未能下载 F-Droid"; +"Start Android to send files to it." = "请先启动 Android,再将文件发送到 Android。"; +"Sending files to Android…" = "正在将文件发送到 Android…"; +"Files sent" = "文件已发送"; +"They're in Android's Download folder (open Files)." = "这些文件位于 Android 的 Download 文件夹。可用 Files 应用打开。"; +"Some files weren't sent" = "有些文件未能发送"; +"Finding the latest Android…" = "正在查找最新版 Android…"; +"Downloading Android… %@ of %@" = "正在下载 Android… %@ / %@"; +"Downloading Android…" = "正在下载 Android…"; +"Checking the download…" = "正在检查下载的文件…"; +"Couldn't download Android" = "未能下载 Android"; +"Unpacking Android…" = "正在解压 Android…"; +"Couldn't install Android" = "未能安装 Android"; +"Android was reset" = "Android 已重置"; +"All Android apps and their data were removed." = "所有 Android 应用和数据都已清除。"; +"Some apps weren't installed" = "有些应用未能安装"; + +/* User-facing failures */ +"Android didn't finish starting." = "Android 未能完成启动。"; +"Android's ADB is in trade-in mode, so this Mac can't set it up. Reset Android in Settings and try again." = "Android 的 ADB 处于 trade-in 模式,本机无法继续设置。请在“设置”中重置 Android,然后重试。"; +"bridge.apk is missing from this copy of %@." = "此 %@ 中没有 bridge.apk。"; +"Couldn't install the bridge app: %@" = "未能安装 bridge 应用:%@"; +"Couldn't change Android's boot settings: %@" = "未能修改 Android 的启动设置:%@"; +"QEMU is missing from this copy of %@. Reinstall it (or, for development, run `brew install qemu`)." = "此 %@ 中没有 QEMU。请重新安装。进行开发时,也可在“终端”运行 `brew install qemu`。"; +"The UEFI firmware (edk2-aarch64-code.fd) is missing." = "缺少 UEFI 固件 edk2-aarch64-code.fd。"; +"Port %@ on this Mac is already in use, so Android's ADB can't be reached. Quit the program using it (often another Android emulator) and try again." = "本机端口 %@ 已被占用,因此无法连接 Android 的 ADB。请先退出占用该端口的程序,通常是另一个 Android 模拟器,然后重试。"; +"Android couldn't start: %@" = "Android 无法启动:%@"; +"This file doesn't contain a LineageOS virtual machine (a .utm folder with config.plist)." = "此文件中没有 LineageOS 虚拟机,需要带 config.plist 的 .utm 文件夹。"; +"The virtual machine has no disks." = "此虚拟机没有磁盘。"; +"Couldn't prepare Android's disks: %@" = "未能准备 Android 的磁盘:%@"; +"No Android image is available to download yet. Pick a UTM-VM-lineage zip instead (see the guide)." = "目前没有可下载的 Android 镜像。请改用 UTM-VM-lineage 的 zip,具体做法见指南。"; +"The download is damaged (its checksum doesn't match). Try again." = "下载的文件已损坏,校验和不符。请重试。"; +"The download failed: %@" = "下载失败:%@"; +"This file" = "此文件"; +".%@ files" = " .%@ 文件"; +"%@ can't be installed. Use .apk, .apks, .apkm or .xapk." = "无法安装%@。请改用 .apk、.apks、.apkm 或 .xapk。"; +"There are no APK files in this archive." = "此压缩包中没有 APK。"; +"This app is built only for Intel/x86 Android devices and can't run on an Apple silicon Mac." = "此应用仅适用于 Intel/x86 的 Android 设备,无法在 Apple 芯片的 Mac 上运行。"; +"This app needs a newer version of Android." = "此应用需要更高版本的 Android。"; +"A different build of this app is already installed. Uninstall it first." = "已安装此应用的不兼容版本。请先卸载。"; +"Android is out of storage space." = "Android 的储存空间不足。"; +"Android couldn't install the app:\n%@" = "Android 未能安装此应用:\n%@"; +"The app window host is missing from %@. Reinstall it." = "%@ 中缺少打开应用窗口的程序。请重新安装。"; +"Signing the launcher failed: %@" = "未能为启动器签名:%@"; +"Couldn't connect to Android: %@" = "无法连接到 Android:%@"; +"The connection to Android closed." = "与 Android 的连接已断开。"; +"Android didn't answer in time (%@)." = "Android 未能及时响应(%@)。"; +"Unexpected answer from Android (%@)." = "Android 的响应无法识别(%@)。"; +"Android hasn't allowed this Mac to connect yet." = "Android 尚未允许本机连接。"; +"Android refused %@." = "Android 拒绝了 %@。"; +"Couldn't create the ADB key: %@" = "未能创建 ADB 密钥:%@"; +"Couldn't sign the ADB token: %@" = "未能为 ADB 令牌签名:%@"; +"Couldn't read the ADB public key." = "无法读取 ADB 公钥。"; +"This file isn't a zip archive." = "此文件不是 zip 压缩包。"; +"%@ uses an unsupported compression method (%@). Re-zip it with standard compression." = "%@ 使用了不支持的压缩方式(%@)。请使用标准压缩重新打包。"; +"The zip archive is damaged (%@)." = "此 zip 压缩包已损坏(%@)。"; +"The archive contains an unsafe path: %@" = "压缩包中有不安全的路径:%@"; + +/* Technical diagnostics shown inside the messages above */ +"handshake" = "握手"; +"read" = "读取"; +"opening %@" = "打开 %@"; +"TLS is not supported on this port" = "此端口不支持 TLS"; +"command %@ during handshake" = "握手时收到命令 %@"; +"bad magic" = "文件头标识不匹配"; +"oversized message" = "消息过大"; +"bad address %@" = "地址无效:%@"; +"timed out" = "超时"; +"STAT reply" = "STAT 响应异常"; +"SEND reply %@" = "SEND 响应异常:%@"; +"push failed" = "发送失败"; +"unknown error" = "未知错误"; +"export failed" = "导出失败"; +"no answer" = "无响应"; +"missing ZIP64 locator" = "缺少 ZIP64 locator"; +"bad ZIP64 record" = "ZIP64 记录无效"; +"truncated central directory" = "中央目录不完整"; +"bad directory entry" = "目录项无效"; +"bad name" = "文件名无效"; +"bad local header for %@" = "%@ 的本地文件头无效"; +"unexpected end of %@" = "%@ 意外结束"; +"%@ is %@ bytes, expected %@" = "%1$@ 的大小是 %2$@ 字节,应该是 %3$@ 字节"; +"could not start decompression" = "无法开始解压"; +"could not inflate %@" = "无法解压 %@"; diff --git a/apple/Shared/ADB/ADBConnection.swift b/apple/Shared/ADB/ADBConnection.swift index 7e1eb77..5886bae 100644 --- a/apple/Shared/ADB/ADBConnection.swift +++ b/apple/Shared/ADB/ADBConnection.swift @@ -26,12 +26,12 @@ enum ADBError: LocalizedError { var errorDescription: String? { switch self { - case .connect(let detail): return "Couldn't connect to Android: \(detail)" - case .closed: return "The connection to Android closed." - case .timeout(let what): return "Android didn't answer in time (\(what))." - case .protocolError(let detail): return "Unexpected answer from Android (\(detail))." - case .unauthorized: return "Android hasn't allowed this Mac to connect yet." - case .serviceUnavailable(let service): return "Android refused \(service)." + case .connect(let detail): return L10n.format("Couldn't connect to Android: %@", detail) + case .closed: return L10n.text("The connection to Android closed.") + case .timeout(let what): return L10n.format("Android didn't answer in time (%@).", what) + case .protocolError(let detail): return L10n.format("Unexpected answer from Android (%@).", detail) + case .unauthorized: return L10n.text("Android hasn't allowed this Mac to connect yet.") + case .serviceUnavailable(let service): return L10n.format("Android refused %@.", service) case .command(let output): return output } } @@ -99,7 +99,7 @@ final class ADBConnection: @unchecked Sendable { do { message = try readMessage() } catch ADBError.timeout { - throw sentPublicKey ? ADBError.unauthorized : ADBError.timeout("handshake") + throw sentPublicKey ? ADBError.unauthorized : ADBError.timeout(L10n.text("handshake")) } switch Command(rawValue: message.command) { case .cnxn: @@ -122,9 +122,10 @@ final class ADBConnection: @unchecked Sendable { throw ADBError.unauthorized } case .stls: - throw ADBError.protocolError("TLS is not supported on this port") + throw ADBError.protocolError(L10n.text("TLS is not supported on this port")) default: - throw ADBError.protocolError(String(format: "command 0x%08x during handshake", message.command)) + throw ADBError.protocolError(L10n.format("command %@ during handshake", + String(format: "0x%08x", message.command))) } } } @@ -166,7 +167,7 @@ final class ADBConnection: @unchecked Sendable { guard stream.waitUntilOpen(timeout: timeout) else { forget(localID) if stream.isClosed { throw ADBError.serviceUnavailable(service) } - throw ADBError.timeout("opening \(service)") + throw ADBError.timeout(L10n.format("opening %@", service)) } return stream } @@ -293,9 +294,9 @@ final class ADBConnection: @unchecked Sendable { header.withUnsafeBytes { UInt32(littleEndian: $0.loadUnaligned(fromByteOffset: i * 4, as: UInt32.self)) } } let command = word(0) - guard word(5) == command ^ 0xffff_ffff else { throw ADBError.protocolError("bad magic") } + guard word(5) == command ^ 0xffff_ffff else { throw ADBError.protocolError(L10n.text("bad magic")) } let length = Int(word(3)) - guard length <= 16 * 1024 * 1024 else { throw ADBError.protocolError("oversized message") } + guard length <= 16 * 1024 * 1024 else { throw ADBError.protocolError(L10n.text("oversized message")) } let payload = length > 0 ? try readExactly(length) : Data() return Message(command: command, arg0: word(1), arg1: word(2), payload: payload) } @@ -316,7 +317,7 @@ final class ADBConnection: @unchecked Sendable { } else if errno == EINTR { continue } else if errno == EAGAIN || errno == EWOULDBLOCK { - throw ADBError.timeout("read") + throw ADBError.timeout(L10n.text("read")) } else { throw ADBError.closed } @@ -344,7 +345,7 @@ final class ADBConnection: @unchecked Sendable { address.sin_port = port.bigEndian guard inet_pton(AF_INET, host, &address.sin_addr) == 1 else { Darwin.close(socket) - throw ADBError.connect("bad address \(host)") + throw ADBError.connect(L10n.format("bad address %@", host)) } // Non-blocking connect so a dead port fails fast. @@ -368,7 +369,7 @@ final class ADBConnection: @unchecked Sendable { getsockopt(socket, SOL_SOCKET, SO_ERROR, &error, &length) if ready <= 0 || error != 0 { Darwin.close(socket) - throw ADBError.connect(ready <= 0 ? "timed out" : String(cString: strerror(error))) + throw ADBError.connect(ready <= 0 ? L10n.text("timed out") : String(cString: strerror(error))) } } _ = fcntl(socket, F_SETFL, flags & ~O_NONBLOCK) diff --git a/apple/Shared/ADB/ADBKey.swift b/apple/Shared/ADB/ADBKey.swift index 3496a63..e93aea8 100644 --- a/apple/Shared/ADB/ADBKey.swift +++ b/apple/Shared/ADB/ADBKey.swift @@ -25,9 +25,9 @@ final class ADBKey: @unchecked Sendable { case publicKey var errorDescription: String? { switch self { - case .generate(let detail): return "Couldn't create the ADB key: \(detail)" - case .sign(let detail): return "Couldn't sign the ADB token: \(detail)" - case .publicKey: return "Couldn't read the ADB public key." + case .generate(let detail): return L10n.format("Couldn't create the ADB key: %@", detail) + case .sign(let detail): return L10n.format("Couldn't sign the ADB token: %@", detail) + case .publicKey: return L10n.text("Couldn't read the ADB public key.") } } } @@ -52,10 +52,10 @@ final class ADBKey: @unchecked Sendable { ] var error: Unmanaged? guard let key = SecKeyCreateRandomKey(attributes as CFDictionary, &error) else { - throw Failure.generate(error?.takeRetainedValue().localizedDescription ?? "unknown error") + throw Failure.generate(error?.takeRetainedValue().localizedDescription ?? L10n.text("unknown error")) } guard let exported = SecKeyCopyExternalRepresentation(key, &error) as Data? else { - throw Failure.generate(error?.takeRetainedValue().localizedDescription ?? "export failed") + throw Failure.generate(error?.takeRetainedValue().localizedDescription ?? L10n.text("export failed")) } FileManager.default.createFile(atPath: file.path, contents: exported, attributes: [.posixPermissions: 0o600]) privateKey = key @@ -72,7 +72,7 @@ final class ADBKey: @unchecked Sendable { func sign(token: Data) throws -> Data { var error: Unmanaged? guard let signature = SecKeyCreateSignature(privateKey, .rsaSignatureDigestPKCS1v15SHA1, token as CFData, &error) as Data? else { - throw Failure.sign(error?.takeRetainedValue().localizedDescription ?? "unknown error") + throw Failure.sign(error?.takeRetainedValue().localizedDescription ?? L10n.text("unknown error")) } return signature } diff --git a/apple/Shared/ADB/ADBSync.swift b/apple/Shared/ADB/ADBSync.swift index 69b617c..09ee698 100644 --- a/apple/Shared/ADB/ADBSync.swift +++ b/apple/Shared/ADB/ADBSync.swift @@ -24,7 +24,7 @@ extension ADBConnection { try stream.write(Self.syncRequest("STAT", Data(path.utf8))) let reply = try stream.readExactly(16, timeout: 15) guard String(decoding: reply.prefix(4), as: UTF8.self) == "STAT" else { - throw ADBError.protocolError("STAT reply") + throw ADBError.protocolError(L10n.text("STAT reply")) } try? stream.write(Self.syncRequest("QUIT", Data())) return RemoteFile(mode: reply.le32(4), size: reply.le32(8), modified: reply.le32(12)) @@ -72,10 +72,10 @@ extension ADBConnection { let id = String(decoding: reply.prefix(4), as: UTF8.self) if id == "FAIL" { let length = Int(reply.le32(4)) - let message = (try? stream.readExactly(length, timeout: 5)).map { String(decoding: $0, as: UTF8.self) } ?? "push failed" + let message = (try? stream.readExactly(length, timeout: 5)).map { String(decoding: $0, as: UTF8.self) } ?? L10n.text("push failed") throw ADBError.command(message) } - guard id == "OKAY" else { throw ADBError.protocolError("SEND reply \(id)") } + guard id == "OKAY" else { throw ADBError.protocolError(L10n.format("SEND reply %@", id)) } try? stream.write(Self.syncHeader("QUIT", 0)) } diff --git a/apple/Shared/Localization.swift b/apple/Shared/Localization.swift new file mode 100644 index 0000000..ac86188 --- /dev/null +++ b/apple/Shared/Localization.swift @@ -0,0 +1,16 @@ +// Mac Android Subsystem - localized strings for text held in String values. +// SwiftUI string literals localize themselves; model, status, notice and AppKit +// strings go through here so the English text is the lookup key. +// Licensed under the GNU General Public License v3 or later. + +import Foundation + +enum L10n { + static func text(_ key: String) -> String { + NSLocalizedString(key, comment: "") + } + + static func format(_ key: String, _ arguments: String...) -> String { + String(format: NSLocalizedString(key, comment: ""), arguments: arguments.map { $0 as CVarArg }) + } +} diff --git a/apple/Shared/PerformanceProfile.swift b/apple/Shared/PerformanceProfile.swift index 76d7b3e..ec4301f 100644 --- a/apple/Shared/PerformanceProfile.swift +++ b/apple/Shared/PerformanceProfile.swift @@ -46,10 +46,10 @@ enum PerformanceMode: String, Codable, CaseIterable, Identifiable, Sendable { var title: String { switch self { - case .powerSaver: return "Power Saver" - case .smart: return "Smart" - case .standard: return "Standard" - case .performance: return "Performance" + case .powerSaver: return L10n.text("Power Saver") + case .smart: return L10n.text("Smart") + case .standard: return L10n.text("Standard") + case .performance: return L10n.text("Performance") } } @@ -65,13 +65,13 @@ enum PerformanceMode: String, Codable, CaseIterable, Identifiable, Sendable { var summary: String { switch self { case .powerSaver: - return "Android only runs while an Android app is open, and adapts while it does: frugal by default, a little faster for the app in front when your Mac has power to spare." + return L10n.text("Android only runs while an Android app is open, and adapts while it does: frugal by default, a little faster for the app in front when your Mac has power to spare.") case .smart: - return "Stays ready so apps open instantly, and adapts all the time: full speed for the app you're using, and power saving as soon as other apps need your Mac or the battery runs low." + return L10n.text("Stays ready so apps open instantly, and adapts all the time: full speed for the app you're using, and power saving as soon as other apps need your Mac or the battery runs low.") case .standard: - return "Android runs as it is, with nothing tuned: every processor core, all of its memory and its own power settings. Stays ready in the background." + return L10n.text("Android runs as it is, with nothing tuned: every processor core, all of its memory and its own power settings. Stays ready in the background.") case .performance: - return "Maximum performance, all the time: every core and all of Android's memory, its game optimizations, up to 120 fps and lower input latency." + return L10n.text("Maximum performance, all the time: every core and all of Android's memory, its game optimizations, up to 120 fps and lower input latency.") } } } @@ -85,10 +85,10 @@ enum PerformanceLevel: String, Codable, Sendable { var title: String { switch self { - case .saver: return "Saving power" - case .balanced: return "Balanced" - case .standard: return "Standard" - case .performance: return "Performance" + case .saver: return L10n.text("Saving power") + case .balanced: return L10n.text("Balanced") + case .standard: return L10n.text("Standard") + case .performance: return L10n.text("Performance") } } diff --git a/apple/Shared/ZipExtractor.swift b/apple/Shared/ZipExtractor.swift index fcaddea..a4453c3 100644 --- a/apple/Shared/ZipExtractor.swift +++ b/apple/Shared/ZipExtractor.swift @@ -19,10 +19,12 @@ enum ZipExtractor { var errorDescription: String? { switch self { - case .notAZip: return "This file isn't a zip archive." - case .unsupportedMethod(let name, let method): return "\(name) uses an unsupported compression method (\(method)). Re-zip it with standard compression." - case .corrupt(let detail): return "The zip archive is damaged (\(detail))." - case .unsafePath(let name): return "The archive contains an unsafe path: \(name)" + case .notAZip: return L10n.text("This file isn't a zip archive.") + case .unsupportedMethod(let name, let method): + return L10n.format("%@ uses an unsupported compression method (%@). Re-zip it with standard compression.", + name, String(method)) + case .corrupt(let detail): return L10n.format("The zip archive is damaged (%@).", detail) + case .unsafePath(let name): return L10n.format("The archive contains an unsafe path: %@", name) } } } @@ -78,11 +80,11 @@ enum ZipExtractor { // ZIP64: a locator sits 20 bytes before the classic record. if count == 0xFFFF || directorySize == 0xFFFF_FFFF || directoryOffset == 0xFFFF_FFFF { - guard eocd >= 20, tail.zipLE32(eocd - 20) == 0x0706_4b50 else { throw Failure.corrupt("missing ZIP64 locator") } + guard eocd >= 20, tail.zipLE32(eocd - 20) == 0x0706_4b50 else { throw Failure.corrupt(L10n.text("missing ZIP64 locator")) } let zip64Offset = tail.zipLE64(eocd - 20 + 8) try handle.seek(toOffset: zip64Offset) guard let record = try handle.read(upToCount: 56), record.count == 56, record.zipLE32(0) == 0x0606_4b50 else { - throw Failure.corrupt("bad ZIP64 record") + throw Failure.corrupt(L10n.text("bad ZIP64 record")) } count = record.zipLE64(32) directorySize = record.zipLE64(40) @@ -91,13 +93,13 @@ enum ZipExtractor { try handle.seek(toOffset: directoryOffset) guard let directory = try handle.read(upToCount: Int(directorySize)), directory.count == Int(directorySize) else { - throw Failure.corrupt("truncated central directory") + throw Failure.corrupt(L10n.text("truncated central directory")) } var entries: [Entry] = [] var p = 0 for _ in 0.. 0 { try autoreleasepool { let data = try handle.read(upToCount: Int(min(UInt64(chunk), remaining))) ?? Data() - guard !data.isEmpty else { throw Failure.corrupt("unexpected end of \(entry.name)") } + guard !data.isEmpty else { throw Failure.corrupt(L10n.format("unexpected end of %@", entry.name)) } try out.write(contentsOf: data) remaining -= UInt64(data.count) } @@ -167,7 +169,8 @@ enum ZipExtractor { let size = try out.offset() if size != entry.uncompressedSize { - throw Failure.corrupt("\(entry.name) is \(size) bytes, expected \(entry.uncompressedSize)") + throw Failure.corrupt(L10n.format("%@ is %@ bytes, expected %@", + entry.name, String(size), String(entry.uncompressedSize))) } } @@ -175,7 +178,7 @@ enum ZipExtractor { let stream = UnsafeMutablePointer.allocate(capacity: 1) defer { stream.deallocate() } guard compression_stream_init(stream, COMPRESSION_STREAM_DECODE, COMPRESSION_ZLIB) == COMPRESSION_STATUS_OK else { - throw Failure.corrupt("could not start decompression") + throw Failure.corrupt(L10n.text("could not start decompression")) } defer { compression_stream_destroy(stream) } @@ -218,10 +221,10 @@ enum ZipExtractor { case COMPRESSION_STATUS_OK: // Out of input with nothing left to emit means the stream is truncated. if remaining == 0, stream.pointee.src_size == 0, idleRounds > 2 { - throw Failure.corrupt("unexpected end of \(entry.name)") + throw Failure.corrupt(L10n.format("unexpected end of %@", entry.name)) } default: - throw Failure.corrupt("could not inflate \(entry.name)") + throw Failure.corrupt(L10n.format("could not inflate %@", entry.name)) } } } diff --git a/apple/Subsystem/Model/AndroidImage.swift b/apple/Subsystem/Model/AndroidImage.swift index a56e13d..f64fa97 100644 --- a/apple/Subsystem/Model/AndroidImage.swift +++ b/apple/Subsystem/Model/AndroidImage.swift @@ -180,12 +180,12 @@ struct AndroidImage: Codable, Equatable, Sendable { var errorDescription: String? { switch self { - case .noPackage: return "This file doesn't contain a LineageOS virtual machine (a .utm folder with config.plist)." - case .noDisks: return "The virtual machine has no disks." - case .overlay(let output): return "Couldn't prepare Android's disks: \(output)" - case .noRelease: return "No Android image is available to download yet. Pick a UTM-VM-lineage zip instead (see the guide)." - case .checksum: return "The download is damaged (its checksum doesn't match). Try again." - case .download(let detail): return "The download failed: \(detail)" + case .noPackage: return L10n.text("This file doesn't contain a LineageOS virtual machine (a .utm folder with config.plist).") + case .noDisks: return L10n.text("The virtual machine has no disks.") + case .overlay(let output): return L10n.format("Couldn't prepare Android's disks: %@", output) + case .noRelease: return L10n.text("No Android image is available to download yet. Pick a UTM-VM-lineage zip instead (see the guide).") + case .checksum: return L10n.text("The download is damaged (its checksum doesn't match). Try again.") + case .download(let detail): return L10n.format("The download failed: %@", detail) } } } diff --git a/apple/Subsystem/Model/AndroidPermissions.swift b/apple/Subsystem/Model/AndroidPermissions.swift index e6e1ad4..9c0a48e 100644 --- a/apple/Subsystem/Model/AndroidPermissions.swift +++ b/apple/Subsystem/Model/AndroidPermissions.swift @@ -23,21 +23,21 @@ enum PrivacyCategory: String, CaseIterable, Identifiable, Hashable { var title: String { switch self { - case .camera: return "Camera" - case .microphone: return "Microphone" - case .location: return "Location" - case .contacts: return "Contacts" - case .calendars: return "Calendars" - case .photos: return "Photos & Videos" - case .music: return "Music & Audio" - case .files: return "Files" - case .notifications: return "Notifications" - case .phone: return "Phone" - case .callLogs: return "Call Logs" - case .messages: return "Messages" - case .nearby: return "Nearby Devices" - case .bodySensors: return "Body Sensors" - case .activity: return "Physical Activity" + case .camera: return L10n.text("Camera") + case .microphone: return L10n.text("Microphone") + case .location: return L10n.text("Location") + case .contacts: return L10n.text("Contacts") + case .calendars: return L10n.text("Calendars") + case .photos: return L10n.text("Photos & Videos") + case .music: return L10n.text("Music & Audio") + case .files: return L10n.text("Files") + case .notifications: return L10n.text("Notifications") + case .phone: return L10n.text("Phone") + case .callLogs: return L10n.text("Call Logs") + case .messages: return L10n.text("Messages") + case .nearby: return L10n.text("Nearby Devices") + case .bodySensors: return L10n.text("Body Sensors") + case .activity: return L10n.text("Physical Activity") } } @@ -64,21 +64,21 @@ enum PrivacyCategory: String, CaseIterable, Identifiable, Hashable { /// The app wants to … var detail: String { switch self { - case .camera: return "take photos and record video" - case .microphone: return "record audio" - case .location: return "know where you are" - case .contacts: return "read and change your contacts" - case .calendars: return "read and change your calendars" - case .photos: return "see photos and videos" - case .music: return "see music and other audio" - case .files: return "read and change shared files" - case .notifications: return "send notifications" - case .phone: return "make and manage calls" - case .callLogs: return "read and change the call history" - case .messages: return "send and read text messages" - case .nearby: return "find and connect to nearby devices" - case .bodySensors: return "read heart rate and other body sensors" - case .activity: return "know when you walk, run or cycle" + case .camera: return L10n.text("take photos and record video") + case .microphone: return L10n.text("record audio") + case .location: return L10n.text("know where you are") + case .contacts: return L10n.text("read and change your contacts") + case .calendars: return L10n.text("read and change your calendars") + case .photos: return L10n.text("see photos and videos") + case .music: return L10n.text("see music and other audio") + case .files: return L10n.text("read and change shared files") + case .notifications: return L10n.text("send notifications") + case .phone: return L10n.text("make and manage calls") + case .callLogs: return L10n.text("read and change the call history") + case .messages: return L10n.text("send and read text messages") + case .nearby: return L10n.text("find and connect to nearby devices") + case .bodySensors: return L10n.text("read heart rate and other body sensors") + case .activity: return L10n.text("know when you walk, run or cycle") } } @@ -211,7 +211,9 @@ final class PrivacyCenter: ObservableObject { center.changing.remove(key) if let text { center.permissions[app.package] = Self.parsePermissions(text) } if let problem { - center.failure = "Android didn't change \(category.title) for \(app.label): \(problem)" + let detail = problem == "no answer" ? L10n.text("no answer") : problem + center.failure = L10n.format("Android didn't change %1$@ for %2$@: %3$@", + category.title, app.label, detail) } } } diff --git a/apple/Subsystem/Model/AndroidSetup.swift b/apple/Subsystem/Model/AndroidSetup.swift index a6622dc..1fccf16 100644 --- a/apple/Subsystem/Model/AndroidSetup.swift +++ b/apple/Subsystem/Model/AndroidSetup.swift @@ -36,10 +36,10 @@ enum AndroidSetup { case bridgeInstall(String) var errorDescription: String? { switch self { - case .bootTimeout: return "Android didn't finish starting." - case .tradeInMode: return "Android's ADB is in trade-in mode, so this Mac can't set it up. Reset Android in Settings and try again." - case .bridgeMissing: return "bridge.apk is missing from this copy of \(AppConfig.displayName)." - case .bridgeInstall(let output): return "Couldn't install the bridge app: \(output)" + case .bootTimeout: return L10n.text("Android didn't finish starting.") + case .tradeInMode: return L10n.text("Android's ADB is in trade-in mode, so this Mac can't set it up. Reset Android in Settings and try again.") + case .bridgeMissing: return L10n.format("bridge.apk is missing from this copy of %@.", AppConfig.displayName) + case .bridgeInstall(let output): return L10n.format("Couldn't install the bridge app: %@", output) } } } diff --git a/apple/Subsystem/Model/GrubEnvironment.swift b/apple/Subsystem/Model/GrubEnvironment.swift index 43389d5..8f4bb65 100644 --- a/apple/Subsystem/Model/GrubEnvironment.swift +++ b/apple/Subsystem/Model/GrubEnvironment.swift @@ -35,7 +35,7 @@ enum GrubEnvironment { case qemuImg(String) var errorDescription: String? { switch self { - case .qemuImg(let output): return "Couldn't change Android's boot settings: \(output)" + case .qemuImg(let output): return L10n.format("Couldn't change Android's boot settings: %@", output) } } } diff --git a/apple/Subsystem/Model/LauncherGenerator.swift b/apple/Subsystem/Model/LauncherGenerator.swift index 00c1ce0..624dd48 100644 --- a/apple/Subsystem/Model/LauncherGenerator.swift +++ b/apple/Subsystem/Model/LauncherGenerator.swift @@ -24,8 +24,8 @@ enum LauncherGenerator { case signing(String) var errorDescription: String? { switch self { - case .hostMissing: return "The app window host is missing from \(AppConfig.displayName). Reinstall it." - case .signing(let output): return "Signing the launcher failed: \(output)" + case .hostMissing: return L10n.format("The app window host is missing from %@. Reinstall it.", AppConfig.displayName) + case .signing(let output): return L10n.format("Signing the launcher failed: %@", output) } } } diff --git a/apple/Subsystem/Model/PackageInstaller.swift b/apple/Subsystem/Model/PackageInstaller.swift index 433e89f..a51795e 100644 --- a/apple/Subsystem/Model/PackageInstaller.swift +++ b/apple/Subsystem/Model/PackageInstaller.swift @@ -15,26 +15,28 @@ enum PackageInstaller { case android(String) var errorDescription: String? { switch self { - case .unsupported(let ext): return "\(ext.isEmpty ? "This file" : ".\(ext) files") can't be installed. Use .apk, .apks, .apkm or .xapk." - case .noAPKs: return "There are no APK files in this archive." + case .unsupported(let ext): + let name = ext.isEmpty ? L10n.text("This file") : L10n.format(".%@ files", ext) + return L10n.format("%@ can't be installed. Use .apk, .apks, .apkm or .xapk.", name) + case .noAPKs: return L10n.text("There are no APK files in this archive.") case .android(let output): return Self.explain(output) } } private static func explain(_ output: String) -> String { if output.contains("INSTALL_FAILED_NO_MATCHING_ABIS") { - return "This app is built only for Intel/x86 Android devices and can't run on an Apple silicon Mac." + return L10n.text("This app is built only for Intel/x86 Android devices and can't run on an Apple silicon Mac.") } if output.contains("INSTALL_FAILED_OLDER_SDK") { - return "This app needs a newer version of Android." + return L10n.text("This app needs a newer version of Android.") } if output.contains("INSTALL_FAILED_UPDATE_INCOMPATIBLE") { - return "A different build of this app is already installed. Uninstall it first." + return L10n.text("A different build of this app is already installed. Uninstall it first.") } if output.contains("INSTALL_FAILED_INSUFFICIENT_STORAGE") { - return "Android is out of storage space." + return L10n.text("Android is out of storage space.") } - return "Android couldn't install the app:\n\(output)" + return L10n.format("Android couldn't install the app:\n%@", output) } } diff --git a/apple/Subsystem/Model/StorageJanitor.swift b/apple/Subsystem/Model/StorageJanitor.swift index 986320e..f095ab0 100644 --- a/apple/Subsystem/Model/StorageJanitor.swift +++ b/apple/Subsystem/Model/StorageJanitor.swift @@ -122,7 +122,9 @@ final class StorageJanitor: ObservableObject { if total > 0 || manual { let amount = ByteCountFormatter.string(fromByteCount: max(total, 0), countStyle: .file) let date = Date().formatted(date: .abbreviated, time: .shortened) - janitor.lastReport = total > 0 ? "Freed \(amount) on \(date)." : "Nothing to clean up on \(date)." + janitor.lastReport = total > 0 + ? L10n.format("Freed %@ on %@.", amount, date) + : L10n.format("Nothing to clean up on %@.", date) UserDefaults.standard.set(janitor.lastReport, forKey: "lastCleanupReport") } janitor.refreshUsage() diff --git a/apple/Subsystem/Model/Subsystem.swift b/apple/Subsystem/Model/Subsystem.swift index c5d0fe3..851519f 100644 --- a/apple/Subsystem/Model/Subsystem.swift +++ b/apple/Subsystem/Model/Subsystem.swift @@ -26,12 +26,12 @@ final class Subsystem: ObservableObject { var title: String { switch self { - case .notInstalled: return "Not set up" - case .off: return "Off" - case .starting: return "Starting" - case .running: return "Running" - case .stopping: return "Turning off" - case .failed: return "Stopped with an error" + case .notInstalled: return L10n.text("Not set up") + case .off: return L10n.text("Off") + case .starting: return L10n.text("Starting") + case .running: return L10n.text("Running") + case .stopping: return L10n.text("Turning off") + case .failed: return L10n.text("Stopped with an error") } } @@ -97,10 +97,10 @@ final class Subsystem: ObservableObject { } let now = LaunchSettings(settings) var changes: [String] = [] - if now.memoryMB != launched.memoryMB { changes.append("memory") } - if now.cpuCount != launched.cpuCount { changes.append("processor cores") } - if now.microphone != launched.microphone { changes.append("microphone") } - if now.showAndroidScreen != launched.showAndroidScreen { changes.append("Android screen window") } + if now.memoryMB != launched.memoryMB { changes.append(L10n.text("memory")) } + if now.cpuCount != launched.cpuCount { changes.append(L10n.text("processor cores")) } + if now.microphone != launched.microphone { changes.append(L10n.text("microphone")) } + if now.showAndroidScreen != launched.showAndroidScreen { changes.append(L10n.text("Android screen window")) } return changes } @@ -177,14 +177,15 @@ final class Subsystem: ObservableObject { switch state { case .off, .failed: break case .notInstalled: - notice = Notice(title: "Android isn't set up yet", message: "Download Android first in \(AppConfig.displayName) settings.") + notice = Notice(title: L10n.text("Android isn't set up yet"), + message: L10n.format("Download Android first in %@ settings.", AppConfig.displayName)) return default: return } guard let image else { return } if StorageJanitor.shared.isCompacting { // Android's disks are being compacted; start as soon as that finishes. - setState(.starting("Finishing a storage clean-up…")) + setState(.starting(L10n.text("Finishing a storage clean-up…"))) StorageJanitor.shared.whenIdle { let subsystem = Subsystem.shared guard case .starting = subsystem.state, subsystem.vm == nil else { return } @@ -195,7 +196,7 @@ final class Subsystem: ObservableObject { } stopRequested = false lastActivity = Date() - setState(.starting("Starting Android…")) + setState(.starting(L10n.text("Starting Android…"))) // Before touching the disks: a QEMU left behind still holds them. VirtualMachine.killStaleInstance() @@ -263,7 +264,7 @@ final class Subsystem: ObservableObject { // trade-in mode during this boot, and adbd follows after a restart. guard !restartedFromTradeInMode else { throw AndroidSetup.Failure.tradeInMode } restartedFromTradeInMode = true - progress("Restarting Android…") + progress(L10n.text("Restarting Android…")) AndroidSetup.restartFromTradeInMode(candidate) candidate.close() Thread.sleep(forTimeInterval: 5) @@ -277,21 +278,21 @@ final class Subsystem: ObservableObject { throw AndroidSetup.Failure.tradeInMode } catch { candidate.close() - if Date() > deadline { throw ADBError.timeout("Android didn't start") } + if Date() > deadline { throw ADBError.timeout(L10n.text("Android didn't start")) } Thread.sleep(forTimeInterval: 1) } } guard let adb = connection else { throw ADBError.closed } - progress("Starting Android…") + progress(L10n.text("Starting Android…")) try AndroidSetup.waitForBoot(adb) if firstBoot { - progress("Setting up Android for the first time…") + progress(L10n.text("Setting up Android for the first time…")) AndroidSetup.firstBoot(adb) } AndroidSetup.applyIdentity(adb) AndroidSetup.disableLockScreen(adb) AndroidSetup.allowInstallingApps(adb) - progress("Preparing apps…") + progress(L10n.text("Preparing apps…")) try AndroidSetup.ensureBridge(adb) try AndroidSetup.ensureScrcpyServer(adb) return (adb, AndroidSetup.versionDescription(adb)) @@ -350,7 +351,7 @@ final class Subsystem: ObservableObject { self.setState(.off) self.start() if case .starting = self.state { - self.setState(.starting("In the Android window, tick “Always allow from this computer” and click Allow.")) + self.setState(.starting(L10n.text("In the Android window, tick “Always allow from this computer” and click Allow."))) } } return @@ -428,7 +429,8 @@ final class Subsystem: ObservableObject { publishStatus() } else { let reason = Self.lastQEMUError().map { "\n\($0)" } ?? "" - setState(.failed("Android stopped unexpectedly (QEMU exit code \(code)).\(reason)\nThe full log is in Settings › Advanced › Show Log.")) + setState(.failed(L10n.format("Android stopped unexpectedly (QEMU exit code %@).%@\nThe full log is in Settings › Advanced › Show Log.", + String(code), reason))) } stopRequested = false StorageJanitor.shared.androidStopped() @@ -518,33 +520,38 @@ final class Subsystem: ObservableObject { func install(_ urls: [URL]) { let packages = urls.filter(PackageInstaller.canInstall) guard !packages.isEmpty else { - notice = Notice(title: "Can't install this file", message: "Choose an .apk, .apks, .apkm or .xapk file.") + notice = Notice(title: L10n.text("Can't install this file"), + message: L10n.text("Choose an .apk, .apks, .apkm or .xapk file.")) return } guard case .running = state, let adb else { pendingInstalls += packages - busy = Busy(message: "Starting Android to install \(packages.count == 1 ? packages[0].lastPathComponent : "\(packages.count) apps")…") + let what = packages.count == 1 + ? packages[0].lastPathComponent + : L10n.format("%@ apps", String(packages.count)) + busy = Busy(message: L10n.format("Starting Android to install %@…", what)) if state == .notInstalled { busy = nil pendingInstalls = [] - notice = Notice(title: "Android isn't set up yet", message: "Finish setting up \(AppConfig.displayName), then install the app again.") + notice = Notice(title: L10n.text("Android isn't set up yet"), + message: L10n.format("Finish setting up %@, then install the app again.", AppConfig.displayName)) } else { start() } return } let before = Set(apps.map(\.package)) - busy = Busy(message: "Installing \(packages[0].lastPathComponent)…", progress: 0) + busy = Busy(message: L10n.format("Installing %@…", packages[0].lastPathComponent), progress: 0) work.async { var failures: [String] = [] for (index, url) in packages.enumerated() { Task { @MainActor in - Subsystem.shared.busy = Busy(message: "Installing \(url.lastPathComponent)…", progress: 0) + Subsystem.shared.busy = Busy(message: L10n.format("Installing %@…", url.lastPathComponent), progress: 0) } do { try PackageInstaller.install(url, adb: adb) { fraction in Task { @MainActor in - Subsystem.shared.busy = Busy(message: "Installing \(url.lastPathComponent)…", + Subsystem.shared.busy = Busy(message: L10n.format("Installing %@…", url.lastPathComponent), progress: (Double(index) + fraction) / Double(packages.count)) } } @@ -560,7 +567,7 @@ final class Subsystem: ObservableObject { if let catalog { subsystem.apps = catalog.apps } let added = (catalog?.apps ?? []).filter { !before.contains($0.package) } if !failures.isEmpty { - subsystem.notice = Notice(title: "Some apps weren't installed", message: failures.joined(separator: "\n\n")) + subsystem.notice = Notice(title: L10n.text("Some apps weren't installed"), message: failures.joined(separator: "\n\n")) } for app in added { subsystem.announceInstalled(app) } // Open the app straight away when exactly one was installed, like double-clicking an installer. @@ -571,18 +578,18 @@ final class Subsystem: ObservableObject { private func announceInstalled(_ app: AndroidApp) { let content = UNMutableNotificationContent() - content.title = "\(app.label) installed" - content.body = "Find it in Launchpad, Spotlight and Applications › \(AppConfig.launcherFolderName)." + content.title = L10n.format("%@ installed", app.label) + content.body = L10n.format("Find it in Launchpad, Spotlight and Applications › %@.", AppConfig.launcherFolderName) content.userInfo = ["package": app.package] UNUserNotificationCenter.current().add(UNNotificationRequest(identifier: "installed-\(app.package)", content: content, trigger: nil)) } func uninstall(_ app: AndroidApp) { guard let adb else { - notice = Notice(title: "Android is off", message: "Start Android to uninstall apps.") + notice = Notice(title: L10n.text("Android is off"), message: L10n.text("Start Android to uninstall apps.")) return } - busy = Busy(message: "Removing \(app.label)…") + busy = Busy(message: L10n.format("Removing %@…", app.label)) work.async { let result = Result { try PackageInstaller.uninstall(app.package, adb: adb) } let catalog = try? AppCatalog.sync(adb) @@ -591,7 +598,7 @@ final class Subsystem: ObservableObject { subsystem.busy = nil if let catalog { subsystem.apps = catalog.apps } if case .failure(let error) = result { - subsystem.notice = Notice(title: "Couldn't remove \(app.label)", message: error.localizedDescription) + subsystem.notice = Notice(title: L10n.format("Couldn't remove %@", app.label), message: error.localizedDescription) } } } @@ -607,18 +614,18 @@ final class Subsystem: ObservableObject { /// F-Droid, the open-source app store, offered during setup and in Settings › Apps. func installFDroid() { - busy = Busy(message: "Downloading F-Droid…", progress: 0) + busy = Busy(message: L10n.text("Downloading F-Droid…"), progress: 0) Task { do { let target = SubsystemPaths.downloads.appendingPathComponent("F-Droid.apk") let file = try await Downloader.download(URL(string: "https://f-droid.org/F-Droid.apk")!, to: target) { fraction, _ in - Task { @MainActor in Subsystem.shared.busy = Busy(message: "Downloading F-Droid…", progress: fraction) } + Task { @MainActor in Subsystem.shared.busy = Busy(message: L10n.text("Downloading F-Droid…"), progress: fraction) } } busy = nil install([file]) } catch { busy = nil - notice = Notice(title: "Couldn't download F-Droid", message: error.localizedDescription) + notice = Notice(title: L10n.text("Couldn't download F-Droid"), message: error.localizedDescription) } } } @@ -626,10 +633,10 @@ final class Subsystem: ObservableObject { /// Copy files into Android's Download folder. func sendFiles(_ urls: [URL]) { guard let adb else { - notice = Notice(title: "Android is off", message: "Start Android to send files to it.") + notice = Notice(title: L10n.text("Android is off"), message: L10n.text("Start Android to send files to it.")) return } - busy = Busy(message: "Sending files to Android…", progress: 0) + busy = Busy(message: L10n.text("Sending files to Android…"), progress: 0) work.async { var errors: [String] = [] for (index, url) in urls.enumerated() { @@ -652,8 +659,9 @@ final class Subsystem: ObservableObject { let subsystem = Subsystem.shared subsystem.busy = nil subsystem.notice = errors.isEmpty - ? Notice(title: "Files sent", message: "They're in Android's Download folder (open Files).") - : Notice(title: "Some files weren't sent", message: errors.joined(separator: "\n")) + ? Notice(title: L10n.text("Files sent"), + message: L10n.text("They're in Android's Download folder (open Files).")) + : Notice(title: L10n.text("Some files weren't sent"), message: errors.joined(separator: "\n")) } } } @@ -661,7 +669,7 @@ final class Subsystem: ObservableObject { // MARK: Android image func downloadImage() { - busy = Busy(message: "Finding the latest Android…") + busy = Busy(message: L10n.text("Finding the latest Android…")) Task { do { let release = try await AndroidImage.latestRelease() @@ -669,12 +677,14 @@ final class Subsystem: ObservableObject { let total = release.size let file = try await Downloader.download(release.url, to: target) { fraction, written in let message = total > 0 - ? "Downloading Android… \(ByteCountFormatter.string(fromByteCount: written, countStyle: .file)) of \(ByteCountFormatter.string(fromByteCount: total, countStyle: .file))" - : "Downloading Android…" + ? L10n.format("Downloading Android… %@ of %@", + ByteCountFormatter.string(fromByteCount: written, countStyle: .file), + ByteCountFormatter.string(fromByteCount: total, countStyle: .file)) + : L10n.text("Downloading Android…") Task { @MainActor in Subsystem.shared.busy = Busy(message: message, progress: fraction) } } if let expected = release.sha256 { - busy = Busy(message: "Checking the download…") + busy = Busy(message: L10n.text("Checking the download…")) let actual = try await Task.detached { try AndroidImage.sha256(of: file) }.value guard actual == expected else { try? FileManager.default.removeItem(at: file) @@ -684,7 +694,7 @@ final class Subsystem: ObservableObject { installImage(from: file, deleteAfterwards: true) } catch { busy = nil - notice = Notice(title: "Couldn't download Android", message: error.localizedDescription) + notice = Notice(title: L10n.text("Couldn't download Android"), message: error.localizedDescription) } } } @@ -692,7 +702,7 @@ final class Subsystem: ObservableObject { /// Install an image the person picked (UTM-VM-lineage zip or .utm folder). func installImage(from url: URL, deleteAfterwards: Bool = false) { if state.isActive { stop() } - busy = Busy(message: "Unpacking Android…", progress: 0) + busy = Busy(message: L10n.text("Unpacking Android…"), progress: 0) Task { while self.state.isActive { try? await Task.sleep(for: .milliseconds(300)) } let result = await Task.detached(priority: .userInitiated) { @@ -700,7 +710,7 @@ final class Subsystem: ObservableObject { defer { if scoped { url.stopAccessingSecurityScopedResource() } } return Result { try AndroidImage.install(from: url) { fraction in - Task { @MainActor in Subsystem.shared.busy = Busy(message: "Unpacking Android…", progress: fraction) } + Task { @MainActor in Subsystem.shared.busy = Busy(message: L10n.text("Unpacking Android…"), progress: fraction) } } } }.value @@ -716,7 +726,7 @@ final class Subsystem: ObservableObject { setState(.off) start() case .failure(let error): - notice = Notice(title: "Couldn't install Android", message: error.localizedDescription) + notice = Notice(title: L10n.text("Couldn't install Android"), message: error.localizedDescription) } } } @@ -732,7 +742,8 @@ final class Subsystem: ObservableObject { AppStore.save([]) try? FileManager.default.removeItem(at: SubsystemPaths.icons) apps = [] - notice = Notice(title: "Android was reset", message: "All Android apps and their data were removed.") + notice = Notice(title: L10n.text("Android was reset"), + message: L10n.text("All Android apps and their data were removed.")) if wasActive || settings.resources == .continuous { start() } } } diff --git a/apple/Subsystem/Model/SubsystemSettings.swift b/apple/Subsystem/Model/SubsystemSettings.swift index 906b15e..b64fe48 100644 --- a/apple/Subsystem/Model/SubsystemSettings.swift +++ b/apple/Subsystem/Model/SubsystemSettings.swift @@ -25,16 +25,16 @@ final class SubsystemSettings: ObservableObject { var id: String { rawValue } var title: String { switch self { - case .automatic: return "Automatic" - case .asNeeded: return "As needed" - case .continuous: return "Continuous" + case .automatic: return L10n.text("Automatic") + case .asNeeded: return L10n.text("As needed") + case .continuous: return L10n.text("Continuous") } } var detail: String { switch self { - case .automatic: return "Follows the performance mode: Smart, Standard and Performance keep Android ready (Smart lets it idle at the lowest level). Power Saver turns it off as soon as no app is open." - case .asNeeded: return "Android starts when you open an Android app and turns off a few minutes after you close the last one. Apps take longer to open the first time." - case .continuous: return "Android stays ready in the background, so apps open quickly. Uses more memory and battery. Power Saver still turns it off when no app is open." + case .automatic: return L10n.text("Follows the performance mode: Smart, Standard and Performance keep Android ready (Smart lets it idle at the lowest level). Power Saver turns it off as soon as no app is open.") + case .asNeeded: return L10n.text("Android starts when you open an Android app and turns off a few minutes after you close the last one. Apps take longer to open the first time.") + case .continuous: return L10n.text("Android stays ready in the background, so apps open quickly. Uses more memory and battery. Power Saver still turns it off when no app is open.") } } } diff --git a/apple/Subsystem/Model/VirtualMachine.swift b/apple/Subsystem/Model/VirtualMachine.swift index 0b445eb..865f3eb 100644 --- a/apple/Subsystem/Model/VirtualMachine.swift +++ b/apple/Subsystem/Model/VirtualMachine.swift @@ -34,10 +34,10 @@ final class VirtualMachine: @unchecked Sendable { var errorDescription: String? { switch self { - case .qemuMissing: return "QEMU is missing from this copy of \(AppConfig.displayName). Reinstall it (or, for development, run `brew install qemu`)." - case .firmwareMissing: return "The UEFI firmware (edk2-aarch64-code.fd) is missing." - case .portInUse(let port): return "Port \(port) on this Mac is already in use, so Android's ADB can't be reached. Quit the program using it (often another Android emulator) and try again." - case .launch(let detail): return "Android couldn't start: \(detail)" + case .qemuMissing: return L10n.format("QEMU is missing from this copy of %@. Reinstall it (or, for development, run `brew install qemu`).", AppConfig.displayName) + case .firmwareMissing: return L10n.text("The UEFI firmware (edk2-aarch64-code.fd) is missing.") + case .portInUse(let port): return L10n.format("Port %@ on this Mac is already in use, so Android's ADB can't be reached. Quit the program using it (often another Android emulator) and try again.", String(port)) + case .launch(let detail): return L10n.format("Android couldn't start: %@", detail) } } } diff --git a/apple/Subsystem/SubsystemApp.swift b/apple/Subsystem/SubsystemApp.swift index b2bc859..2791c2f 100644 --- a/apple/Subsystem/SubsystemApp.swift +++ b/apple/Subsystem/SubsystemApp.swift @@ -135,10 +135,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private func confirmImageInstall(_ url: URL) { let alert = NSAlert() - alert.messageText = "Replace Android with \(url.lastPathComponent)?" - alert.informativeText = "All Android apps and their data will be erased." - alert.addButton(withTitle: "Replace") - alert.addButton(withTitle: "Cancel") + alert.messageText = L10n.format("Replace Android with %@?", url.lastPathComponent) + alert.informativeText = L10n.text("All Android apps and their data will be erased.") + alert.addButton(withTitle: L10n.text("Replace")) + alert.addButton(withTitle: L10n.text("Cancel")) alert.alertStyle = .warning NSApp.activate() if alert.runModal() == .alertFirstButtonReturn { @@ -229,8 +229,8 @@ enum FilePicker { @MainActor static func pickPackages() -> [URL] { let panel = NSOpenPanel() - panel.title = "Install Android Apps" - panel.prompt = "Install" + panel.title = L10n.text("Install Android Apps") + panel.prompt = L10n.text("Install") panel.allowsMultipleSelection = true panel.allowedContentTypes = packageTypes NSApp.activate() @@ -240,9 +240,9 @@ enum FilePicker { @MainActor static func pickImage() -> URL? { let panel = NSOpenPanel() - panel.title = "Choose an Android Image" - panel.message = "Choose a UTM-VM-lineage-…-virtio_arm64only.zip file or a .utm folder." - panel.prompt = "Use Image" + panel.title = L10n.text("Choose an Android Image") + panel.message = L10n.text("Choose a UTM-VM-lineage-…-virtio_arm64only.zip file or a .utm folder.") + panel.prompt = L10n.text("Use Image") panel.canChooseDirectories = true panel.allowedContentTypes = [.zip, UTType(filenameExtension: "utm") ?? .folder, .folder] NSApp.activate() @@ -252,8 +252,8 @@ enum FilePicker { @MainActor static func pickFiles() -> [URL] { let panel = NSOpenPanel() - panel.title = "Send Files to Android" - panel.prompt = "Send" + panel.title = L10n.text("Send Files to Android") + panel.prompt = L10n.text("Send") panel.allowsMultipleSelection = true NSApp.activate() return panel.runModal() == .OK ? panel.urls : [] diff --git a/apple/Subsystem/Views/MenuBarView.swift b/apple/Subsystem/Views/MenuBarView.swift index 214656d..b7fbbdc 100644 --- a/apple/Subsystem/Views/MenuBarView.swift +++ b/apple/Subsystem/Views/MenuBarView.swift @@ -69,17 +69,14 @@ struct MenuBarView: View { Divider() Button("Settings…") { SettingsWindowController.shared.show() } .keyboardShortcut(",") - Button("Quit \(AppConfig.displayName)") { NSApp.terminate(nil) } + Button(L10n.format("Quit %@", AppConfig.displayName)) { NSApp.terminate(nil) } .keyboardShortcut("q") } private var statusLine: String { - var line = "Android: \(subsystem.state.title)" + var line = L10n.format("Android: %@", subsystem.state.title) if case .running = subsystem.state { - line += " · \(settings.performanceMode.title)" - if settings.performanceMode == .smart, let level = subsystem.performanceLevel { - line += " (\(level.title.lowercased()))" - } + line += L10n.format(" · %@", settings.performanceMode.title) } return line } diff --git a/apple/Subsystem/Views/PrivacySettingsView.swift b/apple/Subsystem/Views/PrivacySettingsView.swift index 33e0325..0e075ee 100644 --- a/apple/Subsystem/Views/PrivacySettingsView.swift +++ b/apple/Subsystem/Views/PrivacySettingsView.swift @@ -65,20 +65,22 @@ struct PrivacyCategoryView: View { Section { Toggle("Let Android use this Mac's microphone", isOn: $settings.microphone) } footer: { - Text(subsystem.state == .running - ? "Android has no microphone when this is off, whatever apps are allowed. A change takes effect the next time Android starts." - : "Android has no microphone when this is off, whatever apps are allowed.") + Text(L10n.text(subsystem.state == .running + ? "Android has no microphone when this is off, whatever apps are allowed. A change takes effect the next time Android starts." + : "Android has no microphone when this is off, whatever apps are allowed.")) } } if let hardware { Section { - Label(hardware, systemImage: "info.circle").foregroundStyle(.secondary) + Label(L10n.text(hardware), systemImage: "info.circle").foregroundStyle(.secondary) } } Section { let apps = privacy.apps(in: category, from: subsystem.apps) if apps.isEmpty { - Text(privacy.loading ? "Checking apps…" : "No apps have asked to \(category.detail).") + Text(privacy.loading + ? L10n.text("Checking apps…") + : L10n.format("No apps have asked to %@.", category.detail)) .foregroundStyle(.secondary) } else { ForEach(apps) { app in @@ -86,7 +88,7 @@ struct PrivacyCategoryView: View { } } } header: { - Text("Apps that asked to \(category.detail)") + Text(L10n.format("Apps that asked to %@", category.detail)) } footer: { if category == .location { Text("Turning access on allows it while the app is in use. Turning it off also removes access in the background.") @@ -130,7 +132,9 @@ struct AppPrivacySheet: View { Form { let categories = privacy.categories(for: app) if categories.isEmpty { - Text(privacy.loading ? "Checking…" : "\(app.label) hasn't asked for access to any private data.") + Text(privacy.loading + ? L10n.text("Checking…") + : L10n.format("%@ hasn't asked for access to any private data.", app.label)) .foregroundStyle(.secondary) } else { ForEach(categories) { category in @@ -173,11 +177,11 @@ struct PrivacyToggleRow: View { } if access?.locked == true { Image(systemName: "lock.fill").foregroundStyle(.secondary) - .help("Android manages this permission for \(app.label).") + .help(L10n.format("Android manages this permission for %@.", app.label)) } Toggle(isOn: Binding(get: { access?.allowed ?? false }, set: { privacy.set($0, for: app, in: category) })) { - Text("\(category.title) for \(app.label)") + Text(L10n.format("%@ for %@", category.title, app.label)) } .labelsHidden() .toggleStyle(.switch) diff --git a/apple/Subsystem/Views/SettingsChrome.swift b/apple/Subsystem/Views/SettingsChrome.swift index 35cb10c..3be8283 100644 --- a/apple/Subsystem/Views/SettingsChrome.swift +++ b/apple/Subsystem/Views/SettingsChrome.swift @@ -5,6 +5,7 @@ // // Licensed under the GNU General Public License v3 or later. +import Foundation import SwiftUI // MARK: - Sections @@ -46,28 +47,36 @@ extension SettingsSection { var subtitle: String { switch self { - case .system: return "Start Android, keep it ready in the background, and choose what happens when the last app closes." - case .performance: return "How much of your Mac Android may use, and game controllers." - case .apps: return "Your Android apps, installing apps and app stores." - case .privacy: return "Which Android apps may use the camera, microphone, location and more." - case .files: return "Share files between your Mac and Android." - case .storage: return "Space Android uses on your Mac, and automatic clean-up." - case .advanced: return "Developer mode, ADB, the Android image, logs and reset." - case .about: return "Version, licences and acknowledgements." + case .system: return L10n.text("Start Android, keep it ready in the background, and choose what happens when the last app closes.") + case .performance: return L10n.text("How much of your Mac Android may use, and game controllers.") + case .apps: return L10n.text("Your Android apps, installing apps and app stores.") + case .privacy: return L10n.text("Which Android apps may use the camera, microphone, location and more.") + case .files: return L10n.text("Share files between your Mac and Android.") + case .storage: return L10n.text("Space Android uses on your Mac, and automatic clean-up.") + case .advanced: return L10n.text("Developer mode, ADB, the Android image, logs and reset.") + case .about: return L10n.text("Version, licences and acknowledgements.") } } /// Extra words the sidebar search matches. var keywords: [String] { switch self { - case .system: return ["start", "stop", "always ready", "login", "resources", "notifications", "microphone", "status"] - case .performance: return ["mode", "power saver", "smart", "standard", "gaming", "battery", "cpu", "cores", "memory", "ram", "controller", "gamepad"] - case .apps: return ["install", "apk", "f-droid", "launcher", "uninstall", "keyboard", "density"] - case .privacy: return ["permissions", "camera", "microphone", "location", "contacts"] - case .files: return ["share", "transfer", "downloads", "folder"] - case .storage: return ["disk", "space", "clean", "cache", "compact"] - case .advanced: return ["developer", "adb", "image", "log", "reset", "screen", "debug"] - case .about: return ["version", "license", "website", "github"] + case .system: return ["start", "stop", "always ready", "login", "resources", "notifications", "microphone", "status", + "启动", "停止", "后台", "登录", "资源", "通知", "麦克风", "状态"] + case .performance: return ["mode", "power saver", "smart", "standard", "gaming", "battery", "cpu", "cores", "memory", "ram", "controller", "gamepad", + "模式", "省电", "智能", "标准", "性能", "电池", "核心", "内存", "控制器", "手柄"] + case .apps: return ["install", "apk", "f-droid", "launcher", "uninstall", "keyboard", "density", + "安装", "启动器", "卸载", "键盘", "大小"] + case .privacy: return ["permissions", "camera", "microphone", "location", "contacts", + "权限", "摄像头", "相机", "麦克风", "位置", "位置信息", "定位", "通讯录", "联系人"] + case .files: return ["share", "transfer", "downloads", "folder", + "共享", "传输", "下载", "文件夹"] + case .storage: return ["disk", "space", "clean", "cache", "compact", + "磁盘", "空间", "储存", "存储", "清理", "缓存", "压缩"] + case .advanced: return ["developer", "adb", "image", "log", "reset", "screen", "debug", + "开发者", "镜像", "日志", "重置", "屏幕", "调试"] + case .about: return ["version", "license", "website", "github", + "版本", "许可", "网站"] } } @@ -209,15 +218,12 @@ struct DeviceCard: View { private var status: String { switch subsystem.state { case .running: - if let level = subsystem.performanceLevel, settings.performanceMode == .smart { - return "Running · \(level.title)" - } - return "Running · \(settings.performanceMode.title)" - case .starting: return "Starting…" - case .stopping: return "Turning off…" - case .failed: return "Stopped with an error" - case .off: return "Off" - case .notInstalled: return "Not set up" + return L10n.format("Running · %@", settings.performanceMode.title) + case .starting: return L10n.text("Starting…") + case .stopping: return L10n.text("Turning off…") + case .failed: return L10n.text("Stopped with an error") + case .off: return L10n.text("Off") + case .notInstalled: return L10n.text("Not set up") } } @@ -264,7 +270,7 @@ struct RestartBanner: View { VStack(alignment: .leading, spacing: 2) { Text("Restart Android to apply your changes") .font(.headline) - Text("Changes to \(Self.list(changes)) take effect when Android restarts. Open Android apps close while it restarts.") + Text(L10n.format("Changes to %@ take effect when Android restarts. Open Android apps close while it restarts.", Self.list(changes))) .font(.callout) .foregroundStyle(.secondary) .fixedSize(horizontal: false, vertical: true) @@ -285,10 +291,7 @@ struct RestartBanner: View { } static func list(_ items: [String]) -> String { - switch items.count { - case 0: return "" - case 1: return items[0] - default: return items.dropLast().joined(separator: ", ") + " and " + items.last! - } + guard !items.isEmpty else { return "" } + return ListFormatter.localizedString(byJoining: items) } } diff --git a/apple/Subsystem/Views/SettingsView.swift b/apple/Subsystem/Views/SettingsView.swift index eee75ba..942e4c1 100644 --- a/apple/Subsystem/Views/SettingsView.swift +++ b/apple/Subsystem/Views/SettingsView.swift @@ -12,14 +12,14 @@ enum SettingsSection: String, CaseIterable, Identifiable { var id: String { rawValue } var title: String { switch self { - case .system: return "System" - case .performance: return "Performance" - case .apps: return "Apps" - case .privacy: return "Privacy" - case .files: return "Files" - case .storage: return "Storage" - case .advanced: return "Advanced" - case .about: return "About" + case .system: return L10n.text("System") + case .performance: return L10n.text("Performance") + case .apps: return L10n.text("Apps") + case .privacy: return L10n.text("Privacy") + case .files: return L10n.text("Files") + case .storage: return L10n.text("Storage") + case .advanced: return L10n.text("Advanced") + case .about: return L10n.text("About") } } var symbol: String { @@ -106,7 +106,7 @@ struct SystemSettingsView: View { })) { VStack(alignment: .leading, spacing: 2) { Text("Always ready") - Text("Start with your Mac and keep Android running in the background, so Android apps open instantly. \(AppConfig.displayName) stays in the menu bar.") + Text(L10n.format("Start with your Mac and keep Android running in the background, so Android apps open instantly. %@ stays in the menu bar.", AppConfig.displayName)) .font(.callout) .foregroundStyle(.secondary) } @@ -131,10 +131,10 @@ struct SystemSettingsView: View { .foregroundStyle(.secondary) } if settings.resources == .asNeeded { - Stepper("Turn off after \(settings.idleMinutes) minutes without open apps", + Stepper(L10n.format("Turn off after %@ minutes without open apps", String(settings.idleMinutes)), value: $settings.idleMinutes, in: 1...60) } - Toggle("Start \(AppConfig.displayName) when you log in", isOn: $settings.startAtLogin) + Toggle(L10n.format("Start %@ when you log in", AppConfig.displayName), isOn: $settings.startAtLogin) } header: { Text("Resources") } @@ -161,7 +161,7 @@ struct StatusCard: View { .foregroundStyle(color) .frame(width: 40, height: 40) VStack(alignment: .leading, spacing: 4) { - Text("Android is \(subsystem.state.title.lowercased())") + Text(L10n.format("Android is %@", subsystem.state.title.lowercased())) .font(.headline) if let detail = subsystem.state.detail { Text(detail).foregroundStyle(.secondary).textSelection(.enabled) @@ -224,7 +224,8 @@ struct PerformanceSettingsView: View { Text("Mode") } footer: { if let level = subsystem.performanceLevel { - Text("Right now: \(level.title). App windows stream at up to \(level.maxFPS) fps; windows opened from now on use it.") + Text(L10n.format("Right now: %@. App windows stream at up to %@ fps; windows opened from now on use it.", + level.title, String(level.maxFPS))) } else { Text("The mode applies whenever Android is running.") } @@ -240,7 +241,7 @@ struct PerformanceSettingsView: View { } LabeledContent("Memory for Android") { Picker("", selection: $settings.memoryMB) { - ForEach(settings.memoryChoices, id: \.self) { Text("\($0 / 1024) GB").tag($0) } + ForEach(settings.memoryChoices, id: \.self) { Text(L10n.format("%@ GB", String($0 / 1024))).tag($0) } } .labelsHidden() .frame(width: 100) @@ -254,7 +255,7 @@ struct PerformanceSettingsView: View { Section { Toggle("Use game controllers in Android games", isOn: $settings.controllers) - LabeledContent("Connected controllers", value: controllerCount == 0 ? "None" : "\(controllerCount)") + LabeledContent("Connected controllers", value: controllerCount == 0 ? L10n.text("None") : String(controllerCount)) Text("Pair a controller in System Settings › Bluetooth (Xbox, PlayStation, Switch Pro and MFi controllers work). It appears in the Android app whose window is in front.") .font(.callout) .foregroundStyle(.secondary) @@ -327,9 +328,9 @@ struct AppsSettingsView: View { ContentUnavailableView { Label("No Android apps yet", systemImage: "square.grid.2x2") } description: { - Text(subsystem.state == .running - ? "Install an APK, or get F-Droid to browse free and open-source apps." - : "Start Android to see its apps, or install an APK (Android starts automatically).") + Text(L10n.text(subsystem.state == .running + ? "Install an APK, or get F-Droid to browse free and open-source apps." + : "Start Android to see its apps, or install an APK (Android starts automatically).")) } actions: { Button("Install APK…") { install() } Button("Get F-Droid") { subsystem.installFDroid() } @@ -353,7 +354,7 @@ struct AppsSettingsView: View { } Divider() HStack { - Text("\(subsystem.apps.count) apps") + Text(L10n.format("%@ apps", String(subsystem.apps.count))) .foregroundStyle(.secondary) Spacer() Button("Get F-Droid") { subsystem.installFDroid() } @@ -375,8 +376,8 @@ struct AppsSettingsView: View { } isTargeted: { dropTargeted = $0 } .sheet(item: $privacyApp) { AppPrivacySheet(app: $0) } .navigationTitle("Apps") - .navigationSubtitle("Each app is also in Launchpad and Applications › \(AppConfig.launcherFolderName)") - .confirmationDialog("Uninstall \(confirmRemove?.label ?? "")?", + .navigationSubtitle(L10n.format("Each app is also in Launchpad and Applications › %@", AppConfig.launcherFolderName)) + .confirmationDialog(L10n.format("Uninstall %@?", confirmRemove?.label ?? ""), isPresented: Binding(get: { confirmRemove != nil }, set: { if !$0 { confirmRemove = nil } }), presenting: confirmRemove) { app in Button("Uninstall", role: .destructive) { subsystem.uninstall(app) } @@ -492,12 +493,12 @@ struct StorageSettingsView: View { Section { UsageBar(usage: janitor.usage) .padding(.vertical, 6) - row("Android image", janitor.usage.image, .accentColor) - row("Android apps and data", janitor.usage.androidData, .green) - row("App launchers", janitor.usage.launchers, .orange) - row("Downloads, logs and other", janitor.usage.other, .secondary) + row(L10n.text("Android image"), janitor.usage.image, .accentColor) + row(L10n.text("Android apps and data"), janitor.usage.androidData, .green) + row(L10n.text("App launchers"), janitor.usage.launchers, .orange) + row(L10n.text("Downloads, logs and other"), janitor.usage.other, .secondary) } header: { - Text("Space used: \(format(janitor.usage.total))") + Text(L10n.format("Space used: %@", format(janitor.usage.total))) } Section { @@ -506,7 +507,7 @@ struct StorageSettingsView: View { .font(.callout) .foregroundStyle(.secondary) HStack { - Button(janitor.isWorking ? "Cleaning Up…" : "Clean Up Now") { janitor.cleanNow() } + Button(janitor.isWorking ? L10n.text("Cleaning Up…") : L10n.text("Clean Up Now")) { janitor.cleanNow() } .disabled(janitor.isWorking || subsystem.busy != nil) if janitor.isWorking { ProgressView().controlSize(.small) } Spacer() @@ -590,7 +591,7 @@ struct AdvancedSettingsView: View { } } } - Text("Run `adb connect \(adbAddress)` in Terminal, or use Android Studio. ADB only listens on this Mac. The first time, Android asks to allow this computer only if the image requires it.") + Text(L10n.format("Run `adb connect %@` in Terminal, or use Android Studio. ADB only listens on this Mac. The first time, Android asks to allow this computer only if the image requires it.", adbAddress)) .font(.callout) .foregroundStyle(.secondary) } @@ -622,9 +623,9 @@ struct AdvancedSettingsView: View { } Section { - LabeledContent("Image", value: subsystem.image?.displayName ?? "None") + LabeledContent("Image", value: subsystem.image?.displayName ?? L10n.text("None")) if let version = subsystem.androidVersion { - LabeledContent("Running", value: version) + LabeledContent("Running version", value: version) } HStack { Button("Download Latest Android…") { confirmUpdate = true } @@ -678,7 +679,7 @@ struct AboutView: View { .resizable() .frame(width: 96, height: 96) Text(AppConfig.displayName).font(.title.weight(.semibold)) - Text("Version \(AppConfig.version)").foregroundStyle(.secondary) + Text(L10n.format("Version %@", AppConfig.version)).foregroundStyle(.secondary) } .frame(maxWidth: .infinity) .padding(.vertical, 10) @@ -690,7 +691,7 @@ struct AboutView: View { } else if let image = subsystem.image { LabeledContent("Android image", value: image.displayName) } - LabeledContent("Mac app", value: "Version \(AppConfig.version)") + LabeledContent("Mac app", value: L10n.format("Version %@", AppConfig.version)) } Section { Link("Source code (GPLv3)", destination: AppConfig.repositoryURL) diff --git a/apple/Subsystem/Views/SetupView.swift b/apple/Subsystem/Views/SetupView.swift index 327e933..7a1728d 100644 --- a/apple/Subsystem/Views/SetupView.swift +++ b/apple/Subsystem/Views/SetupView.swift @@ -16,7 +16,7 @@ struct SetupView: View { .resizable() .frame(width: 96, height: 96) VStack(spacing: 8) { - Text("Set up \(AppConfig.displayName)") + Text(L10n.format("Set up %@", AppConfig.displayName)) .font(.largeTitle.weight(.semibold)) Text("Android apps on your Mac: every Android app in its own window, with its own icon in Launchpad and the Dock.") .font(.title3) @@ -26,9 +26,9 @@ struct SetupView: View { } VStack(alignment: .leading, spacing: 10) { - Bullet(symbol: "arrow.down.circle", text: "Downloads Android 17 (LineageOS 24, no Google apps), about 1.5 GB.") - Bullet(symbol: "bolt", text: "Android runs in a lightweight virtual machine on Apple silicon, at close to native speed.") - Bullet(symbol: "lock", text: "Everything stays on this Mac. Android only talks to the Mac through 127.0.0.1.") + Bullet(symbol: "arrow.down.circle", text: L10n.text("Downloads Android 17 (LineageOS 24, no Google apps), about 1.5 GB.")) + Bullet(symbol: "bolt", text: L10n.text("Android runs in a lightweight virtual machine on Apple silicon, at close to native speed.")) + Bullet(symbol: "lock", text: L10n.text("Everything stays on this Mac. Android only talks to the Mac through 127.0.0.1.")) } .frame(maxWidth: 520, alignment: .leading) diff --git a/apple/project.yml b/apple/project.yml index 0fe470f..665655e 100644 --- a/apple/project.yml +++ b/apple/project.yml @@ -48,6 +48,9 @@ targets: - path: Subsystem - path: Shared - path: Resources/Assets.xcassets + - path: Resources/zh-Hans.lproj + type: folder + buildPhase: resources # Liquid Glass icon (Icon Composer); actool also derives the older macOS icon from it. - path: Resources/AppIcon.icon type: file @@ -61,6 +64,8 @@ targets: properties: CFBundleDisplayName: $(APP_NAME) CFBundleName: $(APP_NAME) + CFBundleDevelopmentRegion: en + CFBundleLocalizations: [en, zh-Hans] CFBundleShortVersionString: $(MARKETING_VERSION) CFBundleVersion: $(CURRENT_PROJECT_VERSION) LSApplicationCategoryType: public.app-category.utilities From 7b7fa975b57964d29605b46f7ee7d7f294765a35 Mon Sep 17 00:00:00 2001 From: REMIXPLAYER <2957871186@QQ.com> Date: Fri, 23 Oct 2026 00:04:25 +0800 Subject: [PATCH 2/3] Clarify four English source strings for Automatic, As needed, phone, and locked permissions. English UI copy only: shorten the Automatic and As needed resource blurbs, expand the phone/cellular hardware banner so Messages is covered, and make the locked-permission help say the control cannot be changed. zh-Hans values are unchanged; keys are renamed to match. --- apple/Resources/zh-Hans.lproj/Localizable.strings | 8 ++++---- apple/Subsystem/Model/SubsystemSettings.swift | 4 ++-- apple/Subsystem/Views/PrivacySettingsView.swift | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apple/Resources/zh-Hans.lproj/Localizable.strings b/apple/Resources/zh-Hans.lproj/Localizable.strings index c2c562d..a08ca5c 100644 --- a/apple/Resources/zh-Hans.lproj/Localizable.strings +++ b/apple/Resources/zh-Hans.lproj/Localizable.strings @@ -47,8 +47,8 @@ "Automatic" = "自动"; "As needed" = "需要时"; "Continuous" = "保持运行"; -"Follows the performance mode: Smart, Standard and Performance keep Android ready (Smart lets it idle at the lowest level). Power Saver turns it off as soon as no app is open." = "智能、标准和性能保持运行,智能空闲时降到省电档。省电模式在没有 Android App 打开时关闭 Android。"; -"Android starts when you open an Android app and turns off a few minutes after you close the last one. Apps take longer to open the first time." = "打开 Android App 时启动。达到设定的分钟数后关闭。首次打开等待更长。"; +"Smart, Standard and Performance keep Android ready. Smart drops to Power Saver when idle. Power Saver turns Android off when no app is open." = "智能、标准和性能保持运行,智能空闲时降到省电档。省电模式在没有 Android App 打开时关闭 Android。"; +"Android starts when you open an Android app and turns off after the minutes you set. The first open takes longer." = "打开 Android App 时启动。达到设定的分钟数后关闭。首次打开等待更长。"; "Android stays ready in the background, so apps open quickly. Uses more memory and battery. Power Saver still turns it off when no app is open." = "Android 在后台保持运行,应用可以迅速打开,但会占用更多内存和电量。没有应用打开时,省电模式仍会关闭 Android。"; "Power Saver is on: Android turns off 30 seconds after the last Android app closes." = "省电模式开启时:最后一个 Android 应用关闭 30 秒后,Android 也会关闭。"; "Turn off after %@ minutes without open apps" = "没有应用打开时,%@ 分钟后关闭 Android"; @@ -186,7 +186,7 @@ "Android has no microphone when this is off, whatever apps are allowed." = "关闭后,Android 将没有麦克风。即使应用已获得允许,也无法使用。"; "Android doesn't have a camera on this Mac yet, so apps can't take photos even when allowed." = "本机尚未向 Android 系统提供摄像头。即使允许,应用也无法拍照或录像。"; "Android has no location source on this Mac, so apps can't find where you are even when allowed." = "Android 系统在本机上没有位置来源。即使允许,也无法获得位置,也不会使用“系统设置”中的“定位服务”。"; -"Android has no phone service on this Mac." = "本机上的 Android 系统没有蜂窝网络,无法拨打电话,也没有通话记录和短信。"; +"Android on this Mac has no cellular service, so it can't make calls and has no call log or text messages." = "本机上的 Android 系统没有蜂窝网络,无法拨打电话,也没有通话记录和短信。"; "Android has no body or motion sensors on this Mac." = "本机没有向 Android 系统提供心率或运动数据。即使允许,应用也无法读取。"; "Checking apps…" = "正在查看应用…"; "No apps have asked to %@." = "还没有应用申请%@。"; @@ -194,7 +194,7 @@ "Turning access on allows it while the app is in use. Turning it off also removes access in the background." = "打开后,应用仅能在使用时获取位置。关闭后,后台的位置权限也会一并关闭。"; "Checking…" = "正在查看…"; "%@ hasn't asked for access to any private data." = "%@ 还没有申请任何权限。"; -"Android manages this permission for %@." = "%@ 的这项权限由 Android 系统锁定,无法在此更改。"; +"Android locks this permission for %@, so it can't be changed here." = "%@ 的这项权限由 Android 系统锁定,无法在此更改。"; "%@ for %@" = "%2$@ 的%1$@"; "Couldn't change access" = "未能更改这项权限"; "Camera" = "摄像头"; diff --git a/apple/Subsystem/Model/SubsystemSettings.swift b/apple/Subsystem/Model/SubsystemSettings.swift index b64fe48..88fa4ef 100644 --- a/apple/Subsystem/Model/SubsystemSettings.swift +++ b/apple/Subsystem/Model/SubsystemSettings.swift @@ -32,8 +32,8 @@ final class SubsystemSettings: ObservableObject { } var detail: String { switch self { - case .automatic: return L10n.text("Follows the performance mode: Smart, Standard and Performance keep Android ready (Smart lets it idle at the lowest level). Power Saver turns it off as soon as no app is open.") - case .asNeeded: return L10n.text("Android starts when you open an Android app and turns off a few minutes after you close the last one. Apps take longer to open the first time.") + case .automatic: return L10n.text("Smart, Standard and Performance keep Android ready. Smart drops to Power Saver when idle. Power Saver turns Android off when no app is open.") + case .asNeeded: return L10n.text("Android starts when you open an Android app and turns off after the minutes you set. The first open takes longer.") case .continuous: return L10n.text("Android stays ready in the background, so apps open quickly. Uses more memory and battery. Power Saver still turns it off when no app is open.") } } diff --git a/apple/Subsystem/Views/PrivacySettingsView.swift b/apple/Subsystem/Views/PrivacySettingsView.swift index 0e075ee..a6bb224 100644 --- a/apple/Subsystem/Views/PrivacySettingsView.swift +++ b/apple/Subsystem/Views/PrivacySettingsView.swift @@ -104,7 +104,7 @@ struct PrivacyCategoryView: View { switch category { case .camera: return "Android doesn't have a camera on this Mac yet, so apps can't take photos even when allowed." case .location: return "Android has no location source on this Mac, so apps can't find where you are even when allowed." - case .phone, .callLogs, .messages: return "Android has no phone service on this Mac." + case .phone, .callLogs, .messages: return "Android on this Mac has no cellular service, so it can't make calls and has no call log or text messages." case .bodySensors, .activity: return "Android has no body or motion sensors on this Mac." default: return nil } @@ -177,7 +177,7 @@ struct PrivacyToggleRow: View { } if access?.locked == true { Image(systemName: "lock.fill").foregroundStyle(.secondary) - .help(L10n.format("Android manages this permission for %@.", app.label)) + .help(L10n.format("Android locks this permission for %@, so it can't be changed here.", app.label)) } Toggle(isOn: Binding(get: { access?.allowed ?? false }, set: { privacy.set($0, for: app, in: category) })) { From 64fcc7baf42f9f95d958787e7f1035eb4e238d12 Mon Sep 17 00:00:00 2001 From: REMIXPLAYER <2957871186@QQ.com> Date: Fri, 23 Oct 2026 11:13:27 +0800 Subject: [PATCH 3/3] Lowercase the localized Android state with the user's locale. --- apple/Subsystem/Views/SettingsView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/Subsystem/Views/SettingsView.swift b/apple/Subsystem/Views/SettingsView.swift index 942e4c1..478c196 100644 --- a/apple/Subsystem/Views/SettingsView.swift +++ b/apple/Subsystem/Views/SettingsView.swift @@ -161,7 +161,7 @@ struct StatusCard: View { .foregroundStyle(color) .frame(width: 40, height: 40) VStack(alignment: .leading, spacing: 4) { - Text(L10n.format("Android is %@", subsystem.state.title.lowercased())) + Text(L10n.format("Android is %@", subsystem.state.title.localizedLowercase)) .font(.headline) if let detail = subsystem.state.detail { Text(detail).foregroundStyle(.secondary).textSelection(.enabled)