Browse Source

feat(配对模块): 添加配对页面的多语言支持

为配对模块添加中文翻译并替换硬编码文本为多语言键
newdev_shunjiawei
lxm 1 year ago
parent
commit
8fc12e58d0
  1. 31
      lib/core/translations/language/zh_cn.dart
  2. 46
      lib/modules/pairing/views/pairing_view.dart
  3. 14
      lib/modules/pairing/views/pairing_view_new.dart

31
lib/core/translations/language/zh_cn.dart

@ -413,6 +413,37 @@ const Map<String, String> zhCN = {
"generateSummaryFirst": "请先生成摘要",
"translationSessionRecord": "翻译会话记录",
// 配对模块
// 配对页面 (pairing_view.dart & pairing_view_new.dart)
"devicePairing": "设备配对",
"connectYourDeepSoundHeadset": "连接您的 DeepSound 耳机",
"bind": "绑定",
"authorizeBind": "授权绑定",
"enterCode": "请输入代码",
"autoInputCode": "自动输入代码",
"skipBinding": "跳过绑定",
"rescan": "重新扫描",
"skip": "跳过",
// 配对状态文本
"readyToPair": "准备开始配对",
"preparingPairingEnvironment": "正在准备配对环境...",
"connectDeepSoundViaSystemBluetooth": "请先通过系统蓝牙连接DeapSound设备",
"verifyingDevice": "正在验证设备...",
"deviceBindingConfirm": "设备绑定确认...",
"establishingDeviceAssociation": "正在建立设备关联...",
"waitingCompletePairing": "请稍候,正在完成配对...",
"pairingSuccessRedirecting": "配对成功!即将跳转到主页...",
// 配对错误状态文本
"ensureConnectedDeepSoundDevice": "请确保连接的是DeapSound设备",
"deviceAlreadyBoundToOtherAccount": "该设备已被其他账号绑定",
"deviceAssociationFailed": "设备关联失败,请重试",
"scanTimeoutEnsureDeviceNearby": "扫描超时,请确保设备在附近",
"networkError": "网络错误",
"authorizationFailedCheckCode": "授权失败,请检查授权码是否正确",
"pairingFailedRetry": "配对失败,请重试",
//用户反馈页
"feedback": "用户反馈",
'feedbackInfo': '提供反馈或建议',

46
lib/modules/pairing/views/pairing_view.dart

@ -305,44 +305,44 @@ class PairingView extends GetView<PairingController> {
String _getSubtitleForState(PairingState state) {
switch (state) {
case PairingState.idle:
return '准备开始配对';
return 'readyToPair'.tr; // 准备开始配对
case PairingState.checking:
return '正在准备配对环境...';
return 'preparingPairingEnvironment'.tr; // 正在准备配对环境...
case PairingState.waitingClassic:
return '请先通过系统蓝牙连接DeapSound设备';
return 'connectDeepSoundViaSystemBluetooth'.tr; // 请先通过系统蓝牙连接DeapSound设备
case PairingState.verifying:
return '正在验证设备...';
return 'verifyingDevice'.tr; // 正在验证设备...
case PairingState.binding:
return '设备绑定确认...';
return 'deviceBindingConfirm'.tr; // 设备绑定确认...
case PairingState.associating:
return '正在建立设备关联...';
return 'establishingDeviceAssociation'.tr; // 正在建立设备关联...
case PairingState.waitingBle:
return '请稍候,正在完成配对...';
return 'waitingCompletePairing'.tr; // 请稍候,正在完成配对...
case PairingState.completed:
return '配对成功!即将跳转到主页...';
return 'pairingSuccessRedirecting'.tr; // 配对成功!即将跳转到主页...
case PairingState.error:
final errorType = controller.errorType;
switch (errorType) {
case ErrorType.bluetoothOff:
return '请开启蓝牙后重试';
return 'bluetoothTurnedOff'.tr; // 蓝牙已关闭,请打开蓝牙
case ErrorType.noPermission:
return '需要蓝牙权限才能继续';
return 'lackPermissions'.tr; // 缺少蓝牙权限
case ErrorType.noClassicDevice:
return '请先通过系统蓝牙连接DeapSound设备';
return 'connectDeepSoundViaSystemBluetooth'.tr; // 请先通过系统蓝牙连接DeapSound设备
case ErrorType.deviceNotMatch:
return '请确保连接的是DeapSound设备';
return 'ensureConnectedDeepSoundDevice'.tr; // 请确保连接的是DeapSound设备
case ErrorType.deviceBound:
return '该设备已被其他账号绑定';
return 'deviceAlreadyBoundToOtherAccount'.tr; // 该设备已被其他账号绑定
case ErrorType.associationFailed:
return '设备关联失败,请重试';
return 'deviceAssociationFailed'.tr; // 设备关联失败,请重试
case ErrorType.bleTimeout:
return '扫描超时,请确保设备在附近';
return 'scanTimeoutEnsureDeviceNearby'.tr; // 扫描超时,请确保设备在附近
case ErrorType.networkError:
return '网络错误,请检查网络连接';
return 'networkError'.tr; // 网络错误
case ErrorType.authnFailed:
return '授权失败,请检查授权码是否正确';
return 'authorizationFailedCheckCode'.tr; // 授权失败,请检查授权码是否正确
default:
return '配对失败,请重试';
return 'pairingFailedRetry'.tr; // 配对失败,请重试
}
default:
return '';
@ -489,7 +489,7 @@ class PairingView extends GetView<PairingController> {
minimumSize: Size(double.infinity, 56.h),
),
child: Text(
"绑定",
"bind".tr, // 绑定
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
@ -530,7 +530,7 @@ class PairingView extends GetView<PairingController> {
controller: controller
.codeInputController, // 你可以在 Controller 中声明这个
decoration: InputDecoration(
hintText: '请输入代码',
hintText: 'enterCode'.tr, // 请输入代码
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12.r),
),
@ -552,7 +552,7 @@ class PairingView extends GetView<PairingController> {
elevation: 0,
),
child: Text(
'授权绑定',
'authorizeBind'.tr, // 授权绑定
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
@ -596,7 +596,7 @@ class PairingView extends GetView<PairingController> {
minimumSize: Size(double.infinity, 48.h),
),
child: Text(
'跳过绑定'.tr, // 稍后再说
'skipBinding'.tr, // 跳过绑定
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
@ -615,7 +615,7 @@ class PairingView extends GetView<PairingController> {
minimumSize: Size(double.infinity, 48.h),
),
child: Text(
'重新扫描'.tr, // 稍后再说
'rescan'.tr, // 重新扫描
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,

14
lib/modules/pairing/views/pairing_view_new.dart

@ -45,7 +45,7 @@ class PairingView extends GetView<PairingController> {
return Column(
children: [
Text(
'设备配对',
'devicePairing'.tr, // 设备配对
style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.bold,
@ -54,7 +54,7 @@ class PairingView extends GetView<PairingController> {
),
SizedBox(height: 8.h),
Text(
'连接您的 DeepSound 耳机',
'connectYourDeepSoundHeadset'.tr, // 连接您的 DeepSound 耳机
style: TextStyle(
fontSize: 14.sp,
color: isDarkMode ? Colors.grey[400] : Colors.grey[600],
@ -208,7 +208,7 @@ class PairingView extends GetView<PairingController> {
// 主要操作按钮
if (showConnectButton)
_buildPrimaryButton(
'连接设备',
'connectDevice'.tr, // 连接设备
controller.onConnectTap,
isDarkMode,
),
@ -218,7 +218,7 @@ class PairingView extends GetView<PairingController> {
TextButton(
onPressed: controller.confirmBindDevice,
child: Text(
'绑定',
'bind'.tr, // 绑定
style: TextStyle(
fontSize: 14.sp,
color: isDarkMode ? Colors.grey[400] : Colors.grey[600],
@ -228,7 +228,7 @@ class PairingView extends GetView<PairingController> {
if (showRetryButton)
_buildPrimaryButton(
'重试',
'retry'.tr, // 重试
controller.onRetryTap,
isDarkMode,
),
@ -250,7 +250,7 @@ class PairingView extends GetView<PairingController> {
elevation: 0,
),
child: Text(
'自动输入代码',
'autoInputCode'.tr, // 自动输入代码
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
@ -265,7 +265,7 @@ class PairingView extends GetView<PairingController> {
TextButton(
onPressed: controller.onSkipTap,
child: Text(
'跳过',
'skip'.tr, // 跳过
style: TextStyle(
fontSize: 14.sp,
color: isDarkMode ? Colors.grey[400] : Colors.grey[600],

Loading…
Cancel
Save