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.

71 lines
1.5 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. el: 'Ελληνικά',
  10. eo: 'Esperanto',
  11. es: 'Español',
  12. eu: 'Euskara',
  13. fa: 'فارسی',
  14. fi: 'Suomi',
  15. fr: 'Français',
  16. gl: 'Galego',
  17. he: 'עברית',
  18. hr: 'Hrvatski',
  19. hu: 'Magyar',
  20. hy: 'Հայերեն',
  21. id: 'Bahasa Indonesia',
  22. io: 'Ido',
  23. it: 'Italiano',
  24. ja: '日本語',
  25. ko: '한국어',
  26. nl: 'Nederlands',
  27. no: 'Norsk',
  28. oc: 'Occitan',
  29. pl: 'Polszczyzna',
  30. pt: 'Português',
  31. 'pt-BR': 'Português do Brasil',
  32. ru: 'Русский',
  33. sk: 'Slovensky',
  34. sr: 'Српски',
  35. 'sr-Latn': 'Srpski (latinica)',
  36. sv: 'Svenska',
  37. te: 'తెలుగు',
  38. th: 'ภาษาไทย',
  39. tr: 'Türkçe',
  40. uk: 'Українська',
  41. zh: '中文',
  42. 'zh-CN': '简体中文',
  43. 'zh-HK': '繁體中文(香港)',
  44. 'zh-TW': '繁體中文(臺灣)',
  45. }.freeze
  46. def human_locale(locale)
  47. HUMAN_LOCALES[locale]
  48. end
  49. def filterable_languages
  50. LanguageDetector.instance.language_names.select(&HUMAN_LOCALES.method(:key?))
  51. end
  52. def hash_to_object(hash)
  53. HashObject.new(hash)
  54. end
  55. def session_device_icon(session)
  56. device = session.detection.device
  57. if device.mobile?
  58. 'mobile'
  59. elsif device.tablet?
  60. 'tablet'
  61. else
  62. 'desktop'
  63. end
  64. end
  65. end