Module: I18nFeedback::Marking
- Defined in:
- lib/i18n_feedback/marking.rb
Overview
Appends a "⟦namespace.key⟧" marker to each translated string so the widget can map rendered text back to its i18n key. The marker is never shown to the user: the widget strips every token out of the DOM on load and stashes the key on the element. Marking is a per-request, per-thread toggle (see Middleware), so pages stay clean unless a proofreader has switched the tool on.
Defined Under Namespace
Modules: Backend
Constant Summary collapse
- LEFT =
'⟦'- RIGHT =
'⟧'- SKIP =
Skip format/lookup namespaces — marking these would corrupt number, date, and currency formatting and interpolation strings. The tool's own
i18n_feedback.*strings are skipped too: they aren't part of the host app's translatable copy, so the widget must never mark (or offer to edit) its own UI. /(\A|\.)(number|date|time|datetime|support|i18n_feedback)(\.|\z)|formats?\z/
Class Method Summary collapse
Class Method Details
.enabled=(value) ⇒ Object
25 26 27 |
# File 'lib/i18n_feedback/marking.rb', line 25 def enabled=(value) Thread.current[:i18n_feedback_marking] = value end |
.enabled? ⇒ Boolean
21 22 23 |
# File 'lib/i18n_feedback/marking.rb', line 21 def enabled? Thread.current[:i18n_feedback_marking] || false end |