From 67f8af50b0fd62e6432c0b36572276172bf1e1bf Mon Sep 17 00:00:00 2001 From: norulers Date: Mon, 23 Feb 2026 08:39:20 +0800 Subject: [PATCH 1/2] feat(i18n): Add i18n infrastructure and Chinese translations - Add vue-i18n dependency and i18n plugin - Create English and Chinese translation files (en.json, zh.json) - Add Vuetify Chinese locale support - Configure i18n with fallback locale and locale persistence feat(i18n): Integrate i18n across all components with enhancements - Add i18n to ExternalFeaturesDiscoveryModal, WidgetBar, IFrame, ConfigurationGeneralView - Add en/zh translations for all new upstream components - Export getAvailableCockpitActions for dynamic translations - Resolve merge conflicts in VideoLibraryModal and WidgetHugger --- .eslintrc.cjs | 1 + package.json | 1 + src/App.vue | 30 +- src/components/About.vue | 28 +- src/components/AltitudeSlider.vue | 2 +- src/components/ArchitectureWarning.vue | 30 +- src/components/ArmSafetyDialog.vue | 32 +- src/components/CameraReplacementDialog.vue | 39 +- src/components/DataLakeVariableDialog.vue | 28 +- src/components/DataPrivacyModal.vue | 33 +- src/components/EditMenu.vue | 151 +- .../ExternalFeaturesDiscoveryModal.vue | 179 +- src/components/GlobalOriginDialog.vue | 44 +- src/components/InputElementConfig.vue | 55 +- src/components/InteractionDialog.vue | 4 +- src/components/LanguageSwitcher.vue | 66 + src/components/MainMenu.vue | 44 +- src/components/MiniWidgetInstantiator.vue | 4 +- src/components/MissionChecklist.vue | 25 +- src/components/SplashScreen.vue | 22 +- src/components/TransformingFunctionDialog.vue | 48 +- src/components/Tutorial.vue | 131 +- src/components/UpdateNotification.vue | 46 +- src/components/UserNameInputDialog.vue | 63 +- src/components/VehicleDiscoveryDialog.vue | 30 +- src/components/VideoLibraryModal.vue | 284 +- src/components/VideoPlayerStatsForNerds.vue | 44 +- src/components/WidgetBar.vue | 13 +- src/components/WidgetHugger.vue | 4 +- .../configuration/ActionLinkConfig.vue | 46 +- .../configuration/CockpitSettingsManager.vue | 82 +- .../configuration/HttpRequestActionConfig.vue | 67 +- .../configuration/JavascriptActionConfig.vue | 22 +- .../MavlinkMessageActionConfig.vue | 45 +- .../custom-widget-elements/Checkbox.vue | 6 +- .../custom-widget-elements/Dial.vue | 6 +- .../custom-widget-elements/Dropdown.vue | 6 +- .../custom-widget-elements/Slider.vue | 6 +- .../custom-widget-elements/Switch.vue | 6 +- .../development/MAVLinkInspector.vue | 28 +- .../development/MAVLinkInspectorItem.vue | 26 +- .../joysticks/JoystickCalibration.vue | 76 +- src/components/mini-widgets/Alerter.vue | 29 +- src/components/mini-widgets/ArmerButton.vue | 24 +- .../mini-widgets/BaseCommIndicator.vue | 10 +- .../mini-widgets/BatteryIndicator.vue | 32 +- .../mini-widgets/ChangeAltitudeCommander.vue | 4 +- src/components/mini-widgets/Clock.vue | 11 +- .../mini-widgets/DepthIndicator.vue | 2 +- .../mini-widgets/EkfStateIndicator.vue | 6 +- src/components/mini-widgets/EnterEditMode.vue | 2 +- src/components/mini-widgets/GoFullScreen.vue | 2 +- .../mini-widgets/JoystickCommIndicator.vue | 20 +- .../mini-widgets/MiniMissionControlPanel.vue | 30 +- .../mini-widgets/MiniVideoRecorder.vue | 22 +- .../mini-widgets/MissionIdentifier.vue | 15 +- src/components/mini-widgets/ModeSelector.vue | 76 +- .../RelativeAltitudeIndicator.vue | 2 +- .../mini-widgets/SatelliteIndicator.vue | 35 +- src/components/mini-widgets/SnapshotTool.vue | 49 +- .../mini-widgets/TakeoffLandCommander.vue | 19 +- .../mini-widgets/VeryGenericIndicator.vue | 65 +- src/components/mini-widgets/ViewSelector.vue | 47 +- .../mission-planning/CommandInputForm.vue | 37 +- .../mission-planning/ContextMenu.vue | 48 +- .../HomePositionSettingHelp.vue | 10 +- .../mission-planning/MissionEstimates.vue | 45 +- .../mission-planning/ScanDirectionDial.vue | 4 +- .../mission-planning/SurveyVertexList.vue | 10 +- .../mission-planning/WaypointConfigPanel.vue | 59 +- src/components/poi/PoiManager.vue | 116 +- src/components/widgets/Attitude.vue | 14 +- .../widgets/CollapsibleContainer.vue | 34 +- src/components/widgets/Compass.vue | 9 +- src/components/widgets/CompassHUD.vue | 24 +- src/components/widgets/DepthHUD.vue | 6 +- src/components/widgets/DoItYourself.vue | 57 +- src/components/widgets/IFrame.vue | 43 +- src/components/widgets/ImageView.vue | 6 +- src/components/widgets/Map.vue | 173 +- .../widgets/MissionControlPanel.vue | 38 +- src/components/widgets/Plotter.vue | 154 +- src/components/widgets/URLVideoPlayer.vue | 16 +- src/components/widgets/VideoPlayer.vue | 63 +- src/composables/armSafetyDialog.ts | 5 +- src/electron/main.ts | 2 + src/electron/preload.ts | 1 + src/electron/services/menu.ts | 328 ++ ...ink-message-actions-message-definitions.ts | 31 + src/libs/cosmos.ts | 6 + src/libs/joystick/protocols.ts | 12 +- .../joystick/protocols/cockpit-actions.ts | 65 +- src/libs/joystick/protocols/other.ts | 21 +- .../protocols/predefined-resources.ts | 54 +- src/libs/sensors-logging.ts | 4 +- src/libs/slide-to-confirm.ts | 110 +- src/libs/utils-vue.ts | 5 +- src/libs/vehicle/mavlink/vehicle.ts | 30 +- src/locales/zh.json | 1950 +++++++ src/main.ts | 3 +- src/plugins/i18n.ts | 49 + src/plugins/vuetify.ts | 28 +- src/stores/alert.ts | 3 +- src/stores/controller.ts | 23 +- src/stores/mainVehicle.ts | 50 +- src/stores/omniscientLogger.ts | 13 +- src/stores/snapshot.ts | 3 +- src/stores/vehicleAlerter.ts | 10 +- src/stores/video.ts | 82 +- src/stores/widgetManager.ts | 27 +- src/styles/global.css | 24 + src/views/AboutView.vue | 2 +- src/views/ConfigurationActionsView.vue | 90 +- src/views/ConfigurationAlertsView.vue | 45 +- src/views/ConfigurationDevelopmentView.vue | 28 +- src/views/ConfigurationGeneralView.vue | 222 +- src/views/ConfigurationJoystickView.vue | 246 +- src/views/ConfigurationLogsView.vue | 121 +- src/views/ConfigurationMAVLinkView.vue | 82 +- src/views/ConfigurationMissionView.vue | 96 +- src/views/ConfigurationUIView.vue | 41 +- src/views/ConfigurationVideoView.vue | 219 +- src/views/MissionPlanningView.vue | 348 +- src/views/ToolsDataLakeView.vue | 59 +- src/views/ToolsMAVLinkView.vue | 6 +- src/views/WidgetsView.vue | 4 +- yarn.lock | 4859 +++++++++-------- 127 files changed, 8616 insertions(+), 4162 deletions(-) create mode 100644 src/components/LanguageSwitcher.vue create mode 100644 src/electron/services/menu.ts create mode 100644 src/locales/zh.json create mode 100644 src/plugins/i18n.ts diff --git a/.eslintrc.cjs b/.eslintrc.cjs index cfbda46158..9a37fd7703 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -102,6 +102,7 @@ module.exports = { ignoreHTMLAttributeValues: true, ignoreHTMLTextContents: true, ignoreUrls: true, + ignoreStrings: true, }, ], }, diff --git a/package.json b/package.json index b7d72a2e21..b8f8208b02 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "vue": "^3.4.21", "vue-draggable-plus": "^0.2.0-beta.2", "vue-draggable-resizable": "3.0.0", + "vue-i18n": "9", "vue-router": "^4.0.14", "vue-virtual-scroller": "^2.0.0-beta.8", "vue3-slider": "^1.9.0", diff --git a/src/App.vue b/src/App.vue index f36d2965f5..13d899e1fb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -117,6 +117,8 @@ diff --git a/src/components/MainMenu.vue b/src/components/MainMenu.vue index ce8bb76ab7..e15c39123d 100644 --- a/src/components/MainMenu.vue +++ b/src/components/MainMenu.vue @@ -22,13 +22,13 @@ > Settings Icon Tools Icon { { icon: 'mdi-view-dashboard-variant', title: 'General', + titleKey: 'general', componentName: SubMenuComponentName.SettingsGeneral, component: markRaw(ConfigurationGeneralView) as SubMenuComponent, }, { icon: 'mdi-monitor-cellphone', title: 'Interface', + titleKey: 'interface', componentName: SubMenuComponentName.SettingsInterface, component: markRaw(ConfigurationUIView) as SubMenuComponent, }, { icon: 'mdi-controller', title: 'Joystick', + titleKey: 'joystick', componentName: SubMenuComponentName.SettingsJoystick, component: markRaw(ConfigurationJoystickView) as SubMenuComponent, }, { icon: 'mdi-video', title: 'Video', + titleKey: 'video', componentName: SubMenuComponentName.SettingsVideo, component: markRaw(ConfigurationVideoView) as SubMenuComponent, }, { icon: 'mdi-subtitles-outline', title: 'Telemetry', + titleKey: 'logs', componentName: SubMenuComponentName.SettingsTelemetry, component: markRaw(ConfigurationTelemetryView) as SubMenuComponent, }, { icon: 'mdi-alert-rhombus-outline', title: 'Alerts', + titleKey: 'alerts', componentName: SubMenuComponentName.SettingsAlerts, component: markRaw(ConfigurationAlertsView) as SubMenuComponent, }, { icon: 'mdi-dev-to', title: 'Dev', + titleKey: 'development', componentName: SubMenuComponentName.SettingsDev, component: markRaw(ConfigurationDevelopmentView) as SubMenuComponent, }, { icon: 'mdi-map-marker-path', title: 'Mission', + titleKey: 'mission', componentName: SubMenuComponentName.SettingsMission, component: markRaw(ConfigurationMissionView) as SubMenuComponent, }, { icon: 'mdi-run-fast', title: 'Actions', + titleKey: 'actions', componentName: SubMenuComponentName.SettingsActions, component: markRaw(ConfigurationActionsView) as SubMenuComponent, }, @@ -414,6 +425,7 @@ const configMenu = computed(() => { menusToShow.push({ icon: 'mdi-protocol', title: 'MAVLink', + titleKey: 'mavlink', componentName: SubMenuComponentName.SettingsMAVLink, component: markRaw(ConfigurationMAVLinkView) as SubMenuComponent, }) @@ -426,12 +438,14 @@ const toolsMenu = computed(() => { { icon: 'mdi-protocol', title: 'MAVLink', + titleKey: 'mavlink', componentName: SubMenuComponentName.ToolsMAVLink, component: markRaw(ToolsMAVLinkView) as SubMenuComponent, }, { icon: 'mdi-database-outline', title: 'Data-lake', + titleKey: 'dataLake', componentName: SubMenuComponentName.ToolsDataLake, component: markRaw(ToolsDataLakeView) as SubMenuComponent, }, diff --git a/src/components/MiniWidgetInstantiator.vue b/src/components/MiniWidgetInstantiator.vue index 8a7ce4786e..e2011c51ca 100644 --- a/src/components/MiniWidgetInstantiator.vue +++ b/src/components/MiniWidgetInstantiator.vue @@ -29,6 +29,7 @@ diff --git a/src/components/development/MAVLinkInspectorItem.vue b/src/components/development/MAVLinkInspectorItem.vue index 40072ce166..35f28a1f84 100644 --- a/src/components/development/MAVLinkInspectorItem.vue +++ b/src/components/development/MAVLinkInspectorItem.vue @@ -1,27 +1,35 @@ -