Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML processor generates invalid code for printf style formatting #33

Open
dalewking opened this issue Nov 27, 2023 · 1 comment
Open
Labels
codegen: android-xml Codegen from Android String Resources conversion issue

Comments

@dalewking
Copy link

If you have a string that has printf format specifiers like:

    <string name="total_duration">%1$s Total</string>

It generates:

    override val totalDuration = { p0: String -> 
        "%s Total"
            .format(p0)
    }

Problem is there is no such format method on string at least in common code.

For most simple cases you could simply generate string interpolation code and if the format specifier is more complex generate warnings

@DevNatan DevNatan added the codegen: android-xml Codegen from Android String Resources conversion issue label Nov 27, 2023
@dalewking
Copy link
Author

I confirmed that our string files do not do anything more complicated than %1$s or %1$d so simple string interpolation is all we need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen: android-xml Codegen from Android String Resources conversion issue
Projects
None yet
Development

No branches or pull requests

2 participants