Check if string resources have set a "formatted" attribute #62
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.
Example:
<string name="test" formatted="false">100% Success!</string>
This will produce the following in template.pot:
The main purpose of this PR is essentially to negate an erroneously-detected format string if the boolean is set to "false". Also in the unlikely case that a formatted string is not detected, you can force it to use
c-format
to with the boolean set to "true".Unfortunately I can't find much in the way of official documentation for anything that actually uses
formatted="true|false"
, but Android Studio certainly knows enough to autocomplete it as a boolean.Something to note is that this attribute will not be carried over into specific language files (either .po or .xml). Personally I treat the
.../res/values-<lc>/strings.xml
files as auto-generated, and keep all the clever metadata in the .po files. I can't really see a benefit in explicitly setting theno-c-format
gettext flag, but perhaps that will be useful for someone.