1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-26 09:45:28 +03:00

i18n the OSD warnings list, ordering it in alphabetical order (#1497)

i18n the OSD warnings list, ordering it in alphabetical order
This commit is contained in:
Michael Keller 2019-06-18 00:13:54 +12:00 committed by GitHub
commit 7f452d9c96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 124 additions and 24 deletions

View file

@ -4394,57 +4394,124 @@
"description": "Text of the altitude alarm" "description": "Text of the altitude alarm"
}, },
"osdWarningUnknown": { "osdWarningTextArmingDisabled": {
"message": "Unknown warning (details to be added in a future release)" "message": "Arming disabled",
"description": "One of the warnings that can be selected to be shown in the OSD"
}, },
"osdWarningArmingDisabled": { "osdWarningArmingDisabled": {
"message": "Reports the most severe reason for not arming" "message": "Reports the most severe reason for not arming"
}, },
"osdWarningTextBatteryNotFull": {
"message": "Battery not full",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningBatteryNotFull": { "osdWarningBatteryNotFull": {
"message": "Alerts when a battery is connected that is not fully charged" "message": "Alerts when a battery is connected that is not fully charged"
}, },
"osdWarningTextBatteryWarning": {
"message": "Battery warning",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningBatteryWarning": { "osdWarningBatteryWarning": {
"message": "Alerts when the battery voltage falls below warning threshold" "message": "Alerts when the battery voltage falls below warning threshold"
}, },
"osdWarningTextBatteryCritical": {
"message": "Battery critical",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningBatteryCritical": { "osdWarningBatteryCritical": {
"message": "Alerts when the battery voltage falls below the minimum average cell voltage" "message": "Alerts when the battery voltage falls below the minimum average cell voltage"
}, },
"osdWarningTextVisualBeeper": {
"message": "Visual beeper",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningVisualBeeper": { "osdWarningVisualBeeper": {
"message": "Shows a visualisation of the beeper (shows as 4 asterisks)" "message": "Shows a visualisation of the beeper (shows as 4 asterisks)"
}, },
"osdWarningTextCrashFlipMode": {
"message": "Crash flip mode",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningCrashFlipMode": { "osdWarningCrashFlipMode": {
"message": "Warns when flip over after crash mode is activated" "message": "Warns when flip over after crash mode is activated"
}, },
"osdWarningTextEscFail": {
"message": "ESC fail",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningEscFail": { "osdWarningEscFail": {
"message": "Enumerates a list with the ESCs/motors that are failing (RPM or temperature are out of the configured threshold)" "message": "Enumerates a list with the ESCs/motors that are failing (RPM or temperature are out of the configured threshold)"
}, },
"osdWarningTextCoreTemperature": {
"message": "Core temperature",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningCoreTemperature": { "osdWarningCoreTemperature": {
"message": "Warns when MCU core temperature exceeds a configured threshold" "message": "Warns when MCU core temperature exceeds a configured threshold"
}, },
"osdWarningTextRcSmoothingFailure": {
"message": "RC Smoothing failure",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningRcSmoothingFailure": { "osdWarningRcSmoothingFailure": {
"message": "Warns when RC Smoothing initialization failed" "message": "Warns when RC Smoothing initialization failed"
}, },
"osdWarningTextFailsafe": {
"message": "Failsafe",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningFailsafe": { "osdWarningFailsafe": {
"message": "Warns when failsafe occurs" "message": "Warns when failsafe occurs"
}, },
"osdWarningTextLaunchControl": {
"message": "Launch control",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningLaunchControl": { "osdWarningLaunchControl": {
"message": "Warns when Launch Control mode is activated" "message": "Warns when Launch Control mode is activated"
}, },
"osdWarningTextGpsRescueUnavailable": {
"message": "GPS Rescue unavailable",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningGpsRescueUnavailable": { "osdWarningGpsRescueUnavailable": {
"message": "Warns when GPS Rescue is not available and cannot be activated" "message": "Warns when GPS Rescue is not available and cannot be activated"
}, },
"osdWarningTextGpsRescueDisabled": {
"message": "GPS Rescue disabled",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningGpsRescueDisabled": { "osdWarningGpsRescueDisabled": {
"message": "Warns when GPS Rescue is disabled" "message": "Warns when GPS Rescue is disabled"
}, },
"osdWarningTextRSSI": {
"message": "RSSI",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningRSSI": { "osdWarningRSSI": {
"message": "Warns when RSSI is below alarm setting" "message": "Warns when RSSI is below alarm setting"
}, },
"osdWarningTextLinkQuality": {
"message": "Link quality",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningLinkQuality": { "osdWarningLinkQuality": {
"message": "Warns when Link Quality is below alarm setting" "message": "Warns when Link Quality is below alarm setting"
}, },
"osdWarningTextRssiDbm": {
"message": "RSSI dBm",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningRssiDbm": { "osdWarningRssiDbm": {
"message": "Warns when RSSI dBm value is below alarm setting" "message": "Warns when RSSI dBm value is below alarm setting"
}, },
"osdWarningTextUnknown": {
"message": "Unknown $1"
},
"osdWarningUnknown": {
"message": "Unknown warning (details to be added in a future release)"
},
"osdSectionHelpElements": { "osdSectionHelpElements": {
"message": "Enable or disable OSD elements." "message": "Enable or disable OSD elements."

View file

@ -1213,66 +1213,82 @@ OSD.constants = {
ALL_WARNINGS: { ALL_WARNINGS: {
ARMING_DISABLED: { ARMING_DISABLED: {
name: 'ARMING_DISABLED', name: 'ARMING_DISABLED',
text: 'osdWarningTextArmingDisabled',
desc: 'osdWarningArmingDisabled' desc: 'osdWarningArmingDisabled'
}, },
BATTERY_NOT_FULL: { BATTERY_NOT_FULL: {
name: 'BATTERY_NOT_FULL', name: 'BATTERY_NOT_FULL',
text: 'osdWarningTextBatteryNotFull',
desc: 'osdWarningBatteryNotFull' desc: 'osdWarningBatteryNotFull'
}, },
BATTERY_WARNING: { BATTERY_WARNING: {
name: 'BATTERY_WARNING', name: 'BATTERY_WARNING',
text: 'osdWarningTextBatteryWarning',
desc: 'osdWarningBatteryWarning' desc: 'osdWarningBatteryWarning'
}, },
BATTERY_CRITICAL: { BATTERY_CRITICAL: {
name: 'BATTERY_CRITICAL', name: 'BATTERY_CRITICAL',
text: 'osdWarningTextBatteryCritical',
desc: 'osdWarningBatteryCritical' desc: 'osdWarningBatteryCritical'
}, },
VISUAL_BEEPER: { VISUAL_BEEPER: {
name: 'VISUAL_BEEPER', name: 'VISUAL_BEEPER',
text: 'osdWarningTextVisualBeeper',
desc: 'osdWarningVisualBeeper' desc: 'osdWarningVisualBeeper'
}, },
CRASH_FLIP_MODE: { CRASH_FLIP_MODE: {
name: 'CRASH_FLIP_MODE', name: 'CRASH_FLIP_MODE',
text: 'osdWarningTextCrashFlipMode',
desc: 'osdWarningCrashFlipMode' desc: 'osdWarningCrashFlipMode'
}, },
ESC_FAIL: { ESC_FAIL: {
name: 'ESC_FAIL', name: 'ESC_FAIL',
text: 'osdWarningTextEscFail',
desc: 'osdWarningEscFail' desc: 'osdWarningEscFail'
}, },
CORE_TEMPERATURE: { CORE_TEMPERATURE: {
name: 'CORE_TEMPERATURE', name: 'CORE_TEMPERATURE',
text: 'osdWarningTextCoreTemperature',
desc: 'osdWarningCoreTemperature' desc: 'osdWarningCoreTemperature'
}, },
RC_SMOOTHING_FAILURE: { RC_SMOOTHING_FAILURE: {
name: 'RC_SMOOTHING_FAILURE', name: 'RC_SMOOTHING_FAILURE',
text: 'osdWarningTextRcSmoothingFailure',
desc: 'osdWarningRcSmoothingFailure' desc: 'osdWarningRcSmoothingFailure'
}, },
FAILSAFE: { FAILSAFE: {
name: 'FAILSAFE', name: 'FAILSAFE',
text: 'osdWarningTextFailsafe',
desc: 'osdWarningFailsafe' desc: 'osdWarningFailsafe'
}, },
LAUNCH_CONTROL: { LAUNCH_CONTROL: {
name: 'LAUNCH_CONTROL', name: 'LAUNCH_CONTROL',
text: 'osdWarningTextLaunchControl',
desc: 'osdWarningLaunchControl' desc: 'osdWarningLaunchControl'
}, },
GPS_RESCUE_UNAVAILABLE: { GPS_RESCUE_UNAVAILABLE: {
name: 'GPS_RESCUE_UNAVAILABLE', name: 'GPS_RESCUE_UNAVAILABLE',
text: 'osdWarningTextGpsRescueUnavailable',
desc: 'osdWarningGpsRescueUnavailable' desc: 'osdWarningGpsRescueUnavailable'
}, },
GPS_RESCUE_DISABLED: { GPS_RESCUE_DISABLED: {
name: 'GPS_RESCUE_DISABLED', name: 'GPS_RESCUE_DISABLED',
text: 'osdWarningTextGpsRescueDisabled',
desc: 'osdWarningGpsRescueDisabled' desc: 'osdWarningGpsRescueDisabled'
}, },
RSSI: { RSSI: {
name: 'RSSI', name: 'RSSI',
text: 'osdWarningTextRSSI',
desc: 'osdWarningRSSI' desc: 'osdWarningRSSI'
}, },
LINK_QUALITY: { LINK_QUALITY: {
name: 'LINK_QUALITY', name: 'LINK_QUALITY',
text: 'osdWarningTextLinkQuality',
desc: 'osdWarningLinkQuality' desc: 'osdWarningLinkQuality'
}, },
RSSI_DBM: { RSSI_DBM: {
name: 'RSSI_DBM', name: 'RSSI_DBM',
text: 'osdWarningTextRssiDbm',
desc: 'osdWarningRssiDbm' desc: 'osdWarningRssiDbm'
}, },
@ -1827,7 +1843,7 @@ OSD.msp = {
// Push Unknown Warning field // Push Unknown Warning field
} else { } else {
var warningNumber = i - OSD.constants.WARNINGS.length + 1; var warningNumber = i - OSD.constants.WARNINGS.length + 1;
d.warnings.push({name: 'UNKNOWN_' + warningNumber, desc: 'osdWarningUnknown', enabled: (warningFlags & (1 << i)) != 0 }); d.warnings.push({name: 'UNKNOWN', text: ['osdWarningTextUnknown', warningNumber], desc: 'osdWarningUnknown', enabled: (warningFlags & (1 << i)) != 0 });
} }
} }
@ -2049,6 +2065,32 @@ TABS.osd.initialize = function (callback) {
$('.stats-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpStats')); $('.stats-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpStats'));
$('.warnings-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpWarnings')); $('.warnings-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpWarnings'));
function titleizeField(field) {
let finalFieldName = inflection.titleize(field.name);
if (field.text) {
if (Array.isArray(field.text) && i18n.existsMessage(field.text[0])) {
finalFieldName = i18n.getMessage(field.text[0], field.text.slice(1));
} else if (i18n.existsMessage(field.text)) {
finalFieldName = i18n.getMessage(field.text);
}
}
return finalFieldName;
}
function insertOrdered(fieldList, field) {
let added = false;
fieldList.children().each(function() {
if ($(this).text().localeCompare(field.text(), i18n.getCurrentLocale(), { sensitivity: 'base' }) > 0) {
$(this).before(field);
added = true;
return false;
}
});
if(!added) {
fieldList.append(field);
}
}
// 2 way binding... sorta // 2 way binding... sorta
function updateOsdView() { function updateOsdView() {
// ask for the OSD config data // ask for the OSD config data
@ -2265,9 +2307,16 @@ TABS.osd.initialize = function (callback) {
}); });
}) })
); );
$field.append('<label for="' + field.name + '" class="char-label">' + inflection.titleize(field.name) + '</label>');
$warningFields.append($field); let finalFieldName = titleizeField(field);
$field.append('<label for="' + field.name + '" class="char-label">' + finalFieldName + '</label>');
// Insert in alphabetical order, with unknown fields at the end
if (field.name == 'UNKNOWN') {
$warningFields.append($field);
} else {
insertOrdered($warningFields, $field);
}
} }
} }
} }
@ -2376,14 +2425,8 @@ TABS.osd.initialize = function (callback) {
}) })
); );
} }
let finalFieldName = inflection.titleize(field.name);
if (field.text) { let finalFieldName = titleizeField(field);
if (Array.isArray(field.text) && i18n.existsMessage(field.text[0])) {
finalFieldName = i18n.getMessage(field.text[0], field.text.slice(1));
} else if (i18n.existsMessage(field.text)) {
finalFieldName = i18n.getMessage(field.text);
}
}
$field.append('<label for="' + field.name + '" class="char-label">' + finalFieldName + '</label>'); $field.append('<label for="' + field.name + '" class="char-label">' + finalFieldName + '</label>');
if (field.positionable && field.isVisible[OSD.getCurrentPreviewProfile()]) { if (field.positionable && field.isVisible[OSD.getCurrentPreviewProfile()]) {
$field.append( $field.append(
@ -2406,17 +2449,7 @@ TABS.osd.initialize = function (callback) {
if (field.name == OSD.constants.UNKNOWN_DISPLAY_FIELD.name) { if (field.name == OSD.constants.UNKNOWN_DISPLAY_FIELD.name) {
$displayFields.append($field); $displayFields.append($field);
} else { } else {
let added = false; insertOrdered($displayFields, $field);
$displayFields.children().each(function() {
if ($(this).text().localeCompare($field.text(), i18n.getCurrentLocale(), { sensitivity: 'base' }) > 0) {
$(this).before($field);
added = true;
return false;
}
});
if(!added) {
$displayFields.append($field);
}
} }
} }