Skip to content

fix: crash on malformed plural translation#1080

Merged
jvsena42 merged 4 commits into
masterfrom
fix/crash-malformed-translation
Jul 15, 2026
Merged

fix: crash on malformed plural translation#1080
jvsena42 merged 4 commits into
masterfrom
fix/crash-malformed-translation

Conversation

@jvsena42

@jvsena42 jvsena42 commented Jul 15, 2026

Copy link
Copy Markdown
Member

Fixes #1069

This PR fixes a crash that could occur when Bitkit tried to show the "backup failed" notification in certain languages.

Description

Play Vitals reported an IllegalArgumentException crashing the app from the periodic backup check. When a failed backup is detected, the error toast formats a localized retry message ("Retrying in N minutes") through ICU MessageFormat. Two things combined to make this fatal:

  • The Italian and Czech translations of the retry message used a translated word ("o", "dalších") where ICU requires the literal plural keyword other. On some Android/ICU versions this makes the pattern unparseable and throws before the toast can be shown, which is why it reproduced only rarely.
  • The plural formatting helper had no error handling, so any malformed translation pattern was fatal to the whole app rather than degrading gracefully.

The fix corrects the two malformed translations to use the valid other keyword, and hardens the plural helper so a bad pattern can never crash the app again: it now falls back to returning the raw string and logs a warning. This also protects the Compose plural path, which routes through the same helper.

An audit of all 16 locale string files confirmed these were the only two malformed plural strings; every other plural entry already uses valid ICU keywords, and there are no select patterns.

✅ Transifex updates

https://app.transifex.com/synonym/bitkit/translate/#it/stringsxml/599711093?q=text%3A'failed%20to%20back%20up%20wallet%20data'

https://app.transifex.com/synonym/bitkit/translate/#cs/stringsxml/599711093?q=text%3A'failed%20to%20back%20up%20wallet%20data'

Preview

Screen_recording_20260715_092227.webm

QA Notes

Manual Tests

  • 1. Device locale set to Italian or Czech → trigger a backup-failure notification (failed backup detected on periodic check): the error toast shows the localized retry message without crashing.
  • 2. regression: Device locale set to English → trigger the same backup-failure notification: toast still shows "Retrying in N minute(s)" correctly.

Automated Checks

  • Unit tests added: StringExtTest.kt covers the plural helper selecting the one and other branches for valid patterns, and returning the raw string instead of throwing on a malformed pattern.
  • CI: standard compile, unit test, and detekt checks run by the PR bot.

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR prevents malformed plural translations from crashing the app. The main changes are:

  • Correct invalid ICU plural selectors in the Czech and Italian translations.
  • Return the raw localized string when plural formatting fails.
  • Log plural-formatting failures for diagnosis.
  • Add tests for singular, plural, and malformed patterns.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
app/src/main/java/to/bitkit/ext/String.kt Catches ICU formatting failures, logs a warning, and returns the raw pattern instead of crashing.
app/src/main/res/values-cs/strings.xml Replaces an invalid translated plural selector with ICU's required other keyword.
app/src/main/res/values-it/strings.xml Replaces an invalid translated plural selector with ICU's required other keyword.
app/src/test/java/to/bitkit/ext/StringExtTest.kt Tests both valid plural branches and the malformed-pattern fallback.
changelog.d/next/1069.fixed.md Documents the backup-failure notification crash fix.

Reviews (1): Last reviewed commit: "chore: rename changelog fragment" | Re-trigger Greptile

@jvsena42 jvsena42 self-assigned this Jul 15, 2026
@jvsena42 jvsena42 enabled auto-merge July 15, 2026 12:03
@jvsena42

This comment was marked as resolved.

@jvsena42 jvsena42 requested a review from piotr-iohk July 15, 2026 12:07
@jvsena42 jvsena42 added this to the 2.4.0 milestone Jul 15, 2026
@jvsena42

This comment was marked as duplicate.

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jvsena42 jvsena42 merged commit f928bf4 into master Jul 15, 2026
18 checks passed
@jvsena42 jvsena42 deleted the fix/crash-malformed-translation branch July 15, 2026 12:47
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.

[Bug]: Backup failure toast crashes on formatPlural IllegalArgumentException

2 participants