Vale CMS Need more than a rule playground? Explore
Asset Explorer

AndroidStrings

The text of each string and plural in an Android resource file, with names and untranslatable strings left alone.

view textfsmi18n Vale ≥ 3.21.0 Source

Getting started

Save the file as config/views/AndroidStrings.yml under your StylesPath, then:

[res/values/strings.xml]
BasedOnStyles = Vale

View = AndroidStrings

AndroidStrings.yml

Pull named scopes out of a file Vale can’t otherwise parse.
# Android string resources: the text of each `<string>` and of each `<item>`
# in a `<plurals>`, one element per line. Names, attributes, and strings
# marked `translatable="false"` are never linted.
#
#   [res/values/strings.xml]
#   BasedOnStyles = Vale
#   View = AndroidStrings
engine: textfsm
template: |
  Value String (.*?)
  Value Plural (.*?)

  Start
    ^\s*<string\b[^>]*\btranslatable="false" -> Next
    ^\s*<string\b[^>]*>${String}</string> -> Record
    ^\s*<plurals\b -> Plurals

  Plurals
    ^\s*</plurals> -> Start
    ^\s*<item\b[^>]*>${Plural}</item> -> Record
scopes:
  - name: string
    expr: String

  - name: plural
    expr: Plural