refactor: extract common code for number localization (#903)
This commit is contained in:
parent
71b19dbe68
commit
46c4fe1e5a
13 changed files with 75 additions and 92 deletions
|
@ -20,8 +20,6 @@ const {
|
|||
toggleReblog,
|
||||
} = $(useStatusActions(props))
|
||||
|
||||
const { formatHumanReadableNumber, formatNumber, forSR } = useHumanReadableNumber()
|
||||
|
||||
const reply = () => {
|
||||
if (!checkLogin())
|
||||
return
|
||||
|
@ -44,13 +42,10 @@ const reply = () => {
|
|||
@click="reply"
|
||||
>
|
||||
<template v-if="status.repliesCount" #text>
|
||||
<i18n-t keypath="action.reply_count" :plural="status.repliesCount">
|
||||
<CommonTooltip v-if="forSR(status.repliesCount)" :content="formatNumber(status.repliesCount)" placement="bottom">
|
||||
<span aria-hidden="true">{{ formatHumanReadableNumber(status.repliesCount) }}</span>
|
||||
<span sr-only>{{ formatNumber(status.repliesCount) }}</span>
|
||||
</CommonTooltip>
|
||||
<span v-else>{{ formatHumanReadableNumber(status.repliesCount) }}</span>
|
||||
</i18n-t>
|
||||
<CommonLocalizedNumber
|
||||
keypath="action.reply_count"
|
||||
:count="status.repliesCount"
|
||||
/>
|
||||
</template>
|
||||
</StatusActionButton>
|
||||
</div>
|
||||
|
@ -68,13 +63,10 @@ const reply = () => {
|
|||
@click="toggleReblog()"
|
||||
>
|
||||
<template v-if="status.reblogsCount" #text>
|
||||
<i18n-t keypath="action.boost_count" :plural="status.reblogsCount">
|
||||
<CommonTooltip v-if="forSR(status.reblogsCount)" :content="formatNumber(status.reblogsCount)" placement="bottom">
|
||||
<span aria-hidden="true">{{ formatHumanReadableNumber(status.reblogsCount) }}</span>
|
||||
<span sr-only>{{ formatNumber(status.reblogsCount) }}</span>
|
||||
</CommonTooltip>
|
||||
<span v-else>{{ formatHumanReadableNumber(status.reblogsCount) }}</span>
|
||||
</i18n-t>
|
||||
<CommonLocalizedNumber
|
||||
keypath="action.boost_count"
|
||||
:count="status.reblogsCount"
|
||||
/>
|
||||
</template>
|
||||
</StatusActionButton>
|
||||
</div>
|
||||
|
@ -92,13 +84,10 @@ const reply = () => {
|
|||
@click="toggleFavourite()"
|
||||
>
|
||||
<template v-if="status.favouritesCount" #text>
|
||||
<i18n-t keypath="action.favourite_count" :plural="status.favouritesCount">
|
||||
<CommonTooltip v-if="forSR(status.favouritesCount)" :content="formatNumber(status.favouritesCount)" placement="bottom">
|
||||
<span aria-hidden="true">{{ formatHumanReadableNumber(status.favouritesCount) }}</span>
|
||||
<span sr-only>{{ formatNumber(status.favouritesCount) }}</span>
|
||||
</CommonTooltip>
|
||||
<span v-else>{{ formatHumanReadableNumber(status.favouritesCount) }}</span>
|
||||
</i18n-t>
|
||||
<CommonLocalizedNumber
|
||||
keypath="action.favourite_count"
|
||||
:count="status.favouritesCount"
|
||||
/>
|
||||
</template>
|
||||
</StatusActionButton>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue