Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix localization of counts #4011

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/renderer/components/ft-list-channel/ft-list-channel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineComponent } from 'vue'
import { youtubeImageUrlToInvidious } from '../../helpers/api/invidious'
import { formatNumber } from '../../helpers/utils'
import { parseLocalSubscriberCount } from '../../helpers/api/local'

export default defineComponent({
name: 'FtListChannel',
Expand All @@ -20,7 +21,9 @@ export default defineComponent({
thumbnail: '',
channelName: '',
subscriberCount: 0,
videoCount: '',
videoCount: 0,
formattedSubscriberCount: '',
formattedVideoCount: '',
handle: null,
description: ''
}
Expand Down Expand Up @@ -53,14 +56,16 @@ export default defineComponent({

this.channelName = this.data.name
this.id = this.data.id
this.subscriberCount = this.data.subscribers != null ? this.data.subscribers.replace(/ subscriber(s)?/, '') : null

if (this.data.videos === null) {
this.videoCount = 0
if (this.data.subscribers != null) {
this.subscriberCount = parseLocalSubscriberCount(this.data.subscribers.replace(/ subscriber(s)?/, ''))
this.formattedSubscriberCount = formatNumber(this.subscriberCount)
} else {
this.videoCount = formatNumber(this.data.videos)
this.subscriberCount = null
}

this.videoCount = this.data.videos ?? 0
this.formattedVideoCount = formatNumber(this.videoCount)

if (this.data.handle) {
this.handle = this.data.handle
}
Expand All @@ -76,8 +81,10 @@ export default defineComponent({

this.channelName = this.data.author
this.id = this.data.authorId
this.subscriberCount = formatNumber(this.data.subCount)
this.videoCount = formatNumber(this.data.videoCount)
this.subscriberCount = this.data.subCount
this.videoCount = this.data.videoCount
this.formattedVideoCount = formatNumber(this.data.videoCount)
this.formattedSubscriberCount = formatNumber(this.data.subCount)
this.description = this.data.description
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/ft-list-channel/ft-list-channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
v-if="subscriberCount !== null && !hideChannelSubscriptions"
class="subscriberCount"
>
{{ subscriberCount }} subscribers -
{{ $tc('Global.Counts.Subscriber Count', subscriberCount, {count: formattedSubscriberCount}) }}
</span>
<router-link
v-if="handle !== null"
Expand All @@ -47,7 +47,7 @@
v-else
class="videoCount"
>
{{ videoCount }} videos
{{ $tc('Global.Counts.Video Count', videoCount, {count: formattedVideoCount}) }}
</span>
</div>
<p
Expand Down
9 changes: 5 additions & 4 deletions src/renderer/components/ft-list-video/ft-list-video.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@
<span>{{ channelName }}</span>
</router-link>
<template v-if="!isLive && !isUpcoming && !isPremium && !hideViews">
<span class="viewCount"><template v-if="channelId !== null"> •</template> {{ parsedViewCount }} </span>
<span v-if="viewCount === 1">{{ $t("Video.View").toLowerCase() }}</span>
<span v-else>{{ $t("Video.Views").toLowerCase() }}</span>
<span class="viewCount">
<template v-if="channelId !== null"> • </template>
{{ $tc('Global.Counts.View Count', viewCount, {count: parsedViewCount}) }}
</span>
</template>
<span
v-if="uploadedTime !== '' && !isLive && !inHistory"
Expand All @@ -105,7 +106,7 @@
<span
v-if="isLive && !hideViews"
class="viewCount"
> • {{ parsedViewCount }} {{ $t("Video.Watching").toLowerCase() }}</span>
> • {{ $tc('Global.Counts.Watching Count', viewCount, {count: parsedViewCount}) }}</span>
</div>
<ft-icon-button
class="optionsButton"
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/watch-video-info/watch-video-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ export default defineComponent({
if (this.hideVideoViews) {
return null
}
return formatNumber(this.viewCount) + ` ${this.$t('Video.Views').toLowerCase()}`

return this.$tc('Global.Counts.View Count', this.viewCount, { count: formatNumber(this.viewCount) })
},

dateString: function () {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function calculatePublishedDate(publishedText) {

export function toLocalePublicationString ({ publishText, isLive = false, isUpcoming = false, isRSS = false }) {
if (isLive) {
return '0' + i18n.t('Video.Watching')
return i18n.tc('Global.Counts.Watching Count', 0, { count: 0 })
} else if (isUpcoming || publishText === null) {
// the check for null is currently just an inferring of knowledge, because there is no other possibility left
return `${i18n.t('Video.Published.Upcoming')}: ${publishText}`
Expand Down
4 changes: 1 addition & 3 deletions src/renderer/views/Channel/Channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
v-if="subCount !== null && !hideChannelSubscriptions"
class="channelSubCount"
>
{{ formattedSubCount }}
<span v-if="subCount === 1">{{ $t("Channel.Subscriber") }}</span>
<span v-else>{{ $t("Channel.Subscribers") }}</span>
{{ $tc('Global.Counts.Subscriber Count', subCount, { count: formattedSubCount }) }}
</p>
</div>
</div>
Expand Down
5 changes: 0 additions & 5 deletions static/locales/ar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,6 @@ Profile:
Profile Settings: إعدادات الملف الشخصي
Toggle Profile List: تبديل قائمة الملف الشخصي
Channel:
Subscriber: 'مُشترِك'
Subscribers: 'مُشترِكين'
Subscribe: 'اشتراك'
Unsubscribe: 'إلغاء الاشتراك'
Search Channel: 'ابحث في القناة'
Expand Down Expand Up @@ -671,10 +669,7 @@ Video:
Copy YouTube Embedded Player Link: 'انسخ رابط مشغل اليوتيوب المُضمّن'
Open in Invidious: 'إفتح على انفيديوس'
Copy Invidious Link: 'انسخ رابط انفيديوس'
View: 'عرض'
Views: 'مشاهدات'
# Context is "X People Watching"
Watching: 'يتم مشاهدته'
Watched: 'مُشاهد'
# As in a Live Video
Live: '‏‏‪مُباشر'
Expand Down
5 changes: 0 additions & 5 deletions static/locales/bg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,6 @@ Profile:
Profile Settings: Настройки на профил
Toggle Profile List: Превключване на списъка с профили
Channel:
Subscriber: 'Абонат'
Subscribers: 'Абонати'
Subscribe: 'Абониране'
Unsubscribe: 'Отписване'
Channel has been removed from your subscriptions: 'Каналът беше премахнат от вашите
Expand Down Expand Up @@ -688,15 +686,12 @@ Video:
Copy YouTube Embedded Player Link: 'Копиране на връзка за вградения YouTube плейър'
Open in Invidious: 'Отваряне в Invidious'
Copy Invidious Link: 'Копиране на връзка за Invidious'
View: 'показване'
Views: 'Показвания'
Loop Playlist: 'Повтаряне на плейлиста'
Shuffle Playlist: 'Разбъркване на плейлиста'
Reverse Playlist: 'Обръщане на плейлиста'
Play Next Video: 'Следващо видео'
Play Previous Video: 'Предишно видео'
# Context is "X People Watching"
Watching: 'Гледащи'
Watched: 'Гледано'
Autoplay: 'Автоматично пускане'
Starting soon, please refresh the page to check again: 'Започва скоро, моля опреснете
Expand Down
5 changes: 0 additions & 5 deletions static/locales/ca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,6 @@ Profile:
Profile Settings: Configuració del perfil
Profile Filter: Filtre de perfil
Channel:
Subscriber: 'Subscriptor'
Subscribers: 'Subscriptors'
Subscribe: 'Subscriu-te'
Unsubscribe: 'Des-subscriu-te'
Channel has been removed from your subscriptions: 'El canal s''ha eliminat de les
Expand Down Expand Up @@ -484,15 +482,12 @@ Video:
Copy YouTube Embedded Player Link: 'Copia el Enllaç del Reproductor de YouTube Incrustat'
Open in Invidious: 'Obri a Invidious'
Copy Invidious Link: 'Copia Enllaç d''Invidious'
View: 'Visualitza'
Views: 'Visualitzacions'
Loop Playlist: 'Llista de reproducció en bucle'
Shuffle Playlist: 'Llista de reproducció en aleatori'
Reverse Playlist: 'Llista de reproducció invertida'
Play Next Video: 'Reprodueix el vídeo següent'
Play Previous Video: 'Reprodueix el vídeo anterior'
# Context is "X People Watching"
Watching: 'Visualitzant'
Watched: 'Visualitzat'
Autoplay: 'Reproducció Automàtica'
# As in a Live Video
Expand Down
5 changes: 0 additions & 5 deletions static/locales/cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,6 @@ Profile:
Profile Settings: Nastavení profilu
Toggle Profile List: Přepnout seznam profilů
Channel:
Subscriber: 'Odběratel'
Subscribers: 'odběratelů'
Subscribe: 'Odebírat'
Unsubscribe: 'Zrušit odběr'
Channel has been removed from your subscriptions: 'Kanál byl odebrán z vašich odběrů'
Expand Down Expand Up @@ -676,15 +674,12 @@ Video:
Copy YouTube Channel Link: 'Kopírovat odkaz kanálu YouTube'
Open Channel in Invidious: 'Otevřít kanál v Invidious'
Copy Invidious Channel Link: 'Kopírovat odkaz Invidious kanálu'
View: 'Zhlédnutí'
Views: 'Zhlédnutí'
Loop Playlist: 'Smyčka playlistu'
Shuffle Playlist: 'Zamíchat playlist'
Reverse Playlist: 'Obrátit playlist'
Play Next Video: 'Přehrát další video'
Play Previous Video: 'Přehrát předchozí video'
# Context is "X People Watching"
Watching: 'Sledujících'
Watched: 'Zhlédnuto'
Autoplay: 'Automatické přehrávání'
Starting soon, please refresh the page to check again: 'Začínáme brzy, obnovte prosím
Expand Down
5 changes: 0 additions & 5 deletions static/locales/da.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,6 @@ Profile:
Profile Filter: Profilfilter
Profile Settings: Profilindstillinger
Channel:
Subscriber: 'Abonnent'
Subscribers: 'Abonnenter'
Subscribe: 'Abonnér'
Unsubscribe: 'Afmeld'
Channel has been removed from your subscriptions: 'Kanal er blevet fjernet fra dine
Expand Down Expand Up @@ -581,15 +579,12 @@ Video:
Copy YouTube Embedded Player Link: 'Kopiér YouTube Indbygget Afspiller-Link'
Open in Invidious: 'Åbn i Invidious'
Copy Invidious Link: 'Kopiér Indvidious-Link'
View: 'Vis'
Views: 'Visninger'
Loop Playlist: 'Gentag Playliste'
Shuffle Playlist: 'Bland Playliste'
Reverse Playlist: 'Vend Playliste Om'
Play Next Video: 'Afspil Næste Video'
Play Previous Video: 'Afspil Forrige Video'
# Context is "X People Watching"
Watching: 'Ser'
Watched: 'Set'
Autoplay: 'Autospil'
Starting soon, please refresh the page to check again: 'Begynder snart, genopfrisk
Expand Down
5 changes: 0 additions & 5 deletions static/locales/de-DE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,6 @@ About:
Source code: Quellcode
Discussions: Diskussionen
Channel:
Subscriber: Abonnement
Subscribers: Abonnements
Subscribe: Abonnieren
Unsubscribe: Deabonnieren
Search Channel: Durchsuche Kanal
Expand Down Expand Up @@ -653,10 +651,7 @@ Video:
Copy YouTube Embedded Player Link: Link des eingebetteten YouTube-Abspieler kopieren
Open in Invidious: In Invidious öffnen
Copy Invidious Link: Invidious-Link kopieren
View: Aufruf
Views: Aufrufe
# Context is "X People Watching"
Watching: aktive Zuschauer
Watched: Gesehen
# As in a Live Video
Live: Live
Expand Down
5 changes: 0 additions & 5 deletions static/locales/el.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,6 @@ Profile:
Profile Settings: Ρυθμίσεις προφίλ
Toggle Profile List: Εναλλαγή Λίστας Προφίλ
Channel:
Subscriber: 'Συνδρομητής'
Subscribers: 'Συνδρομητές'
Subscribe: 'Εγγραφή'
Unsubscribe: 'Απεγγραφή'
Channel has been removed from your subscriptions: 'Το κανάλι έχει καταργηθεί από
Expand Down Expand Up @@ -707,15 +705,12 @@ Video:
αναπαραγωγής από το YouTube'
Open in Invidious: 'Άνοιγμα στο Invidious'
Copy Invidious Link: 'Αντιγραφή συνδέσμου Invidious'
View: 'Προβολή'
Views: 'Προβολές'
Loop Playlist: 'Επανάληψη λίστας αναπαραγωγής'
Shuffle Playlist: 'Τυχαία σειρά στη λίστα αναπαραγωγής'
Reverse Playlist: 'Αντιστροφή της λίστας αναπαραγωγής'
Play Next Video: 'Αναπαραγωγή επόμενου βίντεο'
Play Previous Video: 'Αναπαραγωγή προηγούμενου βίντεο'
# Context is "X People Watching"
Watching: 'Παρακολουθούν τώρα'
Watched: 'Παρακολουθήθηκε'
Autoplay: 'Αυτόματη αναπαραγωγή'
# As in a Live Video
Expand Down
8 changes: 3 additions & 5 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Global:
Counts:
Video Count: 1 video | {count} videos
Channel Count: 1 channel | {count} channels
Subscriber Count: 1 subscriber | {count} subscribers
View Count: 1 view | {count} views
Watching Count: 1 watching | {count} watching
Comment on lines +51 to +53
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though not mentioned by
https://kazupon.github.io/vue-i18n/guide/pluralization.html#pluralization

When zero value not provided and count is zero, the plural version is used (I tested locally) (for en at least)


# Search Bar
Search / Go to URL: Search / Go to URL
Expand Down Expand Up @@ -541,8 +544,6 @@ Profile:
from any other profile.
#On Channel Page
Channel:
Subscriber: Subscriber
Subscribers: Subscribers
Subscribe: Subscribe
Unsubscribe: Unsubscribe
Channel has been removed from your subscriptions: Channel has been removed from
Expand Down Expand Up @@ -619,16 +620,13 @@ Video:
Copy YouTube Channel Link: Copy YouTube Channel Link
Open Channel in Invidious: Open Channel in Invidious
Copy Invidious Channel Link: Copy Invidious Channel Link
View: View
Views: Views
Loop Playlist: Loop Playlist
Shuffle Playlist: Shuffle Playlist
Reverse Playlist: Reverse Playlist
Play Next Video: Play Next Video
Play Previous Video: Play Previous Video
Pause on Current Video: Pause on Current Video
# Context is "X People Watching"
Watching: Watching
Watched: Watched
Autoplay: Autoplay
Starting soon, please refresh the page to check again: Starting soon, please refresh
Expand Down
5 changes: 0 additions & 5 deletions static/locales/en_GB.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,6 @@ Profile:
Profile Filter: Profile Filter
'{number} selected': '{number} selected'
Channel:
Subscriber: 'Subscriber'
Subscribers: 'Subscribers'
Subscribe: 'Subscribe'
Unsubscribe: 'Unsubscribe'
Channel has been removed from your subscriptions: 'Channel has been removed from
Expand Down Expand Up @@ -649,15 +647,12 @@ Video:
Copy YouTube Embedded Player Link: 'Copy YouTube Embedded Player Link'
Open in Invidious: 'Open in Invidious'
Copy Invidious Link: 'Copy Invidious Link'
View: 'View'
Views: 'Views'
Loop Playlist: 'Loop Playlist'
Shuffle Playlist: 'Shuffle Playlist'
Reverse Playlist: 'Reverse Playlist'
Play Next Video: 'Play Next Video'
Play Previous Video: 'Play Previous Video'
# Context is "X People Watching"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do see that we're not including this comment anymore, which I think is fine as the pluralization and placement makes the context of the translation label more intuitive. As a sidenote, comments like these do make me wonder if having implicit subjects/objects in our labels is a burden for [a subset of] our translators; I have no idea.

Watching: 'Watching'
Watched: 'Watched'
Autoplay: 'Autoplay'
Starting soon, please refresh the page to check again: 'Starting soon, please refresh
Expand Down
5 changes: 0 additions & 5 deletions static/locales/es-MX.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,6 @@ About:
Donate: Donar
Credits: Créditos
Channel:
Subscriber: 'Suscriptor'
Subscribers: 'Suscriptores'
Subscribe: 'Suscribir'
Unsubscribe: 'Desuscribir'
Search Channel: 'Buscar canal'
Expand Down Expand Up @@ -490,10 +488,7 @@ Video:
YouTube'
Open in Invidious: 'Abrir en Invidious'
Copy Invidious Link: 'Copiar enlace de Invidious'
View: 'Ver'
Views: 'Vistas'
# Context is "X People Watching"
Watching: 'Viendo'
Watched: 'Visto'
# As in a Live Video
Live: 'En vivo'
Expand Down
5 changes: 0 additions & 5 deletions static/locales/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,6 @@ Profile:
Profile Settings: Ajustes del perfil
Toggle Profile List: Alternar la lista de los perfiles
Channel:
Subscriber: 'Suscriptor'
Subscribers: 'Suscriptores'
Subscribe: 'Suscribirse'
Unsubscribe: 'Anular suscripción'
Search Channel: 'Buscar en canal'
Expand Down Expand Up @@ -684,10 +682,7 @@ Video:
YouTube'
Open in Invidious: 'Abrir en Invidious'
Copy Invidious Link: 'Copiar el enlace de Invidious'
View: 'Ver'
Views: 'Vistas'
# Context is "X People Watching"
Watching: 'Viendo'
Watched: 'Visto'
Autoplay: 'Reproducción automática'
# As in a Live Video
Expand Down
Loading