1
0

settings_helper.rb 2.8 KB

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