Skip to content

Commit

Permalink
✨ Date formats in i18n configuration
Browse files Browse the repository at this point in the history
Merge pull request #549 from olibrian/olibrian-i18n_dateformat
  • Loading branch information
AnandChowdhary authored Jun 29, 2024
2 parents 03c78f3 + e1fdd5d commit bdf7fcd
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ duration7D: 7d
duration30D: 30d
duration1Y: 1y
durationAll: all
locale: en-US
2 changes: 1 addition & 1 deletion src/components/ActiveIncidents.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<h4>{incident.title.replace("🛑", "").replace("⚠️", "").trim()}</h4>
<div>
{config.i18n.activeIncidentSummary
.replace(/\$DATE/g, new Date(incident.created_at).toLocaleString())
.replace(/\$DATE/g, new Date(incident.created_at).toLocaleString(config.i18n.locale))
.replace(/\$POSTS/g, incident.comments)}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ActiveScheduled.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
? config.i18n.scheduledMaintenanceSummaryStarted
: config.i18n.scheduledMaintenanceSummaryStarts
)
.replace(/\$DATE/g, new Date(incident.metadata.start).toLocaleString())
.replace(/\$DATE/g, new Date(incident.metadata.start).toLocaleString(config.i18n.locale))
.replace(
/\$DURATION/g,
Math.floor(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Graph.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
.map((commit) => parseInt(commit.commit.message.split(" in ")[1].split("ms")[0]));
labels = commits
.filter((commit) => commit.commit.message.includes("ms) [skip ci]"))
.map((commit) => new Date(commit.commit.committer.date).toLocaleString());
.map((commit) => new Date(commit.commit.committer.date).toLocaleString(config.i18n.locale));
loading = false;
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/components/History.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<h2>{config.i18n.pastIncidents}</h2>
{#each incidents as incident}
{#if incident.showHeading}
<h3>{new Date(incident.created_at).toLocaleDateString()}</h3>
<h3>{new Date(incident.created_at).toLocaleDateString(config.i18n.locale)}</h3>
{/if}
<article class="down link {incident.title.includes('degraded') ? 'degraded' : ''}">
<div class="f">
Expand Down
8 changes: 4 additions & 4 deletions src/components/Incident.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@
? config.i18n.startedAt
: config.i18n.startsAt}
</dt>
<dd>{new Date(incident.metadata.start).toLocaleString()}</dd>
<dd>{new Date(incident.metadata.start).toLocaleString(config.i18n.locale)}</dd>
{:else}
<dt>{config.i18n.incidentOpenedAt}</dt>
<dd>{new Date(incident.created_at).toLocaleString()}</dd>
<dd>{new Date(incident.created_at).toLocaleString(config.i18n.locale)}</dd>
{/if}
{#if incident.metadata.start && incident.metadata.end}
<dt>{config.i18n.duration}</dt>
Expand All @@ -114,7 +114,7 @@
</dd>
{:else if incident.closed_at}
<dt>{config.i18n.incidentClosedAt}</dt>
<dd>{new Date(incident.closed_at).toLocaleString()}</dd>
<dd>{new Date(incident.closed_at).toLocaleString(config.i18n.locale)}</dd>
{/if}
</dl>
<div class="r">
Expand All @@ -134,7 +134,7 @@
{@html config.i18n.incidentCommentSummary
.replace(
/\$DATE/g,
`<a href=${comment.html_url}>${new Date(comment.created_at).toLocaleString()}</a>`
`<a href=${comment.html_url}>${new Date(comment.created_at).toLocaleString(config.i18n.locale)}</a>`
)
.replace(/\$AUTHOR/g, `<a href=${comment.user.html_url}>@${comment.user.login}</a>`)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Incidents.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<h2>{config.i18n.pastIncidents}</h2>
{#each incidents as incident}
{#if incident.showHeading}
<h3>{new Date(incident.created_at).toLocaleDateString()}</h3>
<h3>{new Date(incident.created_at).toLocaleDateString(config.i18n.locale)}</h3>
{/if}
<article class="down link {incident.title.includes('degraded') ? 'degraded' : ''}">
<div class="f">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Scheduled.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<h2>{config.i18n.pastScheduledMaintenance}</h2>
{#each incidents as incident}
{#if incident.showHeading}
<h3>{new Date(incident.created_at).toLocaleDateString()}</h3>
<h3>{new Date(incident.created_at).toLocaleDateString(config.i18n.locale)}</h3>
{/if}
<article class="link degraded">
<div class="f">
Expand Down

0 comments on commit bdf7fcd

Please sign in to comment.