You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.2 KiB

  1. # frozen_string_literal: true
  2. module SettingsHelper
  3. HUMAN_LOCALES = {
  4. en: 'English',
  5. ar: 'العربية',
  6. bg: 'Български',
  7. ca: 'Català',
  8. de: 'Deutsch',
  9. eo: 'Esperanto',
  10. es: 'Español',
  11. fa: 'فارسی',
  12. fi: 'Suomi',
  13. fr: 'Français',
  14. he: 'עברית',
  15. hr: 'Hrvatski',
  16. hu: 'Magyar',
  17. id: 'Bahasa Indonesia',
  18. io: 'Ido',
  19. it: 'Italiano',
  20. ja: '日本語',
  21. ko: '한국어',
  22. nl: 'Nederlands',
  23. no: 'Norsk',
  24. oc: 'Occitan',
  25. pl: 'Polszczyzna',
  26. pt: 'Português',
  27. 'pt-BR': 'Português do Brasil',
  28. ru: 'Русский',
  29. th: 'ภาษาไทย',
  30. tr: 'Türkçe',
  31. uk: 'Українська',
  32. zh: '中文',
  33. 'zh-CN': '简体中文',
  34. 'zh-HK': '繁體中文(香港)',
  35. 'zh-TW': '繁體中文(臺灣)',
  36. }.freeze
  37. def human_locale(locale)
  38. HUMAN_LOCALES[locale]
  39. end
  40. def filterable_languages
  41. I18n.available_locales.map { |locale| locale.to_s.split('-').first.to_sym }.uniq
  42. end
  43. def hash_to_object(hash)
  44. HashObject.new(hash)
  45. end
  46. def session_device_icon(session)
  47. device = session.detection.device
  48. if device.mobile?
  49. 'mobile'
  50. elsif device.tablet?
  51. 'tablet'
  52. else
  53. 'desktop'
  54. end
  55. end
  56. end