Module: Opencdd::Parcel::LanguageAliases
- Defined in:
- lib/opencdd/parcel/language_aliases.rb
Overview
Maps non-conformant language codes found in IEC CDD source .xls exports to their ISO 639-1 equivalents.
This is a Parcel-layer concern, not a model concern: the aliases
exist because one specific source format (IEC CDD XLS) uses
non-standard codes in its property ID suffixes and directive
rows. The Languages value object — and every downstream
consumer (JSON wire format, browser, TS model) — speaks ISO
639-1 unconditionally.
The normalization happens at the SheetSchema ingestion
boundary so downstream code never sees an alias. SheetSchema
also exposes the set of original-to-canonical mappings it
applied via #normalized_language_codes for data-quality
reporting.
Constant Summary collapse
- ALIASES =
{ "jp" => "ja", }.freeze
Class Method Summary collapse
-
.alias?(code) ⇒ Boolean
True when
codewould be rewritten bynormalize. -
.normalize(code) ⇒ Object
Returns the ISO 639-1 form of
code, or the input unchanged if it is already standard.
Class Method Details
.alias?(code) ⇒ Boolean
True when code would be rewritten by normalize.
36 37 38 39 |
# File 'lib/opencdd/parcel/language_aliases.rb', line 36 def self.alias?(code) return false if code.nil? ALIASES.key?(code.to_s.strip) end |
.normalize(code) ⇒ Object
Returns the ISO 639-1 form of code, or the input unchanged
if it is already standard. Pure function: no I/O, no side
effects.
28 29 30 31 32 33 |
# File 'lib/opencdd/parcel/language_aliases.rb', line 28 def self.normalize(code) return code if code.nil? s = code.to_s.strip return s if s.empty? ALIASES.fetch(s, s) end |