Module: LcpRuby::Metadata::I18nLabel
- Defined in:
- lib/lcp_ruby/metadata/i18n_label.rb
Overview
Canonical literal/key/fallback resolver for user-visible strings. The platform’s i18n principle (CLAUDE.md § i18n) treats ‘label:` literal and `label_key:` i18n key as both first-class; this is the one place that precedence is encoded:
* key present → I18n.t(key) with literal (or fallback) as default
* literal-only → returned verbatim
* neither → fallback (may be nil)
Used by chart widgets, filter_form, scope_filters, KPI cards, and the page title — each call site supplies its own ‘fallback:` (humanized field name / zone name / “Series N” / …).
Class Method Summary collapse
Class Method Details
.resolve(literal: nil, key: nil, fallback: nil) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/lcp_ruby/metadata/i18n_label.rb', line 18 def resolve(literal: nil, key: nil, fallback: nil) if key.present? I18n.t(key, default: literal.presence || fallback) elsif literal.present? literal else fallback end end |