settings_helper.rb 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # frozen_string_literal: true
  2. module SettingsHelper
  3. HUMAN_LOCALES = {
  4. ar: 'العربية',
  5. ast: 'Asturianu',
  6. bg: 'Български',
  7. bn: 'বাংলা',
  8. br: 'Breton',
  9. ca: 'Català',
  10. co: 'Corsu',
  11. cs: 'Čeština',
  12. cy: 'Cymraeg',
  13. da: 'Dansk',
  14. de: 'Deutsch',
  15. el: 'Ελληνικά',
  16. en: 'English',
  17. eo: 'Esperanto',
  18. 'es-AR': 'Español (Argentina)',
  19. es: 'Español',
  20. et: 'Eesti',
  21. eu: 'Euskara',
  22. fa: 'فارسی',
  23. fi: 'Suomi',
  24. fr: 'Français',
  25. ga: 'Gaeilge',
  26. gl: 'Galego',
  27. he: 'עברית',
  28. hi: 'हिन्दी',
  29. hr: 'Hrvatski',
  30. hu: 'Magyar',
  31. hy: 'Հայերեն',
  32. id: 'Bahasa Indonesia',
  33. io: 'Ido',
  34. it: 'Italiano',
  35. ja: '日本語',
  36. ka: 'ქართული',
  37. kk: 'Қазақша',
  38. ko: '한국어',
  39. lt: 'Lietuvių',
  40. lv: 'Latviešu',
  41. mk: 'Македонски',
  42. ml: 'മലയാളം',
  43. ms: 'Bahasa Melayu',
  44. nl: 'Nederlands',
  45. nn: 'Nynorsk',
  46. no: 'Norsk',
  47. oc: 'Occitan',
  48. pl: 'Polski',
  49. 'pt-BR': 'Português (Brasil)',
  50. 'pt-PT': 'Português (Portugal)',
  51. pt: 'Português',
  52. ro: 'Română',
  53. ru: 'Русский',
  54. sk: 'Slovenčina',
  55. sl: 'Slovenščina',
  56. sq: 'Shqip',
  57. 'sr-Latn': 'Srpski (latinica)',
  58. sr: 'Српски',
  59. sv: 'Svenska',
  60. ta: 'தமிழ்',
  61. te: 'తెలుగు',
  62. th: 'ไทย',
  63. tr: 'Türkçe',
  64. uk: 'Українська',
  65. 'zh-CN': '简体中文',
  66. 'zh-HK': '繁體中文(香港)',
  67. 'zh-TW': '繁體中文(臺灣)',
  68. zh: '中文',
  69. }.freeze
  70. def human_locale(locale)
  71. HUMAN_LOCALES[locale]
  72. end
  73. def filterable_languages
  74. LanguageDetector.instance.language_names.select(&HUMAN_LOCALES.method(:key?))
  75. end
  76. def hash_to_object(hash)
  77. HashObject.new(hash)
  78. end
  79. def session_device_icon(session)
  80. device = session.detection.device
  81. if device.mobile?
  82. 'mobile'
  83. elsif device.tablet?
  84. 'tablet'
  85. else
  86. 'desktop'
  87. end
  88. end
  89. def compact_account_link_to(account)
  90. return if account.nil?
  91. link_to ActivityPub::TagManager.instance.url_for(account), class: 'name-tag', title: account.acct do
  92. safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: display_name(account), class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ')
  93. end
  94. end
  95. end