Class: RuboCop::Cop::DevDoc::I18n::ReportText

Inherits:
Base
  • Object
show all
Includes:
LocalizableProps
Defined in:
lib/rubocop/cop/dev_doc/i18n/report_text.rb

Overview

Report every user-facing text in a glib JSON-UI text prop — both hardcoded strings and already-localized t(...) calls.

Rationale

DevDoc/I18n/RequireTranslation flags only hardcoded strings; it stays silent once a value is localized. This cop is the opposite: it fires on every text value, localized or not, so you can sweep a codebase and collect the full list of user-facing strings (e.g. to seed a translation catalog or audit coverage).

It is a tooling aid, not a lint — disabled by default and runs at info severity. Run it during a localization pass; it is not meant for every commit.

Both the hardcoded form (view.p text: 'Welcome') and the localized form (view.p text: t('home.welcome')) are reported. Blank/whitespace strings and pure dynamic values (user.name) carry no static text and are skipped.

The watched method names and localizable keys are configurable via WatchedMethods: and LocalizableKeys:.

📋 Reported  hardcoded text
view.p text: 'Welcome'

📋 Reported  localized text
view.p text: t('home.welcome')

Examples:

# info (hardcoded text)
view.p text: 'Welcome'

# info (localized text — still reported)
view.p text: t('home.welcome')

# info (interpolated string)
view.p text: "Hi #{name}"

# ignored (blank — no text)
view.fields_text label: ''

# ignored (pure dynamic — no static text)
view.p text: user.name

Constant Summary collapse

MSG =
'Text for `%<key>s:`: review/collect this for localization.'.freeze

Constants included from LocalizableProps

LocalizableProps::DEFAULT_LOCALIZABLE_KEYS, LocalizableProps::DEFAULT_WATCHED_METHODS, LocalizableProps::TRANSLATION_METHODS

Method Summary

Methods included from LocalizableProps

#on_send