Skip to content

Commit

Permalink
feat: Refactor vue components to use i18n (betaflight#3560)
Browse files Browse the repository at this point in the history
  • Loading branch information
lipskij authored and chmelevskij committed Sep 11, 2023
1 parent fb03f97 commit 5377bf5
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 79 deletions.
8 changes: 4 additions & 4 deletions src/components/data-flash/DataFlash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="data-flash">
<div
v-if="!supportDataflash"
class="noflash_global i18n-replaced"
class="noflash_global"
>
No dataflash <br>chip found
{{ $t("sensorDataFlashNotFound") }}
</div>
<div
v-if="supportDataflash"
Expand All @@ -16,8 +16,8 @@
width: indicatorWidth,
}"
>
<span class="i18n-replaced">
Dataflash: free
<span>
{{ $t("sensorDataFlashFreeSpace") }}
{{ freeSpace }}
</span>
</div>
Expand Down
44 changes: 21 additions & 23 deletions src/components/port-picker/FirmwareVirtualOption.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
<template>
<div
id="firmware-virtual-option"
style="display: block"
:style="{ display: isVirtual ? 'block' : 'none' }"
>
<div class="dropdown dropdown-dark">
<select
id="firmware-version-dropdown"
i18n_title="virtualMSPVersion"
class="dropdown-select i18n_title-replaced"
title="Virtual Firmware Version"
class="dropdown-select"
:title="$t('virtualMSPVersion')"
>
<option value="1.46.0">
MSP: 1.46 | Firmware: 4.5.*
</option>
<option value="1.45.0">
MSP: 1.45 | Firmware: 4.4.*
</option>
<option value="1.44.0">
MSP: 1.44 | Firmware: 4.3.*
</option>
<option value="1.43.0">
MSP: 1.43 | Firmware: 4.2.*
</option>
<option value="1.42.0">
MSP: 1.42 | Firmware: 4.1.*
</option>
<option value="1.41.0">
MSP: 1.41 | Firmware: 4.0.*
<option
v-for="(version, index) in firmwareVersions"
:key="index"
:value="version.value"
>
{{ version.label }}
</option>
</select>
</div>
Expand All @@ -42,6 +28,18 @@ export default {
default: true,
},
},
data() {
return {
firmwareVersions: [
{ value: "1.46.0", label: "MSP: 1.46 | Firmware: 4.5.*" },
{ value: "1.45.0", label: "MSP: 1.45 | Firmware: 4.4.*" },
{ value: "1.44.0", label: "MSP: 1.44 | Firmware: 4.3.*" },
{ value: "1.43.0", label: "MSP: 1.43 | Firmware: 4.2.*" },
{ value: "1.42.0", label: "MSP: 1.42 | Firmware: 4.1.*" },
{ value: "1.41.0", label: "MSP: 1.41 | Firmware: 4.0.*" },
],
};
},
};
</script>

