Module: HeadMusic::Instruments::CatalogLookup
- Included in:
- InstrumentCatalog, InstrumentFamily
- Defined in:
- lib/head_music/instruments/catalog_lookup.rb
Overview
Shared lookup of a catalog entry’s key by a localized (translated) name. Including classes provide #catalog, a Hash of name_key => record whose keys match the I18n keys under “head_music.instruments”.
Instance Method Summary collapse
-
#key_for_name(name) ⇒ Object
private
Instance Method Details
#key_for_name(name) ⇒ Object (private)
9 10 11 12 13 14 15 16 17 |
# File 'lib/head_music/instruments/catalog_lookup.rb', line 9 def key_for_name(name) catalog.each do |key, _data| I18n.config.available_locales.each do |locale| translation = I18n.t("head_music.instruments.#{key}", locale: locale) return key if translation.downcase == name.downcase end end nil end |