fix: crash on malformed plural translation#1080
Merged
Merged
Conversation
Greptile SummaryThis PR prevents malformed plural translations from crashing the app. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| 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
This comment was marked as resolved.
This comment was marked as resolved.
2 tasks
This comment was marked as duplicate.
This comment was marked as duplicate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
IllegalArgumentExceptioncrashing 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 ICUMessageFormat. Two things combined to make this fatal: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 fix corrects the two malformed translations to use the valid
otherkeyword, 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
selectpatterns.✅ 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
regression:Device locale set to English → trigger the same backup-failure notification: toast still shows "Retrying in N minute(s)" correctly.Automated Checks
StringExtTest.ktcovers the plural helper selecting theoneandotherbranches for valid patterns, and returning the raw string instead of throwing on a malformed pattern.