Skip to content

Commit

Permalink
i18n: make played for text translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser committed Nov 5, 2023
1 parent 4d51fce commit 40c53e6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
"gameControls_noToolingSet_button_setVersion": "Set Version",
"gameControls_noToolingSet_header": "No Tooling Version Configured!",
"gameControls_noToolingSet_subheader": "Head over to the following settings page to download the latest release",
"gameControls_timePlayed_label": "Played For",
"gameControls_timePlayed_hour": "hour",
"gameControls_timePlayed_hours": "hours",
"gameControls_timePlayed_minute": "minute",
"gameControls_timePlayed_minutes": "minutes",
"gameControls_timePlayed_second": "second",
"gameControls_timePlayed_seconds": "seconds",
"gameJob_applyTexturePacks": "Applying Packs",
"gameJob_deleteTexturePacks": "Deleting Packs",
"gameJob_enablingTexturePacks": "Enabling Packs",
Expand Down
30 changes: 25 additions & 5 deletions src/components/games/GameControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@
// add the hours to the formatted playtime string
if (hours > 0) {
formattedPlaytime += `${hours} hour${hours > 1 ? "s" : ""}`;
if (hours > 1) {
formattedPlaytime += `${hours} ${$_(`gameControls_timePlayed_hours`)}`;
} else {
formattedPlaytime += `${hours} ${$_(`gameControls_timePlayed_hour`)}`;
}
}
// add the minutes to the formatted playtime string
Expand All @@ -67,16 +71,32 @@
if (formattedPlaytime.length > 0) {
formattedPlaytime += ", ";
}
formattedPlaytime += `${minutes} minute${minutes > 1 ? "s" : ""}`;
if (minutes > 1) {
formattedPlaytime += `${minutes} ${$_(
`gameControls_timePlayed_minutes`,
)}`;
} else {
formattedPlaytime += `${minutes} ${$_(
`gameControls_timePlayed_minute`,
)}`;
}
}
// add the seconds to the formatted playtime string
if (seconds > 0) {
// add a comma if there are already hours or minutes in the formatted playtime string
// add a comma if there are already hours in the formatted playtime string
if (formattedPlaytime.length > 0) {
formattedPlaytime += ", ";
}
formattedPlaytime += `${seconds} second${seconds > 1 ? "s" : ""}`;
if (seconds > 1) {
formattedPlaytime += `${seconds} ${$_(
`gameControls_timePlayed_seconds`,
)}`;
} else {
formattedPlaytime += `${seconds} ${$_(
`gameControls_timePlayed_second`,
)}`;
}
}
// return the formatted playtime string
Expand Down Expand Up @@ -104,7 +124,7 @@
</h1>
{#if playtime}
<h1 class="pb-4 text-xl text-outline tracking-tighter font-extrabold">
{`Played For ${playtime}`}
{`${$_(`gameControls_timePlayed_label`)} ${playtime}`}
</h1>
{/if}
<div class="flex flex-row gap-2">
Expand Down

0 comments on commit 40c53e6

Please sign in to comment.