(#) Straight quotes can be replaced with curvy quotes, and apostrophes with typographic apostrophes !!! WARNING: Straight quotes can be replaced with curvy quotes, and apostrophes with typographic apostrophes This is a warning. Id : `TypographyQuotes` Summary : Straight quotes can be replaced with curvy quotes, and apostrophes with typographic apostrophes Note : **This issue is disabled by default**; use `--enable TypographyQuotes` Severity : Warning Category : Usability: Typography Platform : Android Vendor : Android Open Source Project Feedback : https://issuetracker.google.com/issues/new?component=192708 Since : Initial Affects : Resource files Editing : This check runs on the fly in the IDE editor See : https://en.wikipedia.org/wiki/Quotation_mark Implementation : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/TypographyDetector.kt) Tests : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.kt) Copyright Year : 2011 Straight single quotes and double quotes, when used as a pair, can be replaced by "curvy quotes" (or directional quotes). Use the right single quotation mark for apostrophes. Never use generic quotes ", ' or free-standing accents `, ´ for quotation marks, apostrophes, or primes. This can make the text more readable. !!! Tip This lint check has an associated quickfix available in the IDE. (##) Example Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values/typography.xml:3:Warning: Replace straight quotes ('') with directional quotes (‘’, ‘ and ’) ? [TypographyQuotes] <string name="home_title">Home 'Sample'</string> ------------- res/values/typography.xml:5:Warning: Replace straight quotes (") with directional quotes (“”, “ and ”) ? [TypographyQuotes] <string name="show_all_apps2">Show "All"</string> ---------- res/values/typography.xml:6:Warning: Replace straight quotes (") with directional quotes (“”, “ and ”) ? [TypographyQuotes] <string name="escaped">Skip \"All\"</string> ------------ res/values/typography.xml:7:Warning: Replace apostrophe (') with typographic apostrophe (’, ’) ? [TypographyQuotes] <string name="single">Android's</string> - res/values/typography.xml:9:Warning: Replace apostrophe (') with typographic apostrophe (’, ’) ? [TypographyQuotes] <string name="badquotes1">`First'</string> - res/values/typography.xml:10:Warning: Avoid quoting with grave accents; use apostrophes or better yet directional quotes instead [TypographyQuotes] <string name="badquotes2">``second''</string> ---------- res/values/typography.xml:11:Warning: Replace straight quotes ('') with directional quotes (‘’, ‘ and ’) ? [TypographyQuotes] <string name="notbadquotes">Type Option-` then 'Escape'</string> --------------------------- res/values/typography.xml:22:Warning: Replace apostrophe (') with typographic apostrophe (’, ’) ? [TypographyQuotes] <string name="notdirectional">A's and B's</string> ----------- res/values/typography.xml:29:Warning: Replace apostrophe (') with typographic apostrophe (’, ’) ? [TypographyQuotes] <string>something somthing d\'avoir something something l\'écran.</string> --------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: `res/values/typography.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers <resources> <string name="home_title">Home 'Sample'</string> <string name="show_all_apps">"All"</string> <string name="show_all_apps2">Show "All"</string> <string name="escaped">Skip \"All\"</string> <string name="single">Android's</string> <string name="copyright">(c) 2011</string> <string name="badquotes1">`First'</string> <string name="badquotes2">``second''</string> <string name="notbadquotes">Type Option-` then 'Escape'</string> <string name="fraction1">5 1/2 times</string> <string name="fraction4">1/4 times</string> <string name="notfraction">51/2 times, 1/20</string> <string name="ellipsis">40 times...</string> <string name="notellipsis">40 times.......</string> <string name="ndash">For ages 3-5</string> <string name="ndash2">Copyright 2007 - 2011</string> <string name="nontndash">x-y</string> <string name="mdash">Not found -- please try again</string> <string name="nontndash">----</string> <string name="notdirectional">A's and B's</string> <string-array name="typography"> <item>Ages 3-5</item> <item>Age 5 1/2</item> </string-array> <string name="ndash">X Y Z: 10 10 -1</string> <string name="ga_trackingId">UA-0000-0</string> <string>something somthing d\'avoir something something l\'écran.</string> </resources> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the [source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.kt) for the unit tests for this check to see additional scenarios. (##) Suppressing You can suppress false positives using one of the following mechanisms: * Adding the suppression attribute `tools:ignore="TypographyQuotes"` on the problematic XML element (or one of its enclosing elements). You may also need to add the following namespace declaration on the root element in the XML file if it's not already there: `xmlns:tools="http://schemas.android.com/tools"`. ```xml <?xml version="1.0" encoding="UTF-8"?> <resources xmlns:tools="http://schemas.android.com/tools"> ... <string tools:ignore="TypographyQuotes" .../> ... </resources> ``` * Using a special `lint.xml` file in the source tree which turns off the check in that folder and any sub folder. A simple file might look like this: ```xml <?xml version="1.0" encoding="UTF-8"?> <lint> <issue id="TypographyQuotes" severity="ignore" /> </lint> ``` Instead of `ignore` you can also change the severity here, for example from `error` to `warning`. You can find additional documentation on how to filter issues by path, regular expression and so on [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html). * In Gradle projects, using the DSL syntax to configure lint. For example, you can use something like ```gradle lintOptions { disable 'TypographyQuotes' } ``` In Android projects this should be nested inside an `android { }` block. * For manual invocations of `lint`, using the `--ignore` flag: ``` $ lint --ignore TypographyQuotes ...` ``` * Last, but not least, using baselines, as discussed [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).