Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Improve the strings that are beeing used in the timeago component
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlurak committed Jan 24, 2024
1 parent 009cf02 commit c9607d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ const de = {
'time.ago.edited.months.1': 'Vor einem Monat bearbeitet',
'time.ago.edited.years': 'Vor time Jahren bearbeitet',
'time.ago.edited.years.1': 'Vor einem Jahr bearbeitet',
'time.ago.absolute.created': 'Am $date um $time erstellt',
'time.ago.absolute.edited': 'Am $date um $time bearbeitet',
events: 'Kalender',
'events.create.success': 'Erfolgreich erstellt',
'events.create.time.start': 'Start',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ const en = {
'time.ago.edited.months.1': 'Edited a Month ago',
'time.ago.edited.years': 'Edited time Years ago',
'time.ago.edited.years.1': 'Edited a Year ago',
'time.ago.absolute.created': 'Created on the $date at $time',
'time.ago.absolute.edited': 'Edited on the $date at $time',
events: 'Calendar',
'events.create.success': 'Successfully created new event',
'events.create.time.start': 'Start',
Expand Down
13 changes: 12 additions & 1 deletion src/lib/dates/TimeAgo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
export let type: 'edited' | 'created' = 'created';
let timeDifference: string = getTimeDifference();
let absoluteString = i(`time.ago.absolute.${type}`, {
time: new Date(timestamp).toLocaleTimeString($currentLanguage),
date: new Date(timestamp).toLocaleDateString($currentLanguage)
});
currentLanguage.subscribe(() => {
absoluteString = i(`time.ago.absolute.${type}`, {
time: new Date(timestamp).toLocaleTimeString($currentLanguage),
date: new Date(timestamp).toLocaleDateString($currentLanguage)
});
});
function getTimeDifference() {
const currentTime = Date.now();
Expand Down Expand Up @@ -60,7 +71,7 @@

<button on:click={() => (fullDate = !fullDate)} class="w-max">
{#if fullDate}
<p class={classes}>{new Date(timestamp).toLocaleString($currentLanguage)}</p>
<p class={classes}>{absoluteString}</p>
{:else}
<!-- It's ok that this isn't in a I18n tag due to the interval-->
<p class={classes}>{timeDifference}</p>
Expand Down

0 comments on commit c9607d4

Please sign in to comment.