Module: DevDoc

Defined in:
lib/dev_doc/i18n/pseudo_locale.rb,
lib/dev_doc/test/best_practice_lints.rb,
lib/dev_doc/test/lints/cron_schedule.rb,
lib/dev_doc/test/pseudo_i18n_crawler.rb,
lib/dev_doc/test/lints/no_file_excludes.rb,
lib/dev_doc/test/lints/duplicate_snapshot.rb,
lib/dev_doc/test/lints/http_driven_controller_tests.rb

Overview

Pseudo-localization backend — a hardcoded-text detector.

When installed (see PseudoLocale.install!), an extra locale en-PSEUDO becomes available. Every string resolved through Rails t() is returned as its real English value, accented and wrapped in ⟦ ⟧ markers, e.g.

t('energies.show.title')  # "Monthly Statement"
  --> rendered under en-PSEUDO -->  "⟦Móñţĥļý Šţáţéméñţ⟧"

Render any page under the pseudo locale and scan the output: any user-facing text WITHOUT the ⟦ ⟧ markers never went through t() and is therefore a hardcoded-string candidate — regardless of whether it came from a view, helper, concern, module, or service object.


Per-project integration

This gem is a :development, :test-only dependency, so it is NOT loaded in production and this file is only required when detection mode is on. The project initializer requires it and installs the backend under PSEUDO_I18N=1:

# config/initializers/pseudo_locale.rb
if ENV['PSEUDO_I18N'] == '1'
require 'dev_doc/i18n/pseudo_locale'
DevDoc::I18n::PseudoLocale.install!
end

mark (below) is called from production code paths to flag externally-managed strings for the scanner. Because this gem is absent in production, call it through a null-guard so it degrades to the identity when the gem is not loaded — the value is untouched anyway when detection mode is off:

def pseudo_mark(value)
return value unless defined?(DevDoc::I18n::PseudoLocale)
DevDoc::I18n::PseudoLocale.mark(value)
end

Guarded behind PSEUDO_I18N, so normal dev/prod is untouched and the fake locale can never leak to real users.

Defined Under Namespace

Modules: I18n, Test