Module: Newsmlg2::I18n

Defined in:
lib/newsmlg2/i18n.rb

Overview

Helpers for multi-language content collections (elements carrying xml:lang, such as ConceptNameType values).

Class Method Summary collapse

Class Method Details

.for_language(collection, lang) ⇒ Object

The first element of the collection matching the given language tag (exact match), or nil.



16
17
18
# File 'lib/newsmlg2/i18n.rb', line 16

def for_language(collection, lang)
  collection.find { |item| item.xml_lang == lang }
end

.languages(collection) ⇒ Object

The languages used by a collection of localized elements.



10
11
12
# File 'lib/newsmlg2/i18n.rb', line 10

def languages(collection)
  collection.filter_map(&:xml_lang).uniq
end