diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-07-08 16:17:19 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2021-07-08 16:17:19 +0200 |
commit | 3160e050a95afe47317e82956f055a5ab6030698 (patch) | |
tree | 957699d2b99e6d0024560d790a011a30e60ddd3b /app/helpers | |
parent | 0c2eb949fc21ceecbd99a81e5ffe75517a1e64df (diff) | |
parent | c4568e3b606cc4007739f881c334bdfe8dc77745 (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `app/helpers/accounts_helper.rb`: Conflict due to upstream changing how followers count is displayed while we have an option to hide followers count. Ported upstream change. - `app/views/accounts/_header.html.haml`: Conflict due to upstream changing how followers count is displayed while we have an option to hide followers count. Ported upstream change. - `app/views/directories/index.html.haml`: Conflict due to upstream changing how followers count is displayed while we have an option to hide followers count. Ported upstream change.
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/accounts_helper.rb | 6 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb index e977db2c6..bb2374c0e 100644 --- a/app/helpers/accounts_helper.rb +++ b/app/helpers/accounts_helper.rb @@ -84,19 +84,19 @@ module AccountsHelper def account_description(account) prepend_stats = [ [ - number_to_human(account.statuses_count, strip_insignificant_zeros: true), + number_to_human(account.statuses_count, precision: 3, strip_insignificant_zeros: true), I18n.t('accounts.posts', count: account.statuses_count), ].join(' '), [ - number_to_human(account.following_count, strip_insignificant_zeros: true), + number_to_human(account.following_count, precision: 3, strip_insignificant_zeros: true), I18n.t('accounts.following', count: account.following_count), ].join(' '), ] unless hide_followers_count?(account) prepend_stats << [ - number_to_human(account.followers_count, strip_insignificant_zeros: true), + number_to_human(account.followers_count, precision: 3, strip_insignificant_zeros: true), I18n.t('accounts.followers', count: account.followers_count), ].join(' ') end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5a9496bd4..cc622478d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -14,6 +14,17 @@ module ApplicationHelper ku ).freeze + def friendly_number_to_human(number, **options) + # By default, the number of precision digits used by number_to_human + # is looked up from the locales definition, and rails-i18n comes with + # values that don't seem to make much sense for many languages, so + # override these values with a default of 3 digits of precision. + options[:precision] = 3 + options[:strip_insignificant_zeros] = true + + number_to_human(number, **options) + end + def active_nav_class(*paths) paths.any? { |path| current_page?(path) } ? 'active' : '' end |