getConditionallyRelativeFormattedTimeSpan shows literal %dm instead of a number for anything under 1 hour
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 75/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
バグは core/src/main/java/com/nextcloud/android/common/core/utils/DateFormatter.kt にあります。まず、関数 getConditionallyRelativeFormattedTimeSpan と、ONE_HOUR_IN_MILLIS 未満の期間の分岐を見つけてください。修正は、3引数の getQuantityString オーバーロードを使用し、置換用に分数を渡すことです。また、対応するテスト DateFormatterTest.kt を更新して正しいメソッドを使用するようにしてください。オランダ語の翻訳ファイル values-nl/strings.xml で、不足している複数形の文字列を確認してください。修正を確認するためにテストを実行してください。
索引モデルが issue の本文から書いたものです。
説明
Summary
For a timestamp less than an hour old, DateFormatter.getConditionallyRelativeFormattedTimeSpan() returns the literal unsubstituted string %dm instead of e.g. 13m. Reproduced via the Notes app (it.niedermann.owncloud.notes), which uses this library — the note list showed %dm for any note modified 1–59 minutes ago, while notes older than an hour rendered correctly ("10 u" etc.).
Root cause
In core/src/main/java/com/nextcloud/android/common/core/utils/DateFormatter.kt, the "less than 1h" branch calls the 2-argument Resources.getQuantityString(int, int) overload, which selects a plural form but performs no substitution:
span < ONE_HOUR_IN_MILLIS -> {
context.resources
.getQuantityString(
R.plurals.date_formatting_relative_minutes,
span.toInt() / ONE_MINUTE_IN_MILLIS
)
}
Since values/strings.xml defines this plural as <item quantity="other">%dm</item>, the %d is never substituted. The next branch (hours) uses the correct 3-arg overload:
val hours: Int = span.toInt() / ONE_HOUR_IN_MILLIS
context.resources.getQuantityString(R.plurals.date_formatting_relative_hours, hours, hours)
Suggested fix
span < ONE_HOUR_IN_MILLIS -> {
val minutes = span.toInt() / ONE_MINUTE_IN_MILLIS
context.resources.getQuantityString(R.plurals.date_formatting_relative_minutes, minutes, minutes)
}
Note on test coverage
DateFormatterTest.kt's Test relative minutes formatting computes its expected value with the same broken 2-arg call, so it passes despite the bug — worth using the 3-arg form there too once fixed, to actually catch this.
Secondary, unrelated gap
values-nl/strings.xml doesn't translate date_formatting_relative_minutes at all (only date_formatting_now and date_formatting_relative_hours are present), so Dutch falls back to the English base string for that one plural. Doesn't affect the substitution bug either way, but worth completing while in there.
Environment
- Nextcloud Notes app, via
com.nextcloud.android.common:core(whatever version it currently pulls) - LineageOS 22 (Android 15), Dutch (
nl) locale - OnePlus 6
- 主要言語
- Java
- スター
- 6
- フォーク
- 4
- 平均マージ
- 8時間 1分
- マージ済み PR(30日)
- 26
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/android-common のほかの issue
-
toolbar icon theming is broken for left and right side icons再び着手できるかも @AndyScherzinger が 929 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
nextcloud/android-common#333 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
nextcloud/android-common#290 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Dependency Dashboardオープン
難易度 4/5 3〜5日 初心者へのやさしさ 10/100
nextcloud/android-common#255 ·
メンテナーはふだん 1 日以内に返信
-
common featuresオープンoverview
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
nextcloud/android-common#56 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Testing setupオープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
nextcloud/android-common#18 ·
メンテナーはふだん 1 日以内に返信
nextcloud/android-common の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
go 🏃 testing 🧪
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
valkey-io/valkey-glide#7239 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
github/copilot-sdk#2793 ·
メンテナーはふだん 1 日以内に返信