Browse Source

feat(国际化): 完善权限管理和个人资料页面的翻译

- 将权限管理页面中的硬编码文本替换为国际化翻译
- 在个人资料页面更新翻译文本和注释
- 在翻译文件中添加缺失的权限管理相关翻译项
- 重构权限管理页面的翻译获取逻辑
newdev_shunjiawei
lxm 1 year ago
parent
commit
3375798b66
  1. 55
      lib/core/translations/language/en_us.dart
  2. 45
      lib/core/translations/language/zh_cn.dart
  3. 5
      lib/modules/profile/views/profile_view.dart
  4. 91
      lib/modules/settings/views/permissions_view.dart

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

@ -213,8 +213,6 @@ const Map<String, String> enUS = {
"privacySettingsInfo": "Manage data collection and permissions", "privacySettingsInfo": "Manage data collection and permissions",
"permissionManagement": "Permission Management", // 权限管理 "permissionManagement": "Permission Management", // 权限管理
"permissionManagementInfo": "Manage app permission settings", // 管理应用权限设置 "permissionManagementInfo": "Manage app permission settings", // 管理应用权限设置
"logout": "Log Out",
"logoutTips": "Are you sure you want to log out of the current account?",
"aboutApplication": "About", "aboutApplication": "About",
"versions": "Version", "versions": "Version",
"checkUpdates": "Check Updates", "checkUpdates": "Check Updates",
@ -237,9 +235,6 @@ const Map<String, String> enUS = {
'selecttimbre': 'Select Timbre', 'selecttimbre': 'Select Timbre',
'pleaseRead': 'Please Read', 'pleaseRead': 'Please Read',
'completeRecording': 'Complete Recording', 'completeRecording': 'Complete Recording',
'deleteAccount': 'Delete Account',
'deleteAccountTips':
'Are you sure you want to permanently delete your account? This action cannot be undone.',
"firmwareUpgrade": "Firmware Upgrade", // 固件升级 "firmwareUpgrade": "Firmware Upgrade", // 固件升级
"bleHeadsetFirmwareUpgrade": "BLE Headset Firmware Upgrade", // BLE耳机固件版本升级 "bleHeadsetFirmwareUpgrade": "BLE Headset Firmware Upgrade", // BLE耳机固件版本升级
"deviceManagement": "Device Management", // 设备管理 "deviceManagement": "Device Management", // 设备管理
@ -260,8 +255,58 @@ const Map<String, String> enUS = {
// 编辑个人信息页 // 编辑个人信息页
"editProfile": "Edit Profile", "editProfile": "Edit Profile",
"avatar": "Avatar",
"nickname": "Nickname", "nickname": "Nickname",
"save": "Save", "save": "Save",
"about": "About",
"enterNickname": "Please enter your nickname",
"notSet": "Not Set",
"accountSetting": "Account Setting",
"logout": "Log Out",
"logoutTips": "Are you sure you want to log out of the current account?",
'deleteAccount': 'Delete Account',
'deleteAccountTips':
'Are you sure you want to permanently delete your account? This action cannot be undone.',
// 权限管理页面
'getPermissionStatusFailed': 'Failed to get permission status',
'communicationPermissions': 'Communication Permissions',
'calendarPermissions': 'Calendar Permissions',
'locationPermissions': 'Location Permissions',
'phone': 'Phone',
'sms': 'SMS',
'calendarWrite': 'Calendar Write',
'calendarFullAccess': 'Calendar Full Access',
'locationInfo': 'Location Info',
'phonePermissionDesc': 'Used for phone call functionality',
'smsPermissionDesc': 'Used for SMS functionality',
'calendarWritePermissionDesc':
'Used for creating calendar events and reminders',
'calendarFullAccessPermissionDesc':
'Used for reading and managing calendar events and reminders',
'locationPermissionDesc': 'Used for getting current location information',
'appFunctionNeeds': 'App function needs',
'authorized': 'Authorized',
'unauthorized': 'Unauthorized',
'needOpenInSystemSettings': 'Need to enable in system settings',
'partialAuthorization': 'Partial Authorization',
'unknownStatus': 'Unknown Status',
'permissionGranted': 'Permission granted',
'permissionRequestError': 'Error requesting permission',
'phonePermissionDetailDesc':
'Phone call functionality requires phone permission',
'smsPermissionDetailDesc': 'SMS functionality requires SMS permission',
'calendarWritePermissionDetailDesc':
'Creating calendar events requires calendar write permission',
'calendarFullAccessPermissionDetailDesc':
'Managing calendar events requires full calendar permission',
'locationPermissionDetailDesc':
'Getting location information requires location permission',
'appNeedsPermissionForFullFunction':
'App needs this permission to provide full functionality',
'permanentDenialText':
'You have permanently denied {permission} permission, please go to app settings to enable it',
'goToSettings': 'Go to Settings',
// 国家列表 // 国家列表
"邮箱": "Email", "邮箱": "Email",

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

@ -208,8 +208,6 @@ const Map<String, String> zhCN = {
"privacySettingsInfo": "管理数据收集和权限", "privacySettingsInfo": "管理数据收集和权限",
"permissionManagement": "权限管理", // 权限管理 "permissionManagement": "权限管理", // 权限管理
"permissionManagementInfo": "管理应用权限设置", // 管理应用权限设置 "permissionManagementInfo": "管理应用权限设置", // 管理应用权限设置
"logout": "退出登录",
"logoutTips": "确定要退出当前账号吗?",
"aboutApplication": "关于应用", "aboutApplication": "关于应用",
"versions": "版本", "versions": "版本",
"checkUpdates": "检查更新", "checkUpdates": "检查更新",
@ -230,8 +228,6 @@ const Map<String, String> zhCN = {
'selecttimbre': '选择音色', 'selecttimbre': '选择音色',
'pleaseRead': '请朗读', 'pleaseRead': '请朗读',
'completeRecording': '完成录制', 'completeRecording': '完成录制',
'deleteAccount': '注销账号',
'deleteAccountTips': '确定要永久删除您的账号吗?此操作不可撤销',
"firmwareUpgrade": "固件升级", "firmwareUpgrade": "固件升级",
"bleHeadsetFirmwareUpgrade": "BLE耳机固件版本升级", "bleHeadsetFirmwareUpgrade": "BLE耳机固件版本升级",
"deviceManagement": "设备管理", "deviceManagement": "设备管理",
@ -251,8 +247,49 @@ const Map<String, String> zhCN = {
//编辑个人信息页 //编辑个人信息页
"editProfile": "编辑个人信息", "editProfile": "编辑个人信息",
"avatar": "头像",
"nickname": "昵称", "nickname": "昵称",
"save": "保存", "save": "保存",
"about": "关于",
"enterNickname": "请输入昵称",
"notSet": "未设置",
"accountSetting": "账号设置",
"logout": "退出登录",
"logoutTips": "确定要退出当前账号吗?",
'deleteAccount': '注销账号',
'deleteAccountTips': '确定要永久删除您的账号吗?此操作不可撤销',
// 权限管理页面
'getPermissionStatusFailed': '获取权限状态失败',
'communicationPermissions': '通讯权限',
'calendarPermissions': '日历权限',
'locationPermissions': '位置权限',
'phone': '电话',
'sms': '短信',
'calendarWrite': '日历写入',
'calendarFullAccess': '日历完整访问',
'locationInfo': '位置信息',
'phonePermissionDesc': '用于拨打电话功能',
'smsPermissionDesc': '用于发送短信功能',
'calendarWritePermissionDesc': '用于创建日历事件和提醒',
'calendarFullAccessPermissionDesc': '用于读取和管理日历事件及提醒',
'locationPermissionDesc': '用于获取当前位置信息',
'appFunctionNeeds': '应用功能需要',
'authorized': '已授权',
'unauthorized': '未授权',
'needOpenInSystemSettings': '需要在系统设置中开启',
'partialAuthorization': '部分授权',
'unknownStatus': '未知状态',
'permissionGranted': '权限已授予',
'permissionRequestError': '请求权限时出错',
'phonePermissionDetailDesc': '拨打电话功能需要电话权限',
'smsPermissionDetailDesc': '发送短信功能需要短信权限',
'calendarWritePermissionDetailDesc': '创建日历事件需要日历写入权限',
'calendarFullAccessPermissionDetailDesc': '管理日历事件需要完整日历权限',
'locationPermissionDetailDesc': '获取位置信息需要位置权限',
'appNeedsPermissionForFullFunction': '应用需要此权限以提供完整功能',
'permanentDenialText': '您已永久拒绝{permission}权限,请前往应用设置开启',
'goToSettings': '去设置',
//国家列表 //国家列表
"邮箱": "邮箱", "邮箱": "邮箱",

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

@ -233,7 +233,7 @@ class EditProfileView extends GetView<ProfileController> {
Padding( Padding(
padding: EdgeInsets.only(left: 4.w, bottom: 8.h), padding: EdgeInsets.only(left: 4.w, bottom: 8.h),
child: Text( child: Text(
'editProfile'.tr, // 编辑资料 'editProfile'.tr, // 编辑个人信息
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@ -461,7 +461,8 @@ class EditProfileView extends GetView<ProfileController> {
Widget _buildNicknameEditingMode(BuildContext context, bool isDarkMode, Widget _buildNicknameEditingMode(BuildContext context, bool isDarkMode,
TextEditingController nameController) { TextEditingController nameController) {
return Padding( return Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h), // 与显示模式保持一致的padding padding: EdgeInsets.symmetric(
horizontal: 16.w, vertical: 16.h), // 与显示模式保持一致的padding
child: Row( child: Row(
children: [ children: [
// 图标 - 保持与显示模式相同的绿色主题 // 图标 - 保持与显示模式相同的绿色主题

91
lib/modules/settings/views/permissions_view.dart

@ -27,7 +27,7 @@ class PermissionsView extends GetView<SettingsController> {
onPressed: () => Get.back(), onPressed: () => Get.back(),
), ),
title: Text( title: Text(
'权限管理'.tr, 'permissionManagement'.tr, // 权限管理
style: TextStyle( style: TextStyle(
fontSize: 17.sp, fontSize: 17.sp,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -44,7 +44,9 @@ class PermissionsView extends GetView<SettingsController> {
} }
if (snapshot.hasError) { if (snapshot.hasError) {
return Center(child: Text('获取权限状态失败: ${snapshot.error}'.tr)); return Center(
child: Text('getPermissionStatusFailed'.tr +
': ${snapshot.error}')); // 获取权限状态失败
} }
final permissionStatuses = snapshot.data ?? {}; final permissionStatuses = snapshot.data ?? {};
@ -54,7 +56,7 @@ class PermissionsView extends GetView<SettingsController> {
children: [ children: [
// 通讯权限组 // 通讯权限组
_buildPermissionSection( _buildPermissionSection(
'通讯权限', 'communicationPermissions'.tr, // 通讯权限
Icons.phone_android, Icons.phone_android,
[Permission.phone, Permission.sms], [Permission.phone, Permission.sms],
permissionStatuses, permissionStatuses,
@ -64,7 +66,7 @@ class PermissionsView extends GetView<SettingsController> {
// 日历权限组 // 日历权限组
_buildPermissionSection( _buildPermissionSection(
'日历权限', 'calendarPermissions'.tr, // 日历权限
Icons.calendar_today, Icons.calendar_today,
[Permission.calendarFullAccess], [Permission.calendarFullAccess],
permissionStatuses, permissionStatuses,
@ -73,8 +75,12 @@ class PermissionsView extends GetView<SettingsController> {
SizedBox(height: 20.h), SizedBox(height: 20.h),
// 位置权限组 // 位置权限组
_buildPermissionSection('位置权限', Icons.location_on, _buildPermissionSection(
[Permission.location], permissionStatuses, isDarkMode), 'locationPermissions'.tr, // 位置权限
Icons.location_on,
[Permission.location],
permissionStatuses,
isDarkMode),
], ],
); );
}, },
@ -147,15 +153,15 @@ class PermissionsView extends GetView<SettingsController> {
String getName(Permission permission) { String getName(Permission permission) {
switch (permission) { switch (permission) {
case Permission.phone: case Permission.phone:
return '电话'; return 'phone'.tr; // 电话
case Permission.sms: case Permission.sms:
return '短信'; return 'sms'.tr; // 短信
case Permission.calendarFullAccess: case Permission.calendarFullAccess:
return '日历写入'; return 'calendarWrite'.tr; // 日历写入
case Permission.calendarFullAccess: case Permission.calendarFullAccess:
return '日历完整访问'; return 'calendarFullAccess'.tr; // 日历完整访问
case Permission.location: case Permission.location:
return '位置信息'; return 'locationInfo'.tr; // 位置信息
default: default:
return permission.toString(); return permission.toString();
} }
@ -165,17 +171,17 @@ class PermissionsView extends GetView<SettingsController> {
String getDescription(Permission permission) { String getDescription(Permission permission) {
switch (permission) { switch (permission) {
case Permission.phone: case Permission.phone:
return '用于拨打电话功能'; return 'phonePermissionDesc'.tr; // 用于拨打电话功能
case Permission.sms: case Permission.sms:
return '用于发送短信功能'; return 'smsPermissionDesc'.tr; // 用于发送短信功能
case Permission.calendarFullAccess: case Permission.calendarFullAccess:
return '用于创建日历事件和提醒'; return 'calendarWritePermissionDesc'.tr; // 用于创建日历事件和提醒
case Permission.calendarFullAccess: case Permission.calendarFullAccess:
return '用于读取和管理日历事件及提醒'; return 'calendarFullAccessPermissionDesc'.tr; // 用于读取和管理日历事件及提醒
case Permission.location: case Permission.location:
return '用于获取当前位置信息'; return 'locationPermissionDesc'.tr; // 用于获取当前位置信息
default: default:
return '应用功能需要'; return 'appFunctionNeeds'.tr; // 应用功能需要
} }
} }
@ -265,19 +271,19 @@ class PermissionsView extends GetView<SettingsController> {
Color color; Color color;
if (status.isGranted) { if (status.isGranted) {
text = '已授权'.tr; text = 'authorized'.tr; // 已授权
color = Colors.green; color = Colors.green;
} else if (status.isDenied) { } else if (status.isDenied) {
text = '未授权'.tr; text = 'unauthorized'.tr; // 未授权
color = Colors.red; color = Colors.red;
} else if (status.isPermanentlyDenied) { } else if (status.isPermanentlyDenied) {
text = '需要在系统设置中开启'.tr; text = 'needOpenInSystemSettings'.tr; // 需要在系统设置中开启
color = Colors.orange; color = Colors.orange;
} else if (status.isLimited) { } else if (status.isLimited) {
text = '部分授权'.tr; text = 'partialAuthorization'.tr; // 部分授权
color = Colors.orange; color = Colors.orange;
} else { } else {
text = '未知状态'.tr; text = 'unknownStatus'.tr; // 未知状态
color = Colors.grey; color = Colors.grey;
} }
@ -299,7 +305,7 @@ class PermissionsView extends GetView<SettingsController> {
// if (context == null) return; // if (context == null) return;
final permissionName = _getPermissionName(permission); final permissionName = _getPermissionName(permission);
final explanationText = _getExplanationText(permission); final explanationText = getDetailedDescription(permission);
// 使用 PermissionUtil 请求权限 // 使用 PermissionUtil 请求权限
final hasPermission = await PermissionUtil.instance.requestPermission( final hasPermission = await PermissionUtil.instance.requestPermission(
@ -307,15 +313,16 @@ class PermissionsView extends GetView<SettingsController> {
permissionType: permission, permissionType: permission,
permissionName: permissionName, permissionName: permissionName,
explanationText: explanationText, explanationText: explanationText,
permanentDenialText: '您已永久拒绝$permissionName权限,请前往应用设置开启', permanentDenialText: 'permanentDenialText'.tr.replaceAll(
settingsButtonText: '去设置', '{permission}', permissionName), // 您已永久拒绝{permission}权限,请前往应用设置开启
cancelButtonText: '取消', settingsButtonText: 'goToSettings'.tr, // 去设置
cancelButtonText: 'cancel'.tr, // 取消
); );
if (hasPermission) { if (hasPermission) {
Get.snackbar( Get.snackbar(
'成功'.tr, 'success'.tr, // 成功
'$permissionName权限已授予'.tr, 'permissionGranted'.tr, // 权限已授予
snackPosition: SnackPosition.BOTTOM, snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.green, backgroundColor: Colors.green,
colorText: Colors.white, colorText: Colors.white,
@ -326,8 +333,8 @@ class PermissionsView extends GetView<SettingsController> {
Get.forceAppUpdate(); Get.forceAppUpdate();
} catch (e) { } catch (e) {
Get.snackbar( Get.snackbar(
'错误'.tr, 'error'.tr, // 错误
'请求权限时出错: $e'.tr, 'permissionRequestError'.tr, // 请求权限时出错
snackPosition: SnackPosition.BOTTOM, snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red, backgroundColor: Colors.red,
colorText: Colors.white, colorText: Colors.white,
@ -339,35 +346,35 @@ class PermissionsView extends GetView<SettingsController> {
String _getPermissionName(Permission permission) { String _getPermissionName(Permission permission) {
switch (permission) { switch (permission) {
case Permission.phone: case Permission.phone:
return '电话'; return 'phone'.tr; // 电话
case Permission.sms: case Permission.sms:
return '短信'; return 'sms'.tr; // 短信
case Permission.calendarFullAccess: case Permission.calendarFullAccess:
return '日历写入'; return 'calendarWrite'.tr; // 日历写入
case Permission.calendarFullAccess: case Permission.calendarFullAccess:
return '日历完整访问'; return 'calendarFullAccess'.tr; // 日历完整访问
case Permission.location: case Permission.location:
return '位置信息'; return 'locationInfo'.tr; // 位置信息
default: default:
return permission.toString(); return permission.toString();
} }
} }
// 获取权限说明文本 // 获取权限说明文本
String _getExplanationText(Permission permission) { String getDetailedDescription(Permission permission) {
switch (permission) { switch (permission) {
case Permission.phone: case Permission.phone:
return '拨打电话功能需要电话权限'; return 'phonePermissionDetailDesc'.tr; // 拨打电话功能需要电话权限
case Permission.sms: case Permission.sms:
return '发送短信功能需要短信权限'; return 'smsPermissionDetailDesc'.tr; // 发送短信功能需要短信权限
case Permission.calendarFullAccess: case Permission.calendarFullAccess:
return '创建日历事件需要日历写入权限'; return 'calendarWritePermissionDetailDesc'.tr; // 创建日历事件需要日历写入权限
case Permission.calendarFullAccess: case Permission.calendarFullAccess:
return '管理日历事件需要完整日历权限'; return 'calendarFullAccessPermissionDetailDesc'.tr; // 管理日历事件需要完整日历权限
case Permission.location: case Permission.location:
return '获取位置信息需要位置权限'; return 'locationPermissionDetailDesc'.tr; // 获取位置信息需要位置权限
default: default:
return '应用需要此权限以提供完整功能'; return 'appNeedsPermissionForFullFunction'.tr; // 应用需要此权限以提供完整功能
} }
} }
} }

Loading…
Cancel
Save