settings_helper.rb 3.0 KB

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