0

I have a case of a lot of UI strings in Android strings.xml resource files, such as sol3, which are not words, and which do not belong in a dictionary. I would like to disable lint spell check for those strings, on a per-element basis, something like

<string someattr="nospellcheck">sol3</string>

and on a per-file basis, something like

<resources someattr="nospellcheck">...</resources>

Is there any way to do that?

My only solution now, is to gather the non-word stings into separate resource files with a different name, perhaps non-words.xml. Then in Android Studio's Settings, create a Scope that filters for that file name, and under

Editor->Inspections->Correctness->Messages

In both of these, there is an option to add a Scope (non-obvious). Add the Scope, before Everywhere Else.

But that is horrible. What is the right way to locally suppress spell checks in XML files?

(I got this working for .bat files under Editor->Inspections->Proofreading, but for the current issue, I only managed to change the Message, not make it stop appearing.)

Steve White
  • 373
  • 5
  • 9

1 Answers1

0

Yes, @CommonsWare pointed to the answer. It is very easy, and just what I was looking for.
(Web searches somehow still don't turn up the answer. But I should have been able to figure it out from the Android Studio UI tips.)

Within the <resources> element, the tools namespace has to be defined:

xmlns:tools="http://schemas.android.com/tools"

All spellchecking within that element can be disabled with the attribute

tools:ignore="Typos"

Spellchecking for an individual <string> child is suppressed by the same attribute.

Thanks!

Steve White
  • 373
  • 5
  • 9