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.

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