Expand Down Expand Up @@ -128,7 +126,7 @@ export default {
border: 0;
border-radius: 0;
-webkit-appearance: none;
appearance: 'none';
appearance: "none";
}
.dropdown-select:focus {
Expand Down
5 changes: 1 addition & 4 deletions src/components/port-picker/PortOverrideOption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
>
<label
for="port-override"
><span
i18n="portOverrideText"
class="i18n-replaced"
>Port:</span>
><span>{{ $t("portOverrideText") }}</span>
<input
id="port-override"
type="text"
Expand Down
10 changes: 4 additions & 6 deletions src/components/port-picker/PortsInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
<div class="dropdown dropdown-dark">
<select
id="port"
i18n_title="firmwareFlasherManualPort"
class="dropdown-select i18n_title-replaced"
title="Port"
class="dropdown-select"
:title="$t('firmwareFlasherManualPort')"
>
<option value="virtual">
{{ $t("portsSelectVirtual") }}
Expand Down Expand Up @@ -56,9 +55,8 @@
<select
id="baud"
v-model="selectedBaudRate"
i18n_title="firmwareFlasherBaudRate"
class="dropdown-select i18n_title-replaced"
title="Baud Rate"
class="dropdown-select"
:title="$t('firmwareFlasherBaudRate')"
:disabled="isAutoConnect"
>
<option
Expand Down
12 changes: 6 additions & 6 deletions src/components/quad-status/BottomStatusIcons.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<template>
<div class="bottomStatusIcons">
<div
i18n_title="mainHelpArmed"
class="armedicon cf_tip i18n_title-replaced"
class="armedicon cf_tip"
:title="$t('mainHelpArmed')"
:class="{ active: setActiveArmed }"
/>
<div
i18n_title="mainHelpFailsafe"
class="failsafeicon cf_tip i18n_title-replaced"
class="failsafeicon cf_tip"
:title="$t('mainHelpFailsafe')"
:class="{ active: setFailsafeActive }"
/>
<div
i18n_title="mainHelpLink"
class="linkicon cf_tip i18n_title-replaced"
class="linkicon cf_tip"
:title="$t('mainHelpLink')"
:class="{ active: setActiveLink }"
/>
</div>
Expand Down
60 changes: 24 additions & 36 deletions src/components/sensor-status/SensorStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,90 +6,78 @@
>
<ul>
<li
i18n_title="sensorStatusGyro"
class="gyro i18n_title-replaced"
title="Gyroscope"
class="gyro"
:title="$t('sensorStatusGyro')"
:class="{ on: setGyroActive }"
>
<div
i18n="sensorStatusGyroShort"
class="gyroicon i18n-replaced"
class="gyroicon"
:class="{ active: setGyroActive }"
>
Gyro
{{ $t('sensorStatusGyroShort') }}
</div>
</li>
<li
i18n_title="sensorStatusAccel"
class="accel i18n_title-replaced"
title="Accelerometer"
class="accel"
:title="$t('sensorStatusAccel')"
:class="{ on: setAccActive }"
>
<div
i18n="sensorStatusAccelShort"
class="accicon i18n-replaced"
class="accicon"
:class="{ active: setAccActive }"
>
Accel
{{ $t('sensorStatusAccelShort') }}
</div>
</li>
<li
i18n_title="sensorStatusMag"
class="mag i18n_title-replaced"
title="Magnetometer"
class="mag"
:title="$t('sensorStatusMag')"
:class="{ on: setMagActive }"
>
<div
i18n="sensorStatusMagShort"
class="magicon i18n-replaced"
class="magicon"
:class="{ active: setMagActive }"
>
Mag
{{ $t('sensorStatusMagShort') }}
</div>
</li>
<li
i18n_title="sensorStatusBaro"
class="baro i18n_title-replaced"
title="Barometer"
class="baro"
:title="$t('sensorStatusBaro')"
:class="{ on: setBaroActive }"
>
<div
i18n="sensorStatusBaroShort"
class="baroicon i18n-replaced"
class="baroicon"
:class="{ active: setBaroActive }"
>
Baro
{{ $t('sensorStatusBaroShort') }}
</div>
</li>
<li
i18n_title="sensorStatusGPS"
class="gps i18n_title-replaced"
class="gps"
:class="{ on: setGpsActive }"
title="GPS"
:title="$t('sensorStatusGPS')"
>
<div
i18n="sensorStatusGPSShort"
class="gpsicon i18n-replaced"
class="gpsicon"
:class="{
active: setGpsFixState && setGpsActive,
active_fix: !setGpsFixState && setGpsActive,
}"
>
GPS
{{ $t('sensorStatusGPSShort') }}
</div>
</li>
<li
i18n_title="sensorStatusSonar"
class="sonar i18n_title-replaced"
title="Sonar / Range finder"
class="sonar"
:title="$t('sensorStatusSonar')"
:class="{ on: setSonarActive }"
>
<div
i18n="sensorStatusSonarShort"
class="sonaricon i18n-replaced"
class="sonaricon"
:class="{ active: setSonarActive }"
>
Sonar
{{ $t('sensorStatusSonarShort') }}
</div>
</li>
</ul>
Expand Down

0 comments on commit 5377bf5

Please sign in to comment.