From 46c4fe1e5a540a83fe339a010a5815fda565d271 Mon Sep 17 00:00:00 2001 From: Ivan Demchuk Date: Mon, 9 Jan 2023 13:24:26 +0200 Subject: [PATCH] refactor: extract common code for number localization (#903) --- CONTRIBUTING.md | 4 +- components/account/AccountPostsFollowers.vue | 52 +++++++------------ components/common/LocalizedNumber.vue | 26 ++++++++++ .../NotificationGroupedFollow.vue | 20 ++----- components/status/StatusActions.vue | 35 +++++-------- components/status/StatusPoll.vue | 16 ++---- locales/ar-EG.json | 2 +- locales/en-GB.json | 2 +- locales/en-US.json | 2 +- locales/es-ES.json | 2 +- locales/fr-FR.json | 2 +- locales/nl-NL.json | 2 +- locales/uk-UA.json | 2 +- 13 files changed, 75 insertions(+), 92 deletions(-) create mode 100644 components/common/LocalizedNumber.vue diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 943dd293..20a36e2a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -132,7 +132,7 @@ You can run this code in your browser console to see how it works: #### Custom Plural Number Formatting Entries **Warning**: -Either **{0}**, **{v}** or **{followers}** should be used with the exception being custom plurals entries using the `{n}` placeholder. +Either **{0}** or **{v}** should be used with the exception being custom plurals entries using the `{n}` placeholder. This is the full list of entries that will be available for number formatting in Elk: - `action.boost_count` (no need to be included, we should use always `en-US` entry): `{0}` for formatted number and `{n}` for raw number - **{0} should be use** @@ -142,7 +142,7 @@ This is the full list of entries that will be available for number formatting in - `account.following_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use** - `account.posts_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use** - `compose.drafts`: `{v}` for formatted number and `{n}` for raw number - **{v} should be use** -- `notification.followed_you_count`: `{followers}` for formatted number and `{n}` for raw number - **{followers} should be use** +- `notification.followed_you_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use** - `status.poll.count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use** - `time_ago_options.*`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use**: since numbers will be always small, we can also use `{n}` - `timeline.show_new_items`: `{v}` for formatted number and `{n}` for raw number - **{v} should be use** diff --git a/components/account/AccountPostsFollowers.vue b/components/account/AccountPostsFollowers.vue index c004adb9..9aaba0d0 100644 --- a/components/account/AccountPostsFollowers.vue +++ b/components/account/AccountPostsFollowers.vue @@ -1,17 +1,9 @@