Skip to content

Commit a1e01c4

Browse files
fortmarekclaude
andauthored
fix: handle missing region in navigator.language for chart locale (#973)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 228044c commit a1e01c4

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

cli/Sources/Noora/NooraMock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@
471471
}
472472
}
473473

474-
private struct StandardOutputEvent: Equatable, Sendable {
474+
private struct StandardOutputEvent: Equatable {
475475
let type: StandardPipelineType
476476
let content: String
477477
}

web/js/Chart.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function formatBytes(bytes) {
5656
const formatters = {
5757
toLocaleDate: (el) => (value, _) => {
5858
const date = new Date(value);
59-
return date.toLocaleDateString(locale(), {
59+
return date.toLocaleDateString(navigator.language, {
6060
day: "numeric",
6161
month: "short",
6262
});
@@ -82,11 +82,6 @@ const tooltipFormatters = {
8282
formatHours: (value) => formatHours(value, { includeMinutes: true }),
8383
};
8484

85-
function locale() {
86-
const region = (navigator.language || navigator.userLanguage).split("-")[1];
87-
return `en-${region}`;
88-
}
89-
9085
export default {
9186
mounted() {
9287
this.render();
@@ -343,23 +338,23 @@ function tooltipFormatter(options = {}) {
343338
if (!Number.isNaN(Date.parse(title))) {
344339
const date = new Date(title);
345340
if (options.dateFormat == "minute") {
346-
title = date.toLocaleDateString(locale(), {
341+
title = date.toLocaleDateString(navigator.language, {
347342
day: "numeric",
348343
month: "short",
349344
year: "numeric",
350345
hour: "numeric",
351346
minute: "numeric",
352347
});
353348
} else if (options.dateFormat == "hour") {
354-
const dateStr = date.toLocaleDateString(locale(), {
349+
const dateStr = date.toLocaleDateString(navigator.language, {
355350
day: "numeric",
356351
month: "short",
357352
year: "numeric",
358353
});
359354
const hour = String(date.getHours()).padStart(2, "0");
360355
title = `${dateStr}, ${hour}:00`;
361356
} else {
362-
title = date.toLocaleDateString(locale(), {
357+
title = date.toLocaleDateString(navigator.language, {
363358
day: "numeric",
364359
month: "short",
365360
year: "numeric",

0 commit comments

Comments
 (0)