SEED_LANGUAGES = {
  ar: { is_bing_supported: true, inferred_country_code: 'XA', name: 'Arabic' , rtl: true },
  az: { is_bing_supported: false, inferred_country_code: nil, name: 'Azerbaijani' , rtl: false },
  be: { is_bing_supported: true, inferred_country_code: nil, name: 'Belarusian' , rtl: false },
  bg: { is_bing_supported: true, inferred_country_code: 'BG', name: 'Bulgarian' , rtl: false },
  bn: { is_bing_supported: true, inferred_country_code: nil, name: 'Bangla' , rtl: false },
  bs: { is_bing_supported: false, inferred_country_code: nil, name: 'Bosnian' , rtl: false },
  ca: { is_bing_supported: true, inferred_country_code: nil, name: 'Catalan' , rtl: false },
  cs: { is_bing_supported: true, inferred_country_code: 'CZ', name: 'Czech' , rtl: false },
  da: { is_bing_supported: true, inferred_country_code: 'DK', name: 'Danish' , rtl: false },
  de: { is_bing_supported: true, inferred_country_code: 'DE', name: 'German' , rtl: false },
  el: { is_bing_supported: true, inferred_country_code: 'GR', name: 'Greek' , rtl: false },
  en: { is_bing_supported: true, inferred_country_code: 'US', name: 'English' , rtl: false },
  es: { is_bing_supported: true, inferred_country_code: 'US', name: 'Spanish' , rtl: false },
  et: { is_bing_supported: true, inferred_country_code: 'EE', name: 'Estonian' , rtl: false },
  fa: { is_bing_supported: true, inferred_country_code: nil, name: 'Persian' , rtl: true },
  fi: { is_bing_supported: true, inferred_country_code: 'FI', name: 'Finnish' , rtl: false },
  fr: { is_bing_supported: true, inferred_country_code: 'FR', name: 'French' , rtl: false },
  ha: { is_bing_supported: false, inferred_country_code: nil, name: 'Hausa' , rtl: false },
  he: { is_bing_supported: true, inferred_country_code: 'IL', name: 'Hebrew' , rtl: true },
  hi: { is_bing_supported: true, inferred_country_code: nil, name: 'Hindi' , rtl: false },
  hr: { is_bing_supported: true, inferred_country_code: 'HR', name: 'Croatian' , rtl: false },
  ht: { is_bing_supported: true, inferred_country_code: nil, name: 'Creole' , rtl: false },
  hu: { is_bing_supported: true, inferred_country_code: 'HU', name: 'Hungarian' , rtl: false },
  hy: { is_bing_supported: true, inferred_country_code: nil, name: 'Armenian' , rtl: false },
  id: { is_bing_supported: true, inferred_country_code: nil, name: 'Indonesian' , rtl: false },
  is: { is_bing_supported: false, inferred_country_code: nil, name: 'Icelandic' , rtl: false },
  it: { is_bing_supported: true, inferred_country_code: 'IT', name: 'Italian' , rtl: false },
  ja: { is_bing_supported: true, inferred_country_code: 'JP', name: 'Japanese' , rtl: false },
  ka: { is_bing_supported: true, inferred_country_code: nil, name: 'Georgian' , rtl: false },
  km: { is_bing_supported: true, inferred_country_code: nil, name: 'Khmer' , rtl: false },
  ko: { is_bing_supported: true, inferred_country_code: 'KR', name: 'Korean' , rtl: false },
  kt: { is_bing_supported: false, inferred_country_code: nil, name: 'Kalaallisut' , rtl: false },
  ky: { is_bing_supported: false, inferred_country_code: nil, name: 'Kyrgyz' , rtl: false },
  lt: { is_bing_supported: true, inferred_country_code: 'LT', name: 'Lithuanian' , rtl: false },
  lv: { is_bing_supported: true, inferred_country_code: 'LV', name: 'Latvian' , rtl: false },
  me: { is_bing_supported: false, inferred_country_code: nil, name: 'Montenegrin' , rtl: false },
  mk: { is_bing_supported: true, inferred_country_code: nil, name: 'Macedonian' , rtl: false },
  mn: { is_bing_supported: false, inferred_country_code: nil, name: 'Mongolian' , rtl: false },
  ms: { is_bing_supported: false, inferred_country_code: nil, name: 'Malay' , rtl: false },
  nl: { is_bing_supported: true, inferred_country_code: 'NL', name: 'Dutch' , rtl: false },
  no: { is_bing_supported: false, inferred_country_code: nil, name: 'Norwegian' , rtl: false },
  pl: { is_bing_supported: true, inferred_country_code: 'PL', name: 'Polish' , rtl: false },
  ps: { is_bing_supported: true, inferred_country_code: nil, name: 'Pashto' , rtl: false },
  pt: { is_bing_supported: true, inferred_country_code: 'PT', name: 'Portuguese' , rtl: false },
  ro: { is_bing_supported: true, inferred_country_code: 'RO', name: 'Romanian' , rtl: false },
  ru: { is_bing_supported: true, inferred_country_code: 'RU', name: 'Russian' , rtl: false },
  sk: { is_bing_supported: true, inferred_country_code: 'SK', name: 'Slovak' , rtl: false },
  sl: { is_bing_supported: true, inferred_country_code: 'SL', name: 'Slovene' , rtl: false },
  so: { is_bing_supported: true, inferred_country_code: nil, name: 'Somalian' , rtl: false },
  sq: { is_bing_supported: true, inferred_country_code: nil, name: 'Albanian' , rtl: false },
  sr: { is_bing_supported: true, inferred_country_code: nil, name: 'Serbian' , rtl: false },
  sv: { is_bing_supported: false, inferred_country_code: 'SE', name: 'Swedish' , rtl: false },
  sw: { is_bing_supported: true, inferred_country_code: nil, name: 'Swahili' , rtl: false },
  tg: { is_bing_supported: false, inferred_country_code: nil, name: 'Tajik' , rtl: false },
  th: { is_bing_supported: true, inferred_country_code: 'TH', name: 'Thai' , rtl: false },
  tk: { is_bing_supported: false, inferred_country_code: nil, name: 'Turkmen' , rtl: false },
  tr: { is_bing_supported: true, inferred_country_code: 'TR', name: 'Turkish' , rtl: false },
  uk: { is_bing_supported: true, inferred_country_code: 'UA', name: 'Ukranian' , rtl: false },
  ur: { is_bing_supported: true, inferred_country_code: nil, name: 'Urdu' , rtl: true },
  uz: { is_bing_supported: true, inferred_country_code: nil, name: 'Uzbek' , rtl: false },
  vi: { is_bing_supported: true, inferred_country_code: nil, name: 'Vietnamese' , rtl: false },
  zh: { is_bing_supported: true, inferred_country_code: 'CN', name: 'Chinese' , rtl: false },
}

SEED_LANGUAGES.each do |code, language|
  engines = [ ]
  engines << 'Bing' if language[:is_bing_supported]

  show =
    case engines.count
    when 0
      "unsupported"
    when 1
      "#{engines[0]}-only"
    else
      engines.join('+')
    end

  show = "#{show} (RTL)" if language[:rtl]

  puts "Creating #{show} language #{code}: #{language[:name]}" unless Rails.env.test?
  Language.create(
    code:                  code,
    rtl:                   language[:rtl],
    is_bing_supported:     language[:is_bing_supported],
    name:                  language[:name],
    inferred_country_code: language[:inferred_country_code],
  )
end
