Module: DevDoc::I18n::PseudoLocale::Backend
- Defined in:
- lib/dev_doc/i18n/pseudo_locale.rb
Overview
I18n backend override: resolves the real English entry, then accents it.
Constant Summary collapse
- SKIP_NAMESPACES =
Namespaces whose values are format directives / structural data, not copy. Accenting these would corrupt strftime (
%A), number formats. %w[i18n date time datetime number support].freeze
- NON_COPY =
Some t() values are not display copy — asset filenames, paths, URLs. The asset helpers feed these to Vite, which raises on a missing manifest entry, so accenting them 500s the page. Leave them untouched.
Note: do NOT treat a bare "/" as a path — display copy legitimately contains slashes ("Lamp/Bulbs", "Food/Food Scraps"). A real path is an all-lowercase identifier chain (
shared/layouts/main,images/icon); copy has capitals or spaces, so it won't match the lowercase-path rule. %r{ \A\s*\z # blank | \Ahttps?:// # url | \A[a-z0-9_]+(?:[/.][a-z0-9_]+)+\z # lowercase path / dotted id (shared/layouts/main) }x- ASSET_EXT =
/\.(?:png|jpe?g|svg|gif|webp|ico|bmp|css|js|mjs|html?|pdf|woff2?|ttf|otf|mp[34]|json|xml|csv)\z/i
Instance Method Summary collapse
Instance Method Details
#lookup(locale, key, scope = [], options = ::I18n::EMPTY_HASH) ⇒ Object
132 133 134 135 136 137 138 139 140 |
# File 'lib/dev_doc/i18n/pseudo_locale.rb', line 132 def lookup(locale, key, scope = [], = ::I18n::EMPTY_HASH) return super unless locale.to_s == PSEUDO_LOCALE # Resolve the real English entry (template, before interpolation). real = super(:en, key, scope, ) return real if real.nil? || skip?(key, scope) pseudoize(real) end |