Files
GC/GC-UI/frontend/lib/i18n.dart
Morris 38781c9807 refactor(ui): 删除百宝箱页;设置页去掉主题色
- 删除 pages/treasure.dart 与侧栏「百宝箱」入口,用户页从 index 6 前移到 5
- 清理 pages.dart 导出与 i18n 里的 nav.treasure / treasure.* 键
- 设置页移除主题色色板、自定义颜色入口与 _applyAccent 等实现
- 强调色改由用户账号的 theme_color 决定:
  · controller._applySettings 不再应用 settings.accentColor
  · 启动后 _applyUserTheme() 拉一次 /api/user/me 并按 theme_color 上色
  · 退出登录回落到 GcPalette.defaultAccent
- 清理 i18n 中的 set.accent.* 键与 settings.dart 无用的 dart:async 导入
2026-11-21 20:45:25 +08:00

431 lines
20 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/widgets.dart';
/// 轻量 i18n:键值表 + 运行时切换,和后端 `GC/src/Assets/i18n/*.json` 的键保持一致。
class I18n {
I18n._();
static const List<String> supported = <String>['zh-CN', 'en'];
static final ValueNotifier<String> language = ValueNotifier<String>('zh-CN');
static const Map<String, Map<String, String>> _tables = <String, Map<String, String>>{
'zh-CN': <String, String>{
'app.name': 'Morris GC',
'app.tagline': '天文教学模型 · 可视化启动器',
'nav.home': '主页',
'nav.courseware': '等高线课件',
'nav.download': '下载',
'nav.settings': '设置',
'nav.about': '关于',
'nav.user': '用户',
'home.title': '模型库',
'home.subtitle': '选择模型,用可交互的三维演示讲清自转、公转与四季成因。',
'home.launch': '启动模型',
'home.download': '下载模型',
'home.settings': '设置',
'home.installed': '已安装模型',
'home.count': '{0} 个模型',
'home.noDescription': '暂无简介',
'home.empty': '模型库还是空的',
'home.emptyHint': '启动时会自动检查并下载模型。若当前断网:可把模型文件夹放进 .GC/model/ 后重新打开,或联网后在「下载」页点重试。',
'home.emptyAction': '去下载模型',
'home.open': '打开目录',
'home.delete': '删除',
'home.deleteConfirm': '删除模型「{0}」?模型文件会从本地模型库移除。',
'home.stats.models': '已安装',
'home.stats.sources': '模型源',
'home.stats.memory': '内存预算',
'home.recent': '选择模型后点击「启动模型」',
'home.noBuiltin': '「{0}」暂时没有内置渲染实现',
'model.back': '返回',
'model.missing': '这个模型还没有 Flutter 实现',
'model.missingHint': '模型窗口已全部改为应用内渲染,该模型暂未迁移。',
'home.launchHint': '模型直接在应用内运行,可播放/暂停、切换视角并使用教学要点。',
'dl.title': '下载模型',
'dl.subtitle': '从内置模型源读取可下载模型;模型源在「设置」里查看。',
'dl.sources': '模型源',
'dl.refresh': '刷新',
'dl.available': '可用模型',
'dl.download': '下载',
'dl.installed': '已安装',
'dl.reinstall': '重新下载',
'dl.background': '后台任务',
'dl.bgEmpty': '暂无后台任务',
'dl.cancel': '取消',
'dl.retry': '重试',
'dl.clearDone': '清除已完成',
'dl.removeTask': '移除',
'dl.status.queued': '排队中',
'dl.status.downloading': '下载中',
'dl.status.done': '已完成',
'dl.status.failed': '失败',
'dl.status.canceled': '已取消',
'dl.empty': '这个源里没有模型',
'dl.emptyHint': '仓库需要包含 model/<模型ID>/<模型ID>.json 结构',
'dl.syncing': '正在读取模型源…',
'dl.ready': '共 {0} 个模型',
'dl.fromCache': '本地缓存',
'dl.pickSource': '选择一个模型源,查看可下载的模型',
'set.title': '设置',
'set.subtitle': '模型源、启动时内存分配与本地存储。',
'set.general': '通用',
'set.appearance': '外观',
'set.theme': '主题模式',
'set.theme.desc': '深色、浅色,或跟随系统设置。',
'set.theme.dark': '深色',
'set.theme.light': '浅色',
'set.theme.system': '跟随系统',
'set.language': '界面语言',
'set.language.auto': '跟随系统',
'set.fps': '渲染帧率',
'set.fps.desc': '越高越顺滑,CPU 占用也越高。',
'set.memory': '启动时运行内存分配',
'set.memory.desc': '启动器把这份预算交给模型:模型自己决定用它缓存多少数据(贴图分辨率、缓冲等)。',
'set.memory.current': '当前占用',
'set.memory.auto': '自动(根据设备内存分配)',
'set.memory.hint': '建议 2048 MB 以上,低配设备可选 1024 MB。',
'set.sources': '模型源',
'set.sources.desc': '停用的模型源不会出现在下载页。',
'set.sourceEnabled': '启用',
'set.storage': '存储',
'set.modelDir': '模型库目录',
'set.dataDir': '数据目录',
'set.openFolder': '打开文件夹',
'set.clearCache': '清理缓存',
'set.cacheCleared': '缓存已清理',
'set.about': '关于',
'set.version': '版本',
'set.platform': '平台',
'set.license': '许可',
'set.licenseValue': 'MIT',
'set.checkUpdate': '检查更新',
'set.checkUpdate.desc': '启动时自动检查模型与启动器是否为最新版。',
'set.backend': '后端服务',
'set.backend.desc': '界面(Flutter)与后端(.NET)分离,后端只监听本机回环地址。',
'set.backend.ui': '模型窗口宿主',
'set.backend.uiOk': '可用',
'set.backend.uiBad': '不可用',
'update.title': '自动更新',
'update.auto': '启动时自动检查更新',
'update.checkNow': '检查更新',
'update.source': '更新源',
'update.lastCheck': '上次检查',
'update.never': '尚未检查',
'update.none': '无',
'update.checking': '正在检查更新…',
'update.offline': '暂时无法连接更新服务器,继续使用本地模型',
'update.noChange': '模型与启动器均为最新版',
'update.applied': '已更新 {0} 个模型,立即生效',
'update.done': '更新检查完成',
'update.pendingReady': '启动器新版 {0} 已就绪,下次启动生效',
'common.cancel': '取消',
'common.confirm': '确定',
'common.delete': '删除',
'common.close': '关闭',
'common.open': '打开',
'common.applied': '已应用',
'common.confirmTitle': '请确认',
'common.retry': '重试',
'common.loading': '加载中…',
'common.error': '出错了',
'common.refresh': '刷新',
'about.developers': '开发者',
'about.contributorsHint': '来自仓库提交记录',
'about.repository': '仓库',
'about.openRepository': '打开仓库',
'about.redownload': '重新下载启动器',
'about.redownloading': '正在下载并校验…',
'about.redownloadOk': '已下载 v{0},完整性校验通过(sha256 一致),重启后生效',
'about.redownloadFail': '重新下载失败',
'about.contributions': '{0} 次提交',
'about.noContributors': '暂无贡献者信息',
'about.architecture': '架构',
'about.architectureValue': 'Flutter 前端 + .NET 后端(本地 HTTP)',
'about.sourceLanguage': '源码语言',
'about.frontend': '前端',
'about.gitService': 'Git 服务',
'about.thanks': '感谢',
'about.thanksHint': '特别感谢以下朋友的支持',
'about.thanksGit': 'Git 服务与部署支持',
'about.thanksGeo': '地理学科内容指导',
'user.points': '积分',
'user.days': '连续签到',
'user.signin': '签到',
'user.login': '登录',
'user.register': '注册',
'user.pick': '二选一',
'user.themeColor': '主题颜色',
'user.username': '用户名',
'user.password': '密码',
'user.option1': '选项一',
'user.option2': '选项二',
'user.pickRandom': '随机选择',
'user.switchToRegister': '没有账号?去注册',
'user.switchToLogin': '已有账号?去登录',
'user.loginSuccess': '登录成功',
'user.registerSuccess': '注册成功',
'user.signinSuccess': '签到成功',
'user.alreadySigned': '今天已经签到过了',
'user.fillAll': '请填写用户名和密码',
'user.fillOptions': '请填写两个选项',
'user.loginFirst': '请先登录',
'user.notLoggedIn': '未登录',
'user.loginHint': '登录后可签到攒积分、解锁主题色',
'user.logout': '退出登录',
'user.logoutDone': '已退出登录',
'user.cycleDay': '第 {0} / {1} 天',
'user.signedToday': '今天已签到,明天再来',
'user.signedTodayShort': '已签到',
'user.nextReward': '现在签到可得 {0} 积分',
'user.refunded': '已退回',
'user.usernameRule': '1–20 个字符,不能有空格,不能与他人重复',
'user.captcha': '人机验证',
'user.captchaMissing': '请先获取人机验证题',
'user.captchaAnswer': '验证码答案',
'user.fillCaptcha': '请填写验证码答案',
'user.refreshCaptcha': '换一题',
'user.noRecharge': '积分只能通过每日签到获得,不提供任何充值渠道。',
'user.fortune': '人品值',
'user.fortuneDesc': '每天可以无限次计算,纯属娱乐,不影响积分。',
'user.fortuneIdle': '点一下,看看今天手气',
'user.fortuneRoll': '开始计算',
'user.fortuneAgain': '再算一次',
'user.pickDesc': '填两个选项,随机帮你选一个。',
'user.pickResult': '结果:',
'user.themeDesc': '默认蓝色免费;预置色 50 积分一个,自定义色 150 积分一个。',
'user.custom': '自定义',
'user.customColor': '自定义颜色',
'user.customColorCost': '自定义颜色需要 {0} 积分。',
'user.confirmBuy': '购买并应用',
'user.hexInvalid': '格式应为 #RRGGBB',
'user.free': '免费',
'user.themeUpdated': '主题色已更新',
'user.refundHint': '1 小时内换色可退 80%,当前可退(剩余 {0})',
'user.minutes': '分钟',
'user.seconds': '秒',
},
'en': <String, String>{
'app.name': 'Morris GC',
'app.tagline': 'Astronomy teaching models · visual launcher',
'nav.home': 'Home',
'nav.courseware': 'Contour Course',
'nav.download': 'Download',
'nav.settings': 'Settings',
'nav.about': 'About',
'nav.user': 'User',
'home.title': 'Model library',
'home.subtitle': 'Pick a model and explain rotation, revolution and the seasons with an interactive 3D scene.',
'home.launch': 'Launch model',
'home.download': 'Get models',
'home.settings': 'Settings',
'home.installed': 'Installed models',
'home.count': '{0} models',
'home.noDescription': 'No description',
'home.empty': 'No models yet',
'home.emptyHint': 'Models are checked and downloaded on startup. Offline: drop model folders into .GC/model/ and reopen, or retry from the Download page once online.',
'home.emptyAction': 'Get models',
'home.open': 'Open folder',
'home.delete': 'Delete',
'home.deleteConfirm': 'Delete the model "{0}"? Its files will be removed from the local library.',
'home.stats.models': 'Installed',
'home.stats.sources': 'Sources',
'home.stats.memory': 'Memory budget',
'home.recent': 'Select a model, then press Launch',
'home.noBuiltin': '"{0}" has no built-in renderer yet',
'model.back': 'Back',
'model.missing': 'No Flutter renderer for this model',
'model.missingHint': 'Model windows are rendered in-app now; this model has not been migrated yet.',
'home.launchHint': 'Models render inside the app with play/pause, view controls and teaching notes.',
'dl.title': 'Download',
'dl.subtitle': 'Read downloadable models from the built-in sources; manage sources in Settings.',
'dl.sources': 'Sources',
'dl.refresh': 'Refresh',
'dl.available': 'Available models',
'dl.download': 'Download',
'dl.installed': 'Installed',
'dl.reinstall': 'Re-download',
'dl.background': 'Background tasks',
'dl.bgEmpty': 'No background tasks',
'dl.cancel': 'Cancel',
'dl.retry': 'Retry',
'dl.clearDone': 'Clear finished',
'dl.removeTask': 'Remove',
'dl.status.queued': 'Queued',
'dl.status.downloading': 'Downloading',
'dl.status.done': 'Completed',
'dl.status.failed': 'Failed',
'dl.status.canceled': 'Canceled',
'dl.empty': 'No models in this source',
'dl.emptyHint': 'A source needs model/<model-id>/<model-id>.json layout',
'dl.syncing': 'Reading model source…',
'dl.ready': '{0} models',
'dl.fromCache': 'cached',
'dl.pickSource': 'Select a source to see available models',
'set.title': 'Settings',
'set.subtitle': 'Model sources, startup memory allocation and local storage.',
'set.general': 'General',
'set.appearance': 'Appearance',
'set.theme': 'Theme mode',
'set.theme.desc': 'Dark, light, or follow the system setting.',
'set.theme.dark': 'Dark',
'set.theme.light': 'Light',
'set.theme.system': 'System',
'set.language': 'Language',
'set.language.auto': 'System',
'set.fps': 'Render frame rate',
'set.fps.desc': 'Higher is smoother but uses more CPU.',
'set.memory': 'Startup memory allocation',
'set.memory.desc': 'The launcher hands this budget to each model; models decide how much data to cache with it.',
'set.memory.current': 'In use',
'set.memory.auto': 'Auto (allocate based on device memory)',
'set.memory.hint': '2048 MB or more is recommended; 1024 MB for low-end devices.',
'set.sources': 'Model sources',
'set.sources.desc': 'Disabled sources are hidden from the Download page.',
'set.sourceEnabled': 'Enabled',
'set.storage': 'Storage',
'set.modelDir': 'Model library',
'set.dataDir': 'Data folder',
'set.openFolder': 'Open folder',
'set.clearCache': 'Clear cache',
'set.cacheCleared': 'Cache cleared',
'set.about': 'About',
'set.version': 'Version',
'set.platform': 'Platform',
'set.license': 'License',
'set.licenseValue': 'MIT',
'set.checkUpdate': 'Check for updates',
'set.checkUpdate.desc': 'Check on startup whether models and the launcher are up to date.',
'set.backend': 'Backend service',
'set.backend.desc': 'The UI (Flutter) and the backend (.NET) are separate; the backend only listens on loopback.',
'set.backend.ui': 'Model window host',
'set.backend.uiOk': 'available',
'set.backend.uiBad': 'unavailable',
'update.title': 'Auto update',
'update.auto': 'Check for updates on startup',
'update.checkNow': 'Check now',
'update.source': 'Update source',
'update.lastCheck': 'Last check',
'update.never': 'Never',
'update.none': 'None',
'update.checking': 'Checking for updates…',
'update.offline': 'Update server unavailable — continuing with local models',
'update.noChange': 'Models and launcher are up to date',
'update.applied': 'Updated {0} models, applied now',
'update.done': 'Update check complete',
'update.pendingReady': 'Launcher {0} is ready, applies on next start',
'common.cancel': 'Cancel',
'common.confirm': 'Confirm',
'common.delete': 'Delete',
'common.close': 'Close',
'common.open': 'Open',
'common.applied': 'Applied',
'common.confirmTitle': 'Please confirm',
'common.retry': 'Retry',
'common.loading': 'Loading…',
'common.error': 'Something went wrong',
'common.refresh': 'Refresh',
'about.developers': 'Developers',
'about.contributorsHint': 'From repository commits',
'about.repository': 'Repository',
'about.openRepository': 'Open repository',
'about.redownload': 'Re-download launcher',
'about.redownloading': 'Downloading and verifying…',
'about.redownloadOk': 'Downloaded v{0}, integrity verified (sha256 matched); applies after restart',
'about.redownloadFail': 'Re-download failed',
'about.contributions': '{0} commits',
'about.noContributors': 'No contributor information',
'about.architecture': 'Architecture',
'about.architectureValue': 'Flutter frontend + .NET backend (local HTTP)',
'about.sourceLanguage': 'Source language',
'about.frontend': 'Frontend',
'about.gitService': 'Git hosting',
'about.thanks': 'Thanks',
'about.thanksHint': 'Special thanks to',
'about.thanksGit': 'Git hosting and deployment',
'about.thanksGeo': 'Geography content guidance',
'user.points': 'Points',
'user.days': 'Streak',
'user.signin': 'Sign In',
'user.login': 'Login',
'user.register': 'Register',
'user.pick': 'Pick One',
'user.themeColor': 'Theme Color',
'user.username': 'Username',
'user.password': 'Password',
'user.option1': 'Option A',
'user.option2': 'Option B',
'user.pickRandom': 'Random',
'user.switchToRegister': 'No account? Register',
'user.switchToLogin': 'Have account? Login',
'user.loginSuccess': 'Login successful',
'user.registerSuccess': 'Registration successful',
'user.signinSuccess': 'Signed in',
'user.alreadySigned': 'Already signed in today',
'user.fillAll': 'Please fill in username and password',
'user.fillOptions': 'Please fill in both options',
'user.loginFirst': 'Please login first',
'user.notLoggedIn': 'Not signed in',
'user.loginHint': 'Sign in to earn points and unlock theme colors',
'user.logout': 'Sign out',
'user.logoutDone': 'Signed out',
'user.cycleDay': 'Day {0} / {1}',
'user.signedToday': 'Signed in today, come back tomorrow',
'user.signedTodayShort': 'Signed',
'user.nextReward': 'Sign in now for {0} points',
'user.refunded': 'refunded',
'user.usernameRule': '1–20 chars, no spaces, must be unique',
'user.captcha': 'Verification',
'user.captchaMissing': 'Please load the verification question first',
'user.captchaAnswer': 'Answer',
'user.fillCaptcha': 'Please answer the verification question',
'user.refreshCaptcha': 'New question',
'user.noRecharge': 'Points come from daily check-ins only. There is no way to buy points.',
'user.fortune': 'Luck Meter',
'user.fortuneDesc': 'Unlimited rolls per day. Just for fun — no points involved.',
'user.fortuneIdle': 'Tap to see how lucky you are today',
'user.fortuneRoll': 'Roll',
'user.fortuneAgain': 'Roll again',
'user.pickDesc': 'Two options, one random pick.',
'user.pickResult': 'Result:',
'user.themeDesc': 'Default blue is free; preset colors cost 50, custom colors 150.',
'user.custom': 'Custom',
'user.customColor': 'Custom color',
'user.customColorCost': 'A custom color costs {0} points.',
'user.confirmBuy': 'Buy & apply',
'user.hexInvalid': 'Format must be #RRGGBB',
'user.free': 'Free',
'user.themeUpdated': 'Theme color updated',
'user.refundHint': 'Change within 1 hour for a 80% refund (left {0})',
'user.minutes': 'min',
'user.seconds': 's',
},
};
/// 取一条文案;`{0}` 这类占位符用 [args] 填充。
static String t(String key, [List<Object?> args = const <Object?>[]]) {
final table = _tables[language.value] ?? _tables['zh-CN']!;
var text = table[key] ?? _tables['zh-CN']![key] ?? key;
for (var i = 0; i < args.length; i++) {
text = text.replaceAll('{$i}', '${args[i]}');
}
return text;
}
/// 把后端语言设置(auto / zh-CN / en)解析成实际语言。
static String resolve(String? preference) {
if (preference != null && preference.isNotEmpty && preference != 'auto') {
return preference.startsWith('en') ? 'en' : 'zh-CN';
}
final locale = WidgetsBinding.instance.platformDispatcher.locale;
return locale.languageCode == 'zh' ? 'zh-CN' : 'en';
}
static void setLanguage(String code) {
final resolved = resolve(code);
if (language.value != resolved) language.value = resolved;
}
}
/// 便捷取词:`T('nav.home')`。
String T(String key, [List<Object?> args = const <Object?>[]]) => I18n.t(key, args);