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.

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