Fix format specifier flags in Android xml files (Fix #62)#63
Open
Brock-Gibson wants to merge 4 commits intoAsana:mainfrom
Open
Fix format specifier flags in Android xml files (Fix #62)#63Brock-Gibson wants to merge 4 commits intoAsana:mainfrom
Brock-Gibson wants to merge 4 commits intoAsana:mainfrom
Conversation
Brock-Gibson
commented
Dec 15, 2025
| "%((?<position>\\d+)\\$)?(?<specifier>(\(lengthExpression))?(\(specifierExpression)))" | ||
| static let nativeArgumentRegex = try! NSRegularExpression( | ||
| pattern: Expressions.nativeArgumentExpression, | ||
| private static let iosArgumentExpression = |
Author
There was a problem hiding this comment.
core changes are here to keep iOS backwards compatible and properly handle android separately going forward
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: #62
This pull request introduces improved support for Android string format specifiers, adds comprehensive test cases for format flags and width/precision handling, and refactors the codebase to better distinguish between iOS and Android parsing logic.
Noticed we had a bunch of missing format specifiers that weren't handled properly when i started using this in my own project. Filed that issue and figured i should just improve it to make the format specifiers a bit more robust.
When i ran
swiftformatper the contribution guidelines I got a bunch of unrelated changes, not sure how those made it into the base.Android format specifier support and parsing:
androidArgumentRegexand related expressions inExpressions.swift. Parsing now distinguishes between iOS and Android strings using a newplatformproperty inFormatString.AndroidStringsFileto constructFormatStringobjects withplatform: .android, ensuring correct parsing of Android format strings.Test case and example improvements:
strings-base.xmlandstrings-translation.xmlto cover format specifier flags, width, and precision, including both correct and intentionally incorrect translations for validation.