1
0

settings_helper.rb 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. is: 'Íslenska',
  35. it: 'Italiano',
  36. ja: '日本語',
  37. ka: 'ქართული',
  38. kab: 'Taqbaylit',
  39. kk: 'Қазақша',
  40. kn: 'ಕನ್ನಡ',
  41. ko: '한국어',
  42. ku: 'سۆرانی',
  43. lt: 'Lietuvių',
  44. lv: 'Latviešu',
  45. mk: 'Македонски',
  46. ml: 'മലയാളം',
  47. mr: 'मराठी',
  48. ms: 'Bahasa Melayu',
  49. nl: 'Nederlands',
  50. nn: 'Nynorsk',
  51. no: 'Norsk',
  52. oc: 'Occitan',
  53. pl: 'Polski',
  54. 'pt-BR': 'Português (Brasil)',
  55. 'pt-PT': 'Português (Portugal)',
  56. pt: 'Português',
  57. ro: 'Română',
  58. ru: 'Русский',
  59. sa: 'संस्कृतम्',
  60. sc: 'Sardu',
  61. sk: 'Slovenčina',
  62. sl: 'Slovenščina',
  63. sq: 'Shqip',
  64. 'sr-Latn': 'Srpski (latinica)',
  65. sr: 'Српски',
  66. sv: 'Svenska',
  67. ta: 'தமிழ்',
  68. te: 'తెలుగు',
  69. th: 'ไทย',
  70. tr: 'Türkçe',
  71. uk: 'Українська',
  72. ur: 'اُردُو',
  73. vi: 'Tiếng Việt',
  74. zgh: 'ⵜⴰⵎⴰⵣⵉⵖⵜ',
  75. 'zh-CN': '简体中文',
  76. 'zh-HK': '繁體中文(香港)',
  77. 'zh-TW': '繁體中文(臺灣)',
  78. zh: '中文',
  79. }.freeze
  80. def human_locale(locale)
  81. HUMAN_LOCALES[locale]
  82. end
  83. def filterable_languages
  84. LanguageDetector.instance.language_names.select(&HUMAN_LOCALES.method(:key?))
  85. end
  86. def hash_to_object(hash)
  87. HashObject.new(hash)
  88. end
  89. def session_device_icon(session)
  90. device = session.detection.device
  91. if device.mobile?
  92. 'mobile'
  93. elsif device.tablet?
  94. 'tablet'
  95. else
  96. 'desktop'
  97. end
  98. end
  99. def compact_account_link_to(account)
  100. return if account.nil?
  101. link_to ActivityPub::TagManager.instance.url_for(account), class: 'name-tag', title: account.acct do
  102. safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: display_name(account), class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ')
  103. end
  104. end
  105. def picture_hint(hint, picture)
  106. if picture.original_filename.nil?
  107. hint
  108. else
  109. link = link_to t('generic.delete'), settings_profile_picture_path(picture.name.to_s), data: { method: :delete }
  110. safe_join([hint, link], '<br/>'.html_safe)
  111. end
  112. end
  113. end