diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-24 22:05:58 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-24 22:05:58 +0200 |
| commit | 8e1cbe1362059ee02bcc6380be3fb979455da022 (patch) | |
| tree | b8104412935d4d270bc089161aa0febbec4ba7b0 | |
| parent | 50ca5e40f461290a2db7452b95f80dd3188dba1d (diff) | |
Add a pseudo-locale tripwire for the i18n extraction
| -rw-r--r-- | config/initializers/pseudo_i18n.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/config/initializers/pseudo_i18n.rb b/config/initializers/pseudo_i18n.rb new file mode 100644 index 00000000..16b340f2 --- /dev/null +++ b/config/initializers/pseudo_i18n.rb | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | if ENV["PSEUDO_I18N"] | ||
| 2 | module PseudoI18nDecoration | ||
| 3 | def translate(locale, key, options = {}) | ||
| 4 | result = super | ||
| 5 | return result unless result.is_a?(String) | ||
| 6 | ENV["PSEUDO_I18N"] == "redact" ? "▚" * result.length : "⟦#{result}⟧" | ||
| 7 | end | ||
| 8 | end | ||
| 9 | I18n.backend.class.prepend(PseudoI18nDecoration) | ||
| 10 | end | ||
