Skip to content

Fix: Localize units in next alarm remaining time display - #54

Open
knocker-g wants to merge 1 commit into
SysAdminDoc:mainfrom
knocker-g:upstream-pr/localize-time-units
Open

knocker-g wants to merge 1 commit into
SysAdminDoc:mainfrom
knocker-g:upstream-pr/localize-time-units

Conversation

@knocker-g

Copy link
Copy Markdown

Summary

This PR localizes the time units used in the "remaining time until alarm" display (e.g., "d", "h", "m", "now", "<1m").

Problem

The time units for the remaining duration display were hardcoded in the Kotlin source code (NextAlarmCalculator.kt). This prevented these units from being translated and caused them to always appear in English regardless of the device's locale settings.

Changes

  • Modified NextAlarmCalculator.formatRemaining to accept a Context and use string resources for all units and status labels.
  • Added the following string resources to app/src/main/res/values/strings.xml:
    • time_unit_d (%1$dd)
    • time_unit_now (now)
    • time_unit_less_than_1m (<1m)
    • Reuses existing time_unit_h and time_unit_m.
  • Updated all call sites of formatRemaining to provide the necessary Context:
    • NextAlarmNotifier.kt
    • AlarmListViewModel.kt
    • AlarmEditOverviewSections.kt
    • NextAlarmWidget.kt

Testing

  • git diff --check: PASS
  • F-Droid debug build: SUCCESS
  • Play debug build: SUCCESS
  • Tests: BLOCKED / NOT EXECUTED (due to existing environment issues)
  • Manual verification: Verified that the remaining time display updates correctly and uses localized strings when available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant