diff --git a/src/components/mixins/base.ts b/src/components/mixins/base.ts index 69902e850..8bc9ce571 100644 --- a/src/components/mixins/base.ts +++ b/src/components/mixins/base.ts @@ -175,13 +175,13 @@ export default class BaseMixin extends Vue { } get browserLocale() { - return navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language + return navigator.language } get hours12Format() { const setting = this.$store.state.gui.general.timeFormat if (setting === '12hours') return true - if (setting === null && this.browserLocale === 'en_us') return true + if (setting === null && this.browserLocale === 'en-US') return true return false } diff --git a/src/components/panels/HistoryListPanel.vue b/src/components/panels/HistoryListPanel.vue index 40776039b..4b41adfa1 100644 --- a/src/components/panels/HistoryListPanel.vue +++ b/src/components/panels/HistoryListPanel.vue @@ -962,7 +962,7 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { } exportHistory() { - const checkString = parseFloat('1.23').toLocaleString() + const checkString = parseFloat('1.23').toLocaleString(this.browserLocale) const decimalSeparator = checkString.indexOf(',') >= 0 ? ',' : '.' const csvSeperator = decimalSeparator === ',' ? ';' : ',' @@ -1011,7 +1011,14 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { }) } - const csvContent = 'data:text/csv;charset=utf-8,' + content.map((e) => e.join(csvSeperator)).join('\n') + // escape fields with the csvSeperator in the content + // prettier-ignore + const csvContent = + 'data:text/csv;charset=utf-8,' + + content.map((entry) => + entry.map((field) => (field.indexOf(csvSeperator) === -1 ? field : `"${field}"`)).join(csvSeperator) + ).join('\n') + const link = document.createElement('a') link.setAttribute('href', encodeURI(csvContent)) link.setAttribute('download', 'print_history.csv') @@ -1044,7 +1051,7 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { default: switch (typeof value) { case 'number': - return value?.toLocaleString(undefined, { useGrouping: false }) ?? 0 + return value?.toLocaleString(this.browserLocale, { useGrouping: false }) ?? 0 case 'string': if (escapeChar !== null && value.includes(escapeChar)) value = '"' + value + '"'