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.

63 lines
1.3 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. sv: 'Svenska',
  30. th: 'ภาษาไทย',
  31. tr: 'Türkçe',
  32. uk: 'Українська',
  33. zh: '中文',
  34. 'zh-CN': '简体中文',
  35. 'zh-HK': '繁體中文(香港)',
  36. 'zh-TW': '繁體中文(臺灣)',
  37. }.freeze
  38. def human_locale(locale)
  39. HUMAN_LOCALES[locale]
  40. end
  41. def filterable_languages
  42. LanguageDetector.instance.language_names.select(&HUMAN_LOCALES.method(:key?))
  43. end
  44. def hash_to_object(hash)
  45. HashObject.new(hash)
  46. end
  47. def session_device_icon(session)
  48. device = session.detection.device
  49. if device.mobile?
  50. 'mobile'
  51. elsif device.tablet?
  52. 'tablet'
  53. else
  54. 'desktop'
  55. end
  56. end
  57. end