Browse Source

feat(i18n): 添加设备管理、OTA升级和音乐模块的国际化支持

- 在zh_cn.dart和en_us.dart中添加设备管理、OTA升级和音乐模块的翻译字段
- 修改profile_view.dart、music_playlist_view.dart、devices_view.dart和ota_upgrade_view.dart使用.tr方法调用翻译字段
- 统一各模块中硬编码的字符串为国际化字段
newdev_shunjiawei
lxm 1 year ago
parent
commit
fbd2eb19b6
  1. 36
      lib/core/translations/language/en_us.dart
  2. 33
      lib/core/translations/language/zh_cn.dart
  3. 16
      lib/modules/devices/views/devices_view.dart
  4. 14
      lib/modules/music/views/music_playlist_view.dart
  5. 54
      lib/modules/ota_upgrade/views/ota_upgrade_view.dart
  6. 2
      lib/modules/profile/views/profile_view.dart

36
lib/core/translations/language/en_us.dart

@ -246,6 +246,13 @@ const Map<String, String> enUS = {
'Experience intelligent voice interaction features (Preview)',
'loading': 'Loading...',
//设备管理页面
"earphone": "Earphone", // 耳机
"voicerecorder": "Voice Recorder", // 录音笔
"notBound": "Not Bound", // 未绑定
"deviceNotBoundYet": "Device not bound yet", // 还未绑定设备
"unbind": "Unbind", // 解绑
// 聊天页
"clearChatHistory": "Clear Chat History",
"online": "Online",
@ -530,6 +537,35 @@ const Map<String, String> enUS = {
'feedbackSubmitSuccess': 'Feedback submitted successfully, thank you!',
'feedbackSubmitFailed': 'Failed to submit feedback, please try again later',
// OTA升级模块
"upgradeExitConfirm":
"Currently upgrading, exiting will interrupt the upgrade process. Are you sure you want to exit?",
"deviceModel": "Device Model",
"unknownDevice": "Unknown Device",
"currentFirmwareVersion": "Current Firmware Version",
"latestFirmwareVersion": "Latest Firmware Version",
"newVersionFound": "New Version Found",
"latestVersion": "Latest Version",
"gettingDeviceInfo": "Getting device information...",
"keepDeviceConnected": "Please keep device connected",
"connectionFailed": "Connection Failed",
"retryConnection": "Retry Connection",
"updateNow": "Update Now",
"keepConnectedDontClose":
"Please keep device connected, do not close the app",
"doNotDisconnect": "Do not disconnect",
"charging": "Charging",
"updateContent": "Update Content",
"removeEarbudsEnsureBattery":
"Remove both earbuds and ensure battery level is above 30%",
// 音乐列表页面
"noMusic": "No Music", // 暂无音乐
"noPlayingMusic": "No Playing Music", // 暂无播放音乐
"unknownSong": "Unknown Song", // 未知歌曲
"unknownArtist": "Unknown Artist", // 未知歌手
"playAll": "Play All", // 播放全部
// 语言名称
"中文(简体)": "Chinese (Simplified)",
"中文(繁体)": "Chinese (Traditional)",

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

@ -238,6 +238,13 @@ const Map<String, String> zhCN = {
"realtimeVoiceChatInfo": "体验智能语音交互功能(功能预览)",
"loading": "加载中...",
//设备管理页面
"earphone": "耳机",
"voicerecorder": "录音笔",
"notBound": "未绑定",
"deviceNotBoundYet": "还未绑定设备",
"unbind": "解绑",
// 聊天页
"clearChatHistory": "清空聊天记录",
"online": "在线",
@ -502,6 +509,32 @@ const Map<String, String> zhCN = {
'feedbackSubmitSuccess': '反馈提交成功,感谢您的反馈!',
'feedbackSubmitFailed': '反馈提交失败,请稍后重试',
// OTA升级模块
"upgradeExitConfirm": "当前正在升级,退出将中断升级进程,确定要退出吗?",
"deviceModel": "设备型号",
"unknownDevice": "未知设备",
"currentFirmwareVersion": "当前固件版本",
"latestFirmwareVersion": "最新固件版本",
"newVersionFound": "发现新版本",
"latestVersion": "已是最新版本",
"gettingDeviceInfo": "正在获取设备信息...",
"keepDeviceConnected": "请保持设备连接",
"connectionFailed": "连接失败",
"retryConnection": "重试连接",
"updateNow": "立即更新",
"keepConnectedDontClose": "请保持设备连接,不要关闭应用",
"doNotDisconnect": "请勿断开连接",
"charging": "充电中",
"updateContent": "更新内容",
"removeEarbudsEnsureBattery": "取出双耳机,并保证电量均为30%以上的状态",
// 音乐列表页面
"noMusic": "暂无音乐", // 暂无音乐
"noPlayingMusic": "暂无播放音乐", // 暂无播放音乐
"unknownSong": "未知歌曲", // 未知歌曲
"unknownArtist": "未知歌手", // 未知歌手
"playAll": "播放全部", // 播放全部
// 语言名称
"中文(简体)": "中文(简体)",
"中文(繁体)": "中文(繁体)",

16
lib/modules/devices/views/devices_view.dart

@ -31,7 +31,7 @@ class DevicesView extends GetView<DevicesController> {
},
),
title: Text(
'设备管理'.tr,
'deviceManagement'.tr,
style: TextStyle(
fontSize: 20.sp,
color: isDarkMode ? Colors.white : Colors.black,
@ -58,7 +58,7 @@ class DevicesView extends GetView<DevicesController> {
Padding(
padding: EdgeInsets.only(left: 4.w, bottom: 8.h),
child: Text(
'earphone'.tr, // AI设置
'earphone'.tr, // 耳机
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w500,
@ -95,10 +95,10 @@ class DevicesView extends GetView<DevicesController> {
_buildSimpleNavigationSetting(
title: controller.earphonestate.value != 0
? controller.earphoneName.value
: "未绑定",
: "notBound".tr, // 未绑定
subtitle: controller.earphonestate.value != 0
? controller.earphoneMac.value
: "还未绑定设备",
: "deviceNotBoundYet".tr, // 还未绑定设备
icon: Icons.headphones,
iconBgColor: isDarkMode
? const Color.fromARGB(255, 255, 255, 255)!
@ -167,8 +167,8 @@ class DevicesView extends GetView<DevicesController> {
// 实时对话入口
Obx(
() => _buildSimpleNavigationSetting(
title: '未绑定',
subtitle: '还未绑定设备',
title: 'notBound'.tr, // 未绑定
subtitle: 'deviceNotBoundYet'.tr, // 还未绑定设备
icon: Icons.edit,
iconBgColor: isDarkMode
? const Color.fromARGB(255, 255, 255, 255)!
@ -275,8 +275,8 @@ class DevicesView extends GetView<DevicesController> {
padding: EdgeInsets.symmetric(horizontal: 2, vertical: 2),
),
onPressed: onPressed,
child: const Text(
'解绑',
child: Text(
'unbind'.tr, // 解绑
style: TextStyle(
color: Colors.white,
),

14
lib/modules/music/views/music_playlist_view.dart

@ -38,7 +38,7 @@ class MusicPlaylistView extends StatelessWidget {
),
SizedBox(height: 16.h),
Text(
'暂无音乐',
'noMusic'.tr, // 暂无音乐
style: TextStyle(
fontSize: 16.sp,
color: Colors.grey[600],
@ -103,7 +103,7 @@ class MusicPlaylistView extends StatelessWidget {
),
SizedBox(height: 12.h),
Text(
'暂无播放音乐',
'noPlayingMusic'.tr, // 暂无播放音乐
style: TextStyle(
fontSize: 16.sp,
color: isDarkMode ? Colors.grey[400] : Colors.grey[600],
@ -115,11 +115,11 @@ class MusicPlaylistView extends StatelessWidget {
);
}
final title = currentSong['name'] ?? currentSong['title'] ?? '未知歌曲';
final title = currentSong['name'] ?? currentSong['title'] ?? 'unknownSong'.tr; // 未知歌曲
final artist = currentSong['singer'] ??
currentSong['sgener'] ??
currentSong['artist'] ??
'未知歌手';
'unknownArtist'.tr; // 未知歌手
final coverUrl = currentSong['image'] ?? currentSong['coverUrl'] ?? '';
return Container(
@ -161,7 +161,7 @@ class MusicPlaylistView extends StatelessWidget {
},
icon: Icon(Icons.play_arrow, color: Colors.white, size: 20.w),
label: Text(
'播放全部',
'playAll'.tr, // 播放全部
style: TextStyle(
fontSize: 15.sp,
fontWeight: FontWeight.w600,
@ -190,9 +190,9 @@ class MusicPlaylistView extends StatelessWidget {
itemBuilder: (context, index) {
final item = playlist[index];
final id = item["id"] ?? 0;
final name = item["name"] ?? "未知歌曲";
final name = item["name"] ?? 'unknownSong'.tr; // 未知歌曲
final url = item["url"] ?? "";
final singer = item["singer"] ?? item["sgener"] ?? "未知歌手";
final singer = item["singer"] ?? item["sgener"] ?? 'unknownArtist'.tr; // 未知歌手
final image = item["image"] ?? "";
return _buildMusicItem(

54
lib/modules/ota_upgrade/views/ota_upgrade_view.dart

@ -17,12 +17,13 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
// 显示确认弹窗
await Get.dialog(
AlertDialog(
title: Text('提示'),
content: Text('当前正在升级,退出将中断升级进程,确定要退出吗?'),
title: Text('tip'.tr), // 提示
content:
Text('upgradeExitConfirm'.tr), // 当前正在升级,退出将中断升级进程,确定要退出吗?
actions: [
TextButton(
onPressed: () => Get.back(), // 关闭弹窗
child: Text('取消'),
child: Text('cancel'.tr), // 取消
),
TextButton(
onPressed: () {
@ -30,7 +31,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
Get.back(); // 关闭弹窗
Get.back(); // 返回上一页
},
child: Text('确定'),
child: Text('confirm'.tr), // 确定
),
],
),
@ -57,12 +58,13 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
// 显示确认弹窗
Get.dialog(
AlertDialog(
title: Text('提示'),
content: Text('当前正在升级,退出将中断升级进程,确定要退出吗?'),
title: Text('tip'.tr), // 提示
content: Text(
'upgradeExitConfirm'.tr), // 当前正在升级,退出将中断升级进程,确定要退出吗?
actions: [
TextButton(
onPressed: () => Get.back(), // 关闭弹窗
child: Text('取消'),
child: Text('cancel'.tr), // 取消
),
TextButton(
onPressed: () {
@ -70,7 +72,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
Get.back(); // 关闭弹窗
Get.back(); // 返回上一页
},
child: Text('确定'),
child: Text('confirm'.tr), // 确定
),
],
),
@ -81,7 +83,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
},
),
title: Text(
'固件升级'.tr,
'firmwareUpgrade'.tr, //固件升级
style: TextStyle(
fontSize: 20.sp,
color: isDarkMode ? Colors.white : Colors.black,
@ -217,8 +219,8 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
// 设备型号信息
_buildDeviceInfoRow(
icon: Icons.headset,
label: '设备型号',
value: deviceInfo?.name ?? '未知设备',
label: 'deviceModel'.tr, // 设备型号
value: deviceInfo?.name ?? 'unknownDevice'.tr, // 未知设备
isDarkMode: isDarkMode,
),
// SizedBox(height: 10.h),
@ -361,7 +363,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
if (isCharging) ...[
SizedBox(height: 1.h),
Text(
'充电中',
'charging'.tr, // 充电中
style: TextStyle(
fontSize: 10.sp,
color: batteryColor,
@ -380,7 +382,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
children: [
// 当前版本信息
_buildVersionInfoRow(
label: '当前固件版本'.tr,
label: 'currentFirmwareVersion'.tr, //当前固件版本
version: controller.currentVersion,
isDarkMode: isDarkMode,
isLatest: false,
@ -388,7 +390,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
SizedBox(height: 8.h),
// 最新版本信息
_buildVersionInfoRow(
label: '最新固件版本'.tr,
label: 'latestFirmwareVersion'.tr, //最新固件版本
version: controller.latestVersion,
isDarkMode: isDarkMode,
isLatest: true,
@ -499,7 +501,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
),
SizedBox(width: 6.w),
Text(
'发现新版本',
'newVersionFound'.tr, // 发现新版本
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w500,
@ -530,7 +532,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
),
SizedBox(width: 6.w),
Text(
'已是最新版本',
'latestVersion'.tr, // 已是最新版本
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w500,
@ -596,7 +598,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
),
SizedBox(width: 12.w),
Text(
'更新内容'.tr,
'updateContent'.tr, //更新内容
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
@ -667,7 +669,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
),
SizedBox(height: 24.h),
Text(
'正在获取设备信息...',
'gettingDeviceInfo'.tr, // 正在获取设备信息...
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
@ -676,7 +678,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
),
SizedBox(height: 8.h),
Text(
'请保持设备连接',
'keepDeviceConnected'.tr, // 请保持设备连接
style: TextStyle(
fontSize: 12.sp,
color: isDarkMode ? Colors.grey[500] : Colors.grey[500],
@ -731,7 +733,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
SizedBox(height: 16.h),
// 错误标题
Text(
'连接失败',
'connectionFailed'.tr, // 连接失败
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.w600,
@ -756,7 +758,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
child: ElevatedButton.icon(
icon: Icon(Icons.refresh, size: 18.sp),
label: Text(
'重试连接'.tr,
'retryConnection'.tr, //重试连接
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
@ -832,7 +834,9 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
size: 20.sp,
),
label: Text(
controller.isUpdateAvailable.value ? '立即更新' : '已是最新版本',
controller.isUpdateAvailable.value
? 'updateNow'.tr
: 'latestVersion'.tr, // 立即更新 : 已是最新版本
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
@ -877,7 +881,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
SizedBox(width: 12.w),
Expanded(
child: Text(
'取出双耳机,并保证电量均为30%以上的状态'.tr,
'removeEarbudsEnsureBattery'.tr, //取出双耳机,并保证电量均为30%以上的状态
style: TextStyle(
fontSize: 13.sp,
color: isDarkMode
@ -968,7 +972,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
// 提示信息
Text(
'请保持设备连接,不要关闭应用',
'keepConnectedDontClose'.tr, // 请保持设备连接,不要关闭应用
style: TextStyle(
fontSize: 12.sp,
color: isDarkMode ? Colors.grey[400] : Colors.grey[600],
@ -1081,7 +1085,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
),
),
Text(
'请勿断开连接',
'doNotDisconnect'.tr, // 请勿断开连接
style: TextStyle(
fontSize: 12.sp,
color: isDarkMode ? Colors.grey[400] : Colors.grey[600],

2
lib/modules/profile/views/profile_view.dart

@ -647,7 +647,7 @@ class EditProfileView extends GetView<ProfileController> {
Padding(
padding: EdgeInsets.only(left: 4.w, bottom: 8.h),
child: Text(
'AccountSetting'.tr, // 账号设置
'accountSetting'.tr, // 账号设置
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w500,

Loading…
Cancel
Save