fix(#543): capitalise month and day names at the start of titles and labels

This commit is contained in:
makiolaj committed 2026-11-25 20:43:27 +01:00
1 parent d29faf336f
commit 6e2260134a
20 files changed
+44 -22

No files matched your search

@@ -14,6 +14,7 @@ import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs
import de.jeanlucmakiola.calendula.data.prefs.is24Hour
import de.jeanlucmakiola.calendula.data.prefs.resolveFirstDay
import de.jeanlucmakiola.calendula.domain.reminders.ReminderEventInstance
import de.jeanlucmakiola.floret.locale.capitalizeStart
import kotlinx.coroutines.flow.first
import kotlinx.datetime.isoDayNumber
import kotlinx.datetime.toKotlinLocalDate
@@ -62,7 +63,7 @@ class DailyDigestNotifier @Inject constructor(
today -> context.getString(R.string.digest_day_relative, context.getString(R.string.reminder_day_today), date)
today.plusDays(1) ->
context.getString(R.string.digest_day_relative, context.getString(R.string.reminder_day_tomorrow), date)
else -> date
else -> date.capitalizeStart(locale)
}
val allDay = context.getString(R.string.event_detail_all_day)
val lines = listed.map { entry ->
@@ -2,6 +2,7 @@ package de.jeanlucmakiola.calendula.data.reminders
import de.jeanlucmakiola.calendula.domain.runsMidnightToMidnight
import de.jeanlucmakiola.calendula.ui.common.timeOfDayFormatter
import de.jeanlucmakiola.floret.locale.capitalizeStart
import java.time.DayOfWeek
import java.time.Instant
import java.time.LocalDate
@@ -121,7 +122,7 @@ private fun relativeDayPrefix(
1L -> tomorrowLabel
-1L -> yesterdayLabel
else -> if (isSameWeek(day, today, firstDayOfWeek)) {
day.dayOfWeek.getDisplayName(TextStyle.SHORT, locale)
day.dayOfWeek.getDisplayName(TextStyle.SHORT, locale).capitalizeStart(locale)
} else {
dateFormat.format(day)
}
@@ -1,5 +1,6 @@
package de.jeanlucmakiola.calendula.ui.agenda
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.DayOfWeek
import kotlinx.datetime.LocalDate
@@ -113,7 +114,7 @@ fun agendaRangeWindowSummary(
return when {
range == AgendaRange.Day -> dayMonthYear.format(javaStart)
range == AgendaRange.ThisMonth && !monthAsSpan ->
localizedDateFormatter(locale, "LLLLy").format(javaStart)
localizedDateFormatter(locale, "LLLLy").format(javaStart).capitalizeStart(locale)
else -> {
val startFmt = if (start.year == end.year) dayMonth else dayMonthYear
"${startFmt.format(javaStart)} – ${dayMonthYear.format(javaEnd)}"
@@ -46,6 +46,7 @@ import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.positionOf
import de.jeanlucmakiola.floret.identity.LocalFloretDarkTheme
import de.jeanlucmakiola.floret.identity.animateItemMotion
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.DateTimeUnit
@@ -212,7 +213,7 @@ private fun formatAgendaDate(date: LocalDate): String {
val java = date.toJavaLocalDate()
// Weekday + date in the locale's own field order (e.g. "Wed, Jun 17, 2026"
// vs "Mi., 17. Juni 2026") rather than a hardcoded day-month-year layout.
return localizedDateFormatter(locale, "EEEdMMMy").format(java)
return localizedDateFormatter(locale, "EEEdMMMy").format(java).capitalizeStart(locale)
}
/**
@@ -1,5 +1,6 @@
package de.jeanlucmakiola.calendula.ui.common
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import java.util.Locale
@@ -30,5 +31,5 @@ fun formatCalendarTitle(
forceYear: Boolean = false,
): String {
val fields = if (date.year == currentYear && !forceYear) skeleton else skeleton + "y"
return localizedDateFormatter(locale, fields).format(date)
return localizedDateFormatter(locale, fields).format(date).capitalizeStart(locale)
}
@@ -18,6 +18,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import de.jeanlucmakiola.calendula.R
import de.jeanlucmakiola.calendula.domain.EventInstance
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import java.time.ZoneId
@@ -89,7 +90,7 @@ private fun formatSelectionWhen(event: EventInstance, use24Hour: Boolean, locale
val endsSameDay = end.toLocalDate() == start.toLocalDate() ||
(end.toLocalTime().toSecondOfDay() == 0 && end.toLocalDate() == start.toLocalDate().plusDays(1))
return if (endsSameDay) {
"${day.format(start)} · ${time.format(start)}–${time.format(end)}"
"${day.format(start).capitalizeStart(locale)} · ${time.format(start)}–${time.format(end)}"
} else {
"${day.format(start)}, ${time.format(start)} – ${day.format(end)}, ${time.format(end)}"
}
@@ -104,6 +104,7 @@ import de.jeanlucmakiola.calendula.ui.common.rememberFieldCopier
import de.jeanlucmakiola.calendula.ui.common.icuTimeZoneRegion
import de.jeanlucmakiola.calendula.ui.common.LocalSoftenColors
import de.jeanlucmakiola.calendula.ui.common.eventAccent
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.calendula.ui.common.LocalUse24HourFormat
import de.jeanlucmakiola.calendula.ui.common.timeOfDayFormatter
@@ -849,7 +850,7 @@ private fun formatWhen(
val startDate = instance.start.toJavaLocalDateTime(utc).toLocalDate()
val lastDate = (instance.end - 1.seconds).toJavaLocalDateTime(utc).toLocalDate()
return if (startDate == lastDate) {
allDayLabel to dateFull.format(startDate)
allDayLabel to dateFull.format(startDate).capitalizeStart(locale)
} else {
allDayLabel to "${dateMedium.format(startDate)} – ${dateMedium.format(lastDate)}"
}
@@ -859,7 +860,7 @@ private fun formatWhen(
val startTime = withRepeatedHourZone(timeShort.format(startLdt), instance.start, zone, locale)
val endTime = withRepeatedHourZone(timeShort.format(endLdt), instance.end, zone, locale)
return if (startLdt.toLocalDate() == endLdt.toLocalDate()) {
dateFull.format(startLdt.toLocalDate()) to "$startTime – $endTime"
dateFull.format(startLdt.toLocalDate()).capitalizeStart(locale) to "$startTime – $endTime"
} else {
val start = "${dateMedium.format(startLdt.toLocalDate())} $startTime"
val end = "${dateMedium.format(endLdt.toLocalDate())} $endTime"
@@ -31,6 +31,7 @@ import de.jeanlucmakiola.calendula.ui.common.morphEvent
import de.jeanlucmakiola.calendula.ui.common.jumpToPage
import de.jeanlucmakiola.calendula.ui.common.rememberCalendarPageSpec
import de.jeanlucmakiola.floret.identity.LocalFloretDarkTheme
import de.jeanlucmakiola.floret.locale.capitalizeStart
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.drop
import androidx.compose.animation.ExperimentalSharedTransitionApi
@@ -798,7 +799,7 @@ internal fun WeekdayHeader(weekStart: DayOfWeek, showWeekNumbers: Boolean) {
val isWeekend = dow == DayOfWeek.SATURDAY || dow == DayOfWeek.SUNDAY
val javaDow = dow.toJavaDayOfWeek()
Text(
text = javaDow.getDisplayName(JavaTextStyle.SHORT, locale),
text = javaDow.getDisplayName(JavaTextStyle.SHORT, locale).capitalizeStart(locale),
style = MaterialTheme.typography.labelMedium,
color = if (isWeekend) MaterialTheme.colorScheme.onSurfaceVariant
else MaterialTheme.colorScheme.onSurface,
@@ -2842,6 +2843,7 @@ private fun shortMonthName(date: LocalDate): String {
return remember(date.month, locale) {
date.month.toJavaMonth()
.getDisplayName(JavaTextStyle.SHORT, locale)
.capitalizeStart(locale)
}
}
@@ -88,6 +88,7 @@ import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.SnackChip
import de.jeanlucmakiola.floret.components.SnackChipHeight
import de.jeanlucmakiola.floret.components.SnackChipMargin
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import de.jeanlucmakiola.calendula.ui.common.EventDimAlpha
@@ -470,6 +471,7 @@ private fun monthLabel(month: SearchMonth): String {
return remember(month.year, month.monthNumber, locale) {
localizedDateFormatter(locale, "LLLLy")
.format(java.time.LocalDate.of(month.year, month.monthNumber, 1))
.capitalizeStart(locale)
}
}
@@ -53,6 +53,7 @@ import de.jeanlucmakiola.floret.components.OptionPicker
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.ReorderableColumn
import de.jeanlucmakiola.floret.components.ReorderableRowHeight
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import kotlinx.datetime.DayOfWeek
import java.time.format.TextStyle as JavaTextStyle
@@ -516,6 +517,7 @@ internal fun weekStartLabel(pref: WeekStartPref): String = when (pref) {
// Localised weekday name, so no per-day string resource is needed.
is WeekStartPref.Day -> pref.day.toJavaDayOfWeek()
.getDisplayName(JavaTextStyle.FULL, currentLocale())
.capitalizeStart(currentLocale())
}
@Composable
@@ -21,6 +21,7 @@ import de.jeanlucmakiola.calendula.ui.common.rememberViewSwitchSpec
import de.jeanlucmakiola.calendula.ui.common.jumpToPage
import de.jeanlucmakiola.calendula.ui.common.pagedHeight
import de.jeanlucmakiola.floret.identity.LocalFloretDarkTheme
import de.jeanlucmakiola.floret.locale.capitalizeStart
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.drop
import androidx.compose.foundation.background
@@ -1106,7 +1107,7 @@ private fun WeekDayHeader(
) {
// One line, as the gutter cell beside it assumes (see WeekNumberCell).
Text(
text = javaDow.getDisplayName(JavaTextStyle.SHORT, locale),
text = javaDow.getDisplayName(JavaTextStyle.SHORT, locale).capitalizeStart(locale),
style = MaterialTheme.typography.labelSmall,
maxLines = 1,
overflow = TextOverflow.Clip,
@@ -11,6 +11,7 @@ import de.jeanlucmakiola.calendula.ui.agenda.agendaTimeLabel
import de.jeanlucmakiola.calendula.ui.common.formatTimeOfDay
import de.jeanlucmakiola.floret.glance.LocalWidgetBackground
import de.jeanlucmakiola.floret.glance.WidgetBackground
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.DateTimeUnit
import kotlinx.datetime.LocalDate
@@ -69,7 +70,7 @@ internal fun relativeDayLabel(context: Context, date: LocalDate, today: LocalDat
val locale = widgetLocale()
return relativeDayWord(context, date, today) ?: when {
date < today.plus(7, DateTimeUnit.DAY) && date > today ->
date.dayOfWeek.toJavaDayOfWeek().getDisplayName(java.time.format.TextStyle.SHORT, locale)
date.dayOfWeek.toJavaDayOfWeek().getDisplayName(java.time.format.TextStyle.SHORT, locale).capitalizeStart(locale)
else -> localizedDateFormatter(locale, "dMMM").format(date.toJavaLocalDate())
}
}
@@ -55,6 +55,7 @@ import de.jeanlucmakiola.calendula.domain.hasEnded
import de.jeanlucmakiola.calendula.ui.agenda.anchorTodayIfMissing
import de.jeanlucmakiola.calendula.ui.common.CalendarView
import de.jeanlucmakiola.calendula.ui.common.formatCalendarTitle
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import de.jeanlucmakiola.calendula.widget.widgetEventFill
import de.jeanlucmakiola.calendula.ui.common.eventAccent
@@ -669,7 +670,7 @@ private fun agendaDayLabel(context: Context, date: LocalDate, today: LocalDate):
val java = java.time.LocalDate.of(date.year, date.month.ordinal + 1, date.day)
// Weekday + date in the locale's own field order (compact: no year), rather
// than a hardcoded day-month layout.
val formatted = localizedDateFormatter(locale, if (date.year == today.year) "EEEdMMM" else "EEEdMMMy").format(java)
val formatted = localizedDateFormatter(locale, if (date.year == today.year) "EEEdMMM" else "EEEdMMMy").format(java).capitalizeStart(locale)
return if (relative != null) "$relative · $formatted" else formatted
}
@@ -681,7 +682,7 @@ private fun monthName(date: LocalDate, today: LocalDate): String = formatCalenda
)
private fun weekdayShort(date: LocalDate): String =
date.dayOfWeek.toJavaDayOfWeek().getDisplayName(java.time.format.TextStyle.SHORT, widgetLocale())
date.dayOfWeek.toJavaDayOfWeek().getDisplayName(java.time.format.TextStyle.SHORT, widgetLocale()).capitalizeStart(widgetLocale())
private fun eventTimeSummary(
context: Context,
@@ -38,6 +38,7 @@ import de.jeanlucmakiola.floret.components.GroupedRow
import de.jeanlucmakiola.floret.components.GroupedSectionHeader
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.positionOf
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.TimeZone
@@ -149,7 +150,7 @@ private fun CountdownEventPicker(
val formatter = remember(locale) { localizedDateFormatter(locale, "EEEdMMMy") }
LazyColumn(contentPadding = PaddingValues(top = 8.dp, bottom = 24.dp)) {
itemsIndexed(matches, key = { _, it -> it.event.eventId }) { index, candidate ->
val date = formatter.format(candidate.event.start.toLocalDateTime(candidate.event.dateZone(zone)).date.toJavaLocalDate())
val date = formatter.format(candidate.event.start.toLocalDateTime(candidate.event.dateZone(zone)).date.toJavaLocalDate()).capitalizeStart(locale)
GroupedRow(
title = candidate.event.title.ifBlank { stringResource(R.string.event_untitled) },
summary = if (candidate.repeats) stringResource(R.string.widget_config_countdown_repeats, date) else date,
@@ -45,6 +45,7 @@ import de.jeanlucmakiola.floret.glance.WidgetShapedBox
import de.jeanlucmakiola.floret.glance.currentRefreshStamp
import de.jeanlucmakiola.floret.glance.refreshStamp
import de.jeanlucmakiola.floret.glance.wallpaperBacking
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import de.jeanlucmakiola.floret.prefs.ThemeMode
import kotlinx.datetime.LocalDate
@@ -88,7 +89,7 @@ internal fun DateWidgetContent(today: LocalDate, appearance: WidgetAppearance, a
val size = LocalSize.current
val fontScale = context.resources.configuration.fontScale
val side = (minOf(size.width, size.height - WeekdayLine * fontScale) - 8.dp).coerceIn(32.dp, 120.dp)
val label = localizedDateFormatter(widgetLocale(), "EEEEdMMMM").format(today.toJavaLocalDate())
val label = localizedDateFormatter(widgetLocale(), "EEEEdMMMM").format(today.toJavaLocalDate()).capitalizeStart(widgetLocale())
val weekday = TextStyle(
color = GlanceTheme.colors.onSurface,
fontSize = 12.sp,
@@ -83,6 +83,7 @@ import de.jeanlucmakiola.calendula.widget.widgetCardColor
import de.jeanlucmakiola.calendula.widget.widgetEntryPoint
import de.jeanlucmakiola.calendula.widget.widgetSettings
import de.jeanlucmakiola.calendula.widget.widgetState
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.toJavaLocalDate
import de.jeanlucmakiola.calendula.widget.widgetTimeLabel
@@ -417,7 +418,7 @@ private fun DayList(day: LocalDate, data: MonthDayData.Ready, preview: Boolean)
val metrics = compactRowMetrics(data.options.textSize, context.resources.configuration.fontScale)
val openDay = actionStartActivity(MainActivity.openDateIntent(context, day))
Column(modifier = GlanceModifier.fillMaxSize()) {
val date = localizedDateFormatter(widgetLocale(), "EEEdMMM").format(day.toJavaLocalDate())
val date = localizedDateFormatter(widgetLocale(), "EEEdMMM").format(day.toJavaLocalDate()).capitalizeStart(widgetLocale())
val label = when (day) {
source.today, source.today.plus(1, DateTimeUnit.DAY) -> "${relativeDayLabel(context, day, source.today)} · $date"
else -> date
@@ -73,6 +73,7 @@ import de.jeanlucmakiola.floret.glance.WidgetMessage
import de.jeanlucmakiola.floret.glance.currentRefreshStamp
import de.jeanlucmakiola.floret.glance.refreshStamp
import de.jeanlucmakiola.floret.glance.wallpaperBacking
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import de.jeanlucmakiola.floret.prefs.ThemeMode
import kotlinx.datetime.DateTimeUnit
@@ -251,7 +252,7 @@ private fun TodayPill(today: LocalDate) {
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = today.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.SHORT, locale),
text = today.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.SHORT, locale).capitalizeStart(locale),
maxLines = 1,
style = TextStyle(color = GlanceTheme.colors.onPrimary, fontSize = 11.sp, textAlign = TextAlign.Center),
)
@@ -60,6 +60,7 @@ import de.jeanlucmakiola.floret.glance.WidgetMessage
import de.jeanlucmakiola.floret.glance.currentRefreshStamp
import de.jeanlucmakiola.floret.glance.refreshStamp
import de.jeanlucmakiola.floret.glance.wallpaperBacking
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.prefs.ThemeMode
import kotlinx.datetime.DateTimeUnit
import kotlinx.datetime.LocalDate
@@ -170,12 +171,12 @@ private fun DateHeader(today: LocalDate, height: Dp) {
Spacer(GlanceModifier.width(8.dp))
Column {
Text(
text = today.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.FULL, locale),
text = today.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.FULL, locale).capitalizeStart(locale),
maxLines = 1,
style = TextStyle(color = GlanceTheme.colors.onSurface, fontSize = 13.sp, fontWeight = FontWeight.Medium),
)
Text(
text = java.time.Month.of(today.month.ordinal + 1).getDisplayName(JavaTextStyle.FULL_STANDALONE, locale),
text = java.time.Month.of(today.month.ordinal + 1).getDisplayName(JavaTextStyle.FULL_STANDALONE, locale).capitalizeStart(locale),
maxLines = 1,
style = TextStyle(color = GlanceTheme.colors.onSurfaceVariant, fontSize = 12.sp),
)
@@ -63,6 +63,7 @@ import de.jeanlucmakiola.floret.glance.WidgetMessage
import de.jeanlucmakiola.floret.glance.currentRefreshStamp
import de.jeanlucmakiola.floret.glance.refreshStamp
import de.jeanlucmakiola.floret.glance.themedColor
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import de.jeanlucmakiola.floret.prefs.ThemeMode
import kotlinx.datetime.DateTimeUnit
@@ -148,7 +149,7 @@ private fun DayTile(date: LocalDate, data: DaysWidgetData.Ready) {
// A declined or cancelled event is no plan for the day, so it adds no dot and no count (#388).
val events = data.eventsOn(date).filterNot { it.isCrossedOut }
val colors = events.map { it.color }.distinct()
val label = localizedDateFormatter(locale, "EEEEdMMMM").format(date.toJavaLocalDate())
val label = localizedDateFormatter(locale, "EEEEdMMMM").format(date.toJavaLocalDate()).capitalizeStart(locale)
Column(
modifier = GlanceModifier
.fillMaxSize()
@@ -164,7 +165,7 @@ private fun DayTile(date: LocalDate, data: DaysWidgetData.Ready) {
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = date.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.SHORT, locale),
text = date.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.SHORT, locale).capitalizeStart(locale),
maxLines = 1,
style = TextStyle(color = ink, fontSize = 11.sp, textAlign = TextAlign.Center),
)