Module: Edoxen::LocalizationHost
Overview
Mixed into entities that carry a per-language localizations[]
collection. Provides in_language(code, fallback:) and
primary_localization in one place so Decision, Meeting, etc.
share a single implementation.
The including class must declare a typed localizations attribute
whose entries expose language_code (ISO 639-3).
Instance Method Summary collapse
Instance Method Details
#in_language(code, fallback: false) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/edoxen/localization_host.rb', line 12 def in_language(code, fallback: false) match = localizations&.find { |loc| loc.language_code == code.to_s } return match if match fallback ? localizations&.first : nil end |
#primary_localization ⇒ Object
19 20 21 |
# File 'lib/edoxen/localization_host.rb', line 19 def primary_localization in_language("eng", fallback: true) end |