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

i18n the OSD warnings list, ordering it in alphabetical order
10.7.0-preview
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"
},
"osdWarningUnknown": {
"message": "Unknown warning (details to be added in a future release)"
"osdWarningTextArmingDisabled": {
"message": "Arming disabled",
"description": "One of the warnings that can be selected to be shown in the OSD"
},
"osdWarningArmingDisabled": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"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": {
"message": "Enable or disable OSD elements."

View File

@ -1213,66 +1213,82 @@ OSD.constants = {
ALL_WARNINGS: {
ARMING_DISABLED: {
name: 'ARMING_DISABLED',
text: 'osdWarningTextArmingDisabled',
desc: 'osdWarningArmingDisabled'
},
BATTERY_NOT_FULL: {
name: 'BATTERY_NOT_FULL',
text: 'osdWarningTextBatteryNotFull',
desc: 'osdWarningBatteryNotFull'
},
BATTERY_WARNING: {
name: 'BATTERY_WARNING',
text: 'osdWarningTextBatteryWarning',
desc: 'osdWarningBatteryWarning'
},
BATTERY_CRITICAL: {
name: 'BATTERY_CRITICAL',
text: 'osdWarningTextBatteryCritical',
desc: 'osdWarningBatteryCritical'
},
VISUAL_BEEPER: {
name: 'VISUAL_BEEPER',
text: 'osdWarningTextVisualBeeper',
desc: 'osdWarningVisualBeeper'
},
CRASH_FLIP_MODE: {
name: 'CRASH_FLIP_MODE',
text: 'osdWarningTextCrashFlipMode',
desc: 'osdWarningCrashFlipMode'
},
ESC_FAIL: {
name: 'ESC_FAIL',
text: 'osdWarningTextEscFail',
desc: 'osdWarningEscFail'
},
CORE_TEMPERATURE: {
name: 'CORE_TEMPERATURE',
text: 'osdWarningTextCoreTemperature',
desc: 'osdWarningCoreTemperature'
},
RC_SMOOTHING_FAILURE: {
name: 'RC_SMOOTHING_FAILURE',
text: 'osdWarningTextRcSmoothingFailure',
desc: 'osdWarningRcSmoothingFailure'
},
FAILSAFE: {
name: 'FAILSAFE',
text: 'osdWarningTextFailsafe',
desc: 'osdWarningFailsafe'
},
LAUNCH_CONTROL: {
name: 'LAUNCH_CONTROL',
text: 'osdWarningTextLaunchControl',
desc: 'osdWarningLaunchControl'
},
GPS_RESCUE_UNAVAILABLE: {
name: 'GPS_RESCUE_UNAVAILABLE',
text: 'osdWarningTextGpsRescueUnavailable',
desc: 'osdWarningGpsRescueUnavailable'
},
GPS_RESCUE_DISABLED: {
name: 'GPS_RESCUE_DISABLED',
text: 'osdWarningTextGpsRescueDisabled',
desc: 'osdWarningGpsRescueDisabled'
},
RSSI: {
name: 'RSSI',
text: 'osdWarningTextRSSI',
desc: 'osdWarningRSSI'
},
LINK_QUALITY: {
name: 'LINK_QUALITY',
text: 'osdWarningTextLinkQuality',
desc: 'osdWarningLinkQuality'
},
RSSI_DBM: {
name: 'RSSI_DBM',
text: 'osdWarningTextRssiDbm',
desc: 'osdWarningRssiDbm'
},
@ -1827,7 +1843,7 @@ OSD.msp = {
// Push Unknown Warning field
} else {
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'));
$('.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
function updateOsdView() {
// 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) {
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);
}
}
let finalFieldName = titleizeField(field);
$field.append('<label for="' + field.name + '" class="char-label">' + finalFieldName + '</label>');
if (field.positionable && field.isVisible[OSD.getCurrentPreviewProfile()]) {
$field.append(
@ -2406,17 +2449,7 @@ TABS.osd.initialize = function (callback) {
if (field.name == OSD.constants.UNKNOWN_DISPLAY_FIELD.name) {
$displayFields.append($field);
} else {
let added = false;
$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);
}
insertOrdered($displayFields, $field);
}
}