159 lines
8.4 KiB
Dart
Executable File
159 lines
8.4 KiB
Dart
Executable File
import 'package:flutter/foundation.dart';
|
||
import 'package:shared_preferences/shared_preferences.dart';
|
||
|
||
class S {
|
||
static const _languagePreferenceKey = 'is_english';
|
||
static final ValueNotifier<bool> langNotifier = ValueNotifier<bool>(false);
|
||
|
||
static bool get isEn => langNotifier.value;
|
||
static set isEn(bool value) => langNotifier.value = value;
|
||
|
||
static Future<void> loadLanguagePreference() async {
|
||
try {
|
||
final preferences = await SharedPreferences.getInstance();
|
||
isEn = preferences.getBool(_languagePreferenceKey) ?? false;
|
||
} catch (error) {
|
||
debugPrint('Failed to load language preference: $error');
|
||
isEn = false;
|
||
}
|
||
}
|
||
|
||
static Future<void> setLanguagePreference(bool value) async {
|
||
isEn = value;
|
||
try {
|
||
final preferences = await SharedPreferences.getInstance();
|
||
await preferences.setBool(_languagePreferenceKey, value);
|
||
} catch (error) {
|
||
debugPrint('Failed to save language preference: $error');
|
||
}
|
||
}
|
||
|
||
// App Title
|
||
static String get title => isEn ? 'Demo' : '示例';
|
||
|
||
// Tabs
|
||
static String get tabInit => isEn ? 'Login' : '登录';
|
||
static String get tabScan => isEn ? 'Scan' : '设备扫描';
|
||
static String get tabLock => isEn ? 'Lock' : '蓝牙控锁';
|
||
static String get tabWifi => isEn ? 'WiFi' : 'WiFi配网';
|
||
static String get tabTalk => isEn ? 'Talk' : '视频对讲';
|
||
|
||
// Common Logs & Buttons
|
||
static String get logFailed => isEn ? 'Failed' : '失败';
|
||
static String get logSuccess => isEn ? 'Success' : '成功';
|
||
static String get btnProcessing => isEn ? 'Processing...' : '处理中...';
|
||
|
||
// Auth Tab
|
||
static String get sdkStatus => isEn ? 'SDK Status' : 'SDK 状态';
|
||
static String get cloudUserStatus => isEn ? 'Signed-in Account' : '登录账户';
|
||
static String get clientId => isEn ? 'Client ID *' : '客户ID *';
|
||
static String get clientSecret => isEn ? 'Client Secret' : '客户端密钥';
|
||
static String get envUrl => isEn ? 'Env URL' : '环境地址';
|
||
static String get step1Init => isEn
|
||
? 'Step 1: Register a cloud account to get client_id and client_secret, then initialize the SDK'
|
||
: '第1步:注册星云账号填写后初始化SDK';
|
||
static String get step2User => isEn ? 'Step 2: Sign In' : '第 2 步:登录账号';
|
||
static String get btnCreateTestCloudAccount => isEn
|
||
? 'Step 2: Create a new SDK cloud account (testing only)'
|
||
: '第2步:仅测试创建新的 SDK 星云账户';
|
||
static String get btnLoginForWifiAuthorization => isEn
|
||
? 'Step 3: Sign in with the app account for WiFi authorization'
|
||
: '第3步:填写 app 登录账号,支持 WIFI 授权账号';
|
||
static String get accountLabel => isEn ? 'Account' : '账号';
|
||
static String get passwordLabel => isEn ? 'Password' : '密码';
|
||
static String get logFillId =>
|
||
isEn ? 'Please fill Client ID' : '请先填写 Client ID';
|
||
static String get logInitSuccess => isEn ? 'SDK Initialized' : 'SDK 初始化成功';
|
||
static String get logUserReady => isEn ? 'Account ready' : '账号登录成功';
|
||
|
||
// Scan Tab
|
||
static String get btnScan => isEn ? 'Scan' : '扫描';
|
||
static String get btnScanning => isEn ? 'Scanning...' : '扫描中...';
|
||
static String get btnStop => isEn ? 'Stop' : '停止';
|
||
static String get scanHint => isEn ? 'Tap "Scan" to start' : '点击"扫描设备"开始';
|
||
static String get pairedStatus => isEn ? 'Paired' : '已配对';
|
||
static String get btnPair => isEn ? 'Pair' : '配对';
|
||
static String get logScanning =>
|
||
isEn ? 'Scanning (10s)...' : '开始扫描(10 秒超时)...';
|
||
static String get logScanDone => isEn ? 'Scan done' : '扫描完成';
|
||
|
||
// Lock Tab
|
||
static String get lockIdLabel => isEn ? 'Lock ID' : '锁定ID';
|
||
static String get notPaired => isEn ? 'Not Paired' : '未配对';
|
||
static String get btnOpen => isEn ? 'Open' : '开锁';
|
||
static String get btnClose => isEn ? 'Close' : '关锁';
|
||
static String get btnDeleteLock => isEn ? 'Delete lock' : '删除锁';
|
||
static String get confirmDeleteLockTitle =>
|
||
isEn ? 'Delete lock' : '删除锁';
|
||
static String get confirmDeleteLockMessage => isEn
|
||
? 'This removes the lock from the account and resets its local binding. Continue?'
|
||
: '此操作会从当前账号删除该锁,并重置锁端绑定信息,确定继续吗?';
|
||
|
||
// WiFi Tab
|
||
static String get wifiTitle => isEn ? 'WiFi Config' : 'WiFi配网';
|
||
static String get wifiModeDirect =>
|
||
isEn ? 'Direct Mode (Lock Board)' : '锁板直连模式';
|
||
static String get wifiModeGateway => isEn ? 'Gateway Mode' : '网关模式';
|
||
static String get wifiConfigSec => isEn ? 'WiFi Settings' : 'WiFi 配置';
|
||
static String get btnStartConfig =>
|
||
isEn ? 'Step 2: WiFi Setup' : '第2步:wifi配网';
|
||
static String get logConfigSent => isEn ? 'Config Sent' : '指令已发送';
|
||
static String get currentLoggedInAccountPrefix =>
|
||
isEn ? 'Current signed-in account: ' : '当前登录账号:';
|
||
static String get wifiUsesAuthorizedSession => isEn
|
||
? 'WiFi setup will use this account\'s authorized session.'
|
||
: 'WIFI 配网将使用此账号的授权会话。';
|
||
static String get logConfigCancelledNeedTalkInitialization => isEn
|
||
? 'WiFi setup cancelled: Please tap “Step 1: Initialize Video Talk” on this page first.'
|
||
: '已取消配网:请先点击本页“第1步:初始化视频对讲”。';
|
||
static String get logUsingLoginSessionForGatewayConfig => isEn
|
||
? 'Using the signed-in session to get the gateway configuration and send it via BLE...'
|
||
: '已使用登录会话,正在获取网关配置并通过 BLE 下发...';
|
||
static String get logWifiConfigCompleted => isEn
|
||
? 'SUCCESS: BLE WiFi provisioning and deviceNetwork/setting are complete.'
|
||
: 'SUCCESS: BLE 配网及 deviceNetwork/setting 均已完成。';
|
||
|
||
// Talk Tab
|
||
static String get talkServer => isEn ? 'Server Address' : '服务器地址';
|
||
static String get btnInitTalk =>
|
||
isEn ? 'Step 1: Initialize Video Talk' : '第1步:初始化视频对讲';
|
||
static String get initialized => isEn ? 'Initialized' : '已初始化';
|
||
static String get completeWifiTalkInitialization => isEn
|
||
? 'Please complete Step 1: Initialize Video Talk on the WiFi Setup tab.'
|
||
: '请先在“WiFi配网”页完成第1步:初始化视频对讲。';
|
||
static String get incomingCall => isEn ? 'Incoming Call' : '来电';
|
||
static String get btnAccept => isEn ? 'Accept' : '接听';
|
||
static String get btnReject => isEn ? 'Reject' : '拒绝';
|
||
static String get btnHangup => isEn ? 'Hang up' : '挂断';
|
||
static String get btnRemoteUnlock =>
|
||
isEn ? 'Remote unlock' : '远程开锁';
|
||
static String get confirmRemoteUnlockTitle =>
|
||
isEn ? 'Confirm remote unlock' : '确认远程开锁';
|
||
static String get confirmRemoteUnlockMessage => isEn
|
||
? 'Make sure it is safe to unlock the door.'
|
||
: '请确认现场安全后再远程开锁。';
|
||
static String get remoteUnlockUnavailable => isEn
|
||
? 'The lock service reports remote unlock as unsupported or disabled. Enable remote unlock for this lock, then refresh its details and try again.'
|
||
: '云端锁详情显示不支持或未开启远程开锁。请在锁端/管理端开启该锁的远程开锁权限,刷新锁详情后重试。';
|
||
static String get remoteUnlockNeedsGateway => isEn
|
||
? 'This lock is not connected to a gateway for remote unlock.'
|
||
: '该锁未绑定网关,无法使用网关远程开锁。';
|
||
static String get remoteUnlockPeerUnavailable => isEn
|
||
? 'The lock peer is missing or does not match the active video call.'
|
||
: '未获取到与本次视频通话匹配的锁 Peer,无法透传开锁。';
|
||
static String get remoteUnlockNeedsOnline => isEn
|
||
? 'The lock is offline. Remote unlock is unavailable.'
|
||
: '该锁当前离线,暂时无法远程开锁。';
|
||
static String get remoteUnlockNeedsLogin => isEn
|
||
? 'Please sign in on the Login tab first.'
|
||
: '请先在登录页完成锁服务账号登录。';
|
||
static String get remoteUnlockNeedsWifi => isEn
|
||
? 'Complete Wi-Fi setup for this lock before remote unlock.'
|
||
: '请先完成当前锁的 Wi-Fi 配置,再使用远程开锁。';
|
||
static String get remoteUnlockSuccess =>
|
||
isEn ? 'Remote unlock request succeeded.' : '远程开锁请求成功。';
|
||
static String get btnMonitor => isEn ? 'Monitor' : '监控';
|
||
static String get logTalkReady => isEn ? 'Talk Ready' : '视频对讲就绪';
|
||
static String get deviceIdLabel => isEn ? 'Device ID' : '设备ID';
|
||
}
|