module I18nData
def recognise_code(type, search)
def recognise_code(type, search) search = search.strip # common languages first <-> faster in majority of cases language_codes = ['EN', 'ES', 'FR', 'DE', 'ZH'] | available_language_codes language_codes.each do |language_code| options = begin send(type, language_code) rescue NoTranslationAvailable next end options.each do |code, name| # support "Dutch" and "Dutch; Flemish", checks for inclusion first to skip the splitting # then check for exact match return code if name.include?(search) && (name == search || name.split('; ').include?(search)) end end nil # not found end