diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-05-26 23:30:10 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-05-26 23:30:10 +0200 |
commit | 3f10136a41b841897f7a69fb7b2c4d13abf4de53 (patch) | |
tree | 01ff7496b04b558ba8702ec15c2ce56df9addcba /app/helpers | |
parent | 6d13901e4c1f660a25420b623cbfea6966b218b9 (diff) | |
parent | fbcbf7898f000d9d1a21d52e8a8d3ed4602aa7db (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/formatting_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/languages_helper.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/app/helpers/formatting_helper.rb b/app/helpers/formatting_helper.rb index 526efd766..448177bec 100644 --- a/app/helpers/formatting_helper.rb +++ b/app/helpers/formatting_helper.rb @@ -23,7 +23,7 @@ module FormattingHelper before_html = begin if status.spoiler_text? - "<p><strong>#{I18n.t('rss.content_warning', locale: valid_locale_or_nil(status.language))}</strong> #{h(status.spoiler_text)}</p><hr />" + "<p><strong>#{I18n.t('rss.content_warning', locale: available_locale_or_nil(status.language) || I18n.default_locale)}</strong> #{h(status.spoiler_text)}</p><hr />" else '' end diff --git a/app/helpers/languages_helper.rb b/app/helpers/languages_helper.rb index d39bb6c93..4077e19bd 100644 --- a/app/helpers/languages_helper.rb +++ b/app/helpers/languages_helper.rb @@ -254,4 +254,8 @@ module LanguagesHelper def valid_locale?(locale) locale.present? && SUPPORTED_LOCALES.key?(locale.to_sym) end + + def available_locale_or_nil(locale_name) + locale_name.to_sym if locale_name.present? && I18n.available_locales.include?(locale_name.to_sym) + end end |