Added compact translations for date duration

This commit is contained in:
Alexis
2024-09-05 21:16:24 +02:00
parent f42a68dfc9
commit 11d900e7f7
4 changed files with 37 additions and 6 deletions

View File

@@ -496,12 +496,24 @@ export const useCalendar = defineStore("calendar", () => {
years: "xYearsNext",
yearsAndMonths: "xYearsAndMonthsNext",
}
const futureKeysCompact: DateDirectionTranslationKeys = {
days: "xDaysNextCompact",
months: "xMonthsNextCompact",
years: "xYearsNextCompact",
yearsAndMonths: "xYearsAndMonthsNextCompact",
}
const pastKeys: DateDirectionTranslationKeys = {
days: "xDaysAgo",
months: "xMonthsAgo",
years: "xYearsAgo",
yearsAndMonths: "xYearsAndMonthsAgo",
}
const pastKeysCompact: DateDirectionTranslationKeys = {
days: "xDaysAgoCompact",
months: "xMonthsAgoCompact",
years: "xYearsAgoCompact",
yearsAndMonths: "xYearsAndMonthsAgoCompact",
}
let directionKeys: DateDirectionTranslationKeys = pastKeys
// Check whether it's a past or future date
@@ -535,6 +547,13 @@ export const useCalendar = defineStore("calendar", () => {
} else {
directionKeys = pastKeys
}
} else {
// Get relevant prefix for the string (without the prefix)
if (direction === "future") {
directionKeys = futureKeysCompact
} else {
directionKeys = pastKeysCompact
}
}
const isSameMonth = baseDate.month === relativeDate.month