End i18n work of OSD statistics (#1512)

End i18n work of OSD statistics
10.7.0-preview
Michael Keller 2019-07-01 22:22:22 +12:00 committed by GitHub
commit c167f48c73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 20 deletions

View File

@ -4424,12 +4424,21 @@
"osdDescStatTotalFlightDistance": {
"message": "Total distance traveled"
},
"osdTextStatMinRssiDbm": {
"message": "RSSI dBm minimum",
"description": "One of the statistics that can be shown at the end of the flight in the OSD"
},
"osdDescStatMinRssiDbm": {
"message": "Minimum RSSI dBm value"
},
"osdTextStatUnknown": {
"message": "Unknown $1",
"description": "One of the statistics that can be shown at the end of the flight in the OSD"
},
"osdDescStatUnknown": {
"message": "Unknown statistic (details to be added in a future release)"
},
"osdDescribeFontVersion1": {
"message": "Font version: 1 (Betaflight 4.0 or older)"
},

View File

@ -1238,6 +1238,7 @@ OSD.constants = {
},
MIN_RSSI_DBM: {
name: 'MIN_RSSI_DBM',
text: 'osdTextStatMinRssiDbm',
desc: 'osdDescStatMinRssiDbm'
},
},
@ -1842,7 +1843,8 @@ OSD.msp = {
// Read all the data for any statistics we don't know about
} else {
d.stat_items.push({name: 'UNKNOWN', desc: 'osdDescStatUnknown', index: i, enabled: v === 1 });
let statisticNumber = i - OSD.constants.STATISTIC_FIELDS.length + 1;
d.stat_items.push({name: 'UNKNOWN', text: ['osdTextStatUnknown', statisticNumber], desc: 'osdDescStatUnknown', index: i, enabled: v === 1 });
}
}
@ -2114,16 +2116,20 @@ TABS.osd.initialize = function (callback) {
}
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) {
if (field.name == 'UNKNOWN') {
fieldList.append(field);
} else {
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);
}
}
}
@ -2311,6 +2317,7 @@ TABS.osd.initialize = function (callback) {
);
$field.append('<label for="' + field.name + '" class="char-label">' + titleizeField(field) + '</label>');
// Insert in alphabetical order, with unknown fields at the end
insertOrdered($statsFields, $field);
}
@ -2348,11 +2355,8 @@ TABS.osd.initialize = function (callback) {
$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);
}
insertOrdered($warningFields, $field);
}
}
}
@ -2482,11 +2486,8 @@ TABS.osd.initialize = function (callback) {
}
// Insert in alphabetical order, with unknown fields at the end
if (field.name == OSD.constants.UNKNOWN_DISPLAY_FIELD.name) {
$displayFields.append($field);
} else {
insertOrdered($displayFields, $field);
}
insertOrdered($displayFields, $field);
}
GUI.switchery();