summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--locales/en-US.json30
-rw-r--r--locales/fa.json25
-rw-r--r--locales/fr.json30
-rw-r--r--locales/id.json25
-rw-r--r--locales/it.json30
-rw-r--r--locales/ja.json25
-rw-r--r--locales/ko.json25
-rw-r--r--locales/vi.json9
-rw-r--r--locales/zh-CN.json25
-rw-r--r--locales/zh-TW.json25
-rw-r--r--src/invidious/channels/community.cr2
-rw-r--r--src/invidious/helpers/i18n.cr19
-rw-r--r--src/invidious/views/components/item.ecr10
-rw-r--r--src/invidious/views/edit_playlist.ecr2
-rw-r--r--src/invidious/views/feeds/history.ecr4
-rw-r--r--src/invidious/views/playlist.ecr4
-rw-r--r--src/invidious/views/subscription_manager.ecr2
-rw-r--r--src/invidious/views/watch.ecr2
18 files changed, 92 insertions, 202 deletions
diff --git a/locales/en-US.json b/locales/en-US.json
index 166143ac..9d3a70d2 100644
--- a/locales/en-US.json
+++ b/locales/en-US.json
@@ -1,16 +1,14 @@
{
- "`x` subscribers": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` subscriber",
- "": "`x` subscribers"
- },
- "`x` videos": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` video",
- "": "`x` videos"
- },
- "`x` playlists": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` playlist",
- "": "`x` playlists"
- },
+ "generic_views_count": "{{count}} view",
+ "generic_views_count_plural": "{{count}} views",
+ "generic_videos_count": "{{count}} video",
+ "generic_videos_count_plural": "{{count}} videos",
+ "generic_playlists_count": "{{count}} playlist",
+ "generic_playlists_count_plural": "{{count}} playlists",
+ "generic_subscribers_count": "{{count}} subscriber",
+ "generic_subscribers_count_plural": "{{count}} subscribers",
+ "generic_subscriptions_count": "{{count}} subscription",
+ "generic_subscriptions_count_plural": "{{count}} subscriptions",
"LIVE": "LIVE",
"Shared `x` ago": "Shared `x` ago",
"Unsubscribe": "Unsubscribe",
@@ -146,10 +144,6 @@
"Subscription manager": "Subscription manager",
"Token manager": "Token manager",
"Token": "Token",
- "`x` subscriptions": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` subscription",
- "": "`x` subscriptions"
- },
"`x` tokens": {
"([^.,0-9]|^)1([^.,0-9]|$)": "`x` token",
"": "`x` tokens"
@@ -195,10 +189,6 @@
"Whitelisted regions: ": "Whitelisted regions: ",
"Blacklisted regions: ": "Blacklisted regions: ",
"Shared `x`": "Shared `x`",
- "`x` views": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` view",
- "": "`x` views"
- },
"Premieres in `x`": "Premieres in `x`",
"Premieres `x`": "Premieres `x`",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.",
diff --git a/locales/fa.json b/locales/fa.json
index d8df2b4f..22ca416c 100644
--- a/locales/fa.json
+++ b/locales/fa.json
@@ -1,16 +1,9 @@
{
- "`x` subscribers": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` دنبال کننده",
- "": "`x` دنبال کننده"
- },
- "`x` videos": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` ویدئو",
- "": "`x` ویدئو"
- },
- "`x` playlists": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` فهرست پخش",
- "": "`x` فهرست پخش"
- },
+ "generic_views_count_0": "{{count}} بازدید",
+ "generic_videos_count_0": "{{count}} ویدئو",
+ "generic_playlists_count_0": "{{count}} فهرست پخش",
+ "generic_subscribers_count_0": "{{count}} دنبال کننده",
+ "generic_subscriptions_count_0": "{{count}} اشتراک ها",
"LIVE": "زنده",
"Shared `x` ago": "`x` پیش به اشتراک گذاشته شده",
"Unsubscribe": "لغو اشتراک",
@@ -127,10 +120,6 @@
"Subscription manager": "مدیریت اشتراک",
"Token manager": "مدیر توکن",
"Token": "توکن",
- "`x` subscriptions": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` اشتراک ها",
- "": "`x` اشتراک ها"
- },
"`x` tokens": {
"([^.,0-9]|^)1([^.,0-9]|$)": "`x` توکن ها",
"": "`x` توکن ها"
@@ -176,10 +165,6 @@
"Whitelisted regions: ": "مناطق لیست سفید: ",
"Blacklisted regions: ": "مناطق لیست سیاه: ",
"Shared `x`": "به اشتراک گذاشته شده `x`",
- "`x` views": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` بازدید",
- "": "`x` بازدید"
- },
"Premieres in `x`": "برای اولین بار در `x`",
"Premieres `x`": "برای اولین بار `x`",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "سلام! مثل اینکه تو جاوا اسکریپت رو خاموش کرده ای. اینجا کلیک کن تا نظرات را ببینی، این رو یادت باشه که ممکنه بارگذاری اونها کمی طول بکشه.",
diff --git a/locales/fr.json b/locales/fr.json
index f9975a6b..d14a20ac 100644
--- a/locales/fr.json
+++ b/locales/fr.json
@@ -1,16 +1,14 @@
{
- "`x` subscribers": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` abonné",
- "": "`x` abonnés"
- },
- "`x` videos": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` vidéo",
- "": "`x` vidéos"
- },
- "`x` playlists": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` liste de lecture",
- "": "`x` listes de lecture"
- },
+ "generic_views_count": "{{count}} vue",
+ "generic_views_count_plural":"{{count}} vues",
+ "generic_videos_count": "{{count}} vidéo",
+ "generic_videos_count_plural": "{{count}} vidéos",
+ "generic_playlists_count": "{{count}} liste de lecture",
+ "generic_playlists_count_plural": "{{count}} listes de lecture",
+ "generic_subscribers_count": "{{count}} abonné",
+ "generic_subscribers_count_plural": "{{count}} abonnés",
+ "generic_subscriptions_count": "{{count}} abonnement",
+ "generic_subscriptions_count_plural": "{{count}} abonnements",
"LIVE": "EN DIRECT",
"Shared `x` ago": "Ajoutée il y a `x`",
"Unsubscribe": "Se désabonner",
@@ -127,10 +125,6 @@
"Subscription manager": "Gestionnaire d'abonnement",
"Token manager": "Gestionnaire de token",
"Token": "Token",
- "`x` subscriptions": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` abonnements",
- "": "`x` abonnements"
- },
"`x` tokens": {
"([^.,0-9]|^)1([^.,0-9]|$)": "`x` token",
"": "`x` tokens"
@@ -176,10 +170,6 @@
"Whitelisted regions: ": "Régions sur liste blanche : ",
"Blacklisted regions: ": "Régions sur liste noire : ",
"Shared `x`": "Ajoutée le `x`",
- "`x` views": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` vues",
- "": "`x` vues"
- },
"Premieres in `x`": "Première dans `x`",
"Premieres `x`": "Première le `x`",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Il semblerait que JavaScript soit désactivé. Cliquez ici pour voir les commentaires, mais gardez à l'esprit que le chargement peut prendre plus de temps.",
diff --git a/locales/id.json b/locales/id.json
index 78f5e773..949cc69a 100644
--- a/locales/id.json
+++ b/locales/id.json
@@ -1,16 +1,9 @@
{
- "`x` subscribers": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` pelanggan",
- "": "`x` pelanggan"
- },
- "`x` videos": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` video",
- "": "`x` video"
- },
- "`x` playlists": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` daftar putar",
- "": "`x` daftar putar"
- },
+ "generic_views_count_0": "{{count}} tampilan",
+ "generic_videos_count_0": "{{count}} video",
+ "generic_playlists_count_0": "{{count}} daftar putar",
+ "generic_subscribers_count_0": "{{count}} pelanggan",
+ "generic_subscriptions_count_0": "{{count}} langganan",
"LIVE": "SIARAN LANGSUNG",
"Shared `x` ago": "Dibagikan `x` yang lalu",
"Unsubscribe": "Batal Langganan",
@@ -127,10 +120,6 @@
"Subscription manager": "Pengatur langganan",
"Token manager": "Pengatur token",
"Token": "Token",
- "`x` subscriptions": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` langganan",
- "": "`x` langganan"
- },
"`x` tokens": {
"([^.,0-9]|^)1([^.,0-9]|$)": "`x` token",
"": "`x` token"
@@ -176,10 +165,6 @@
"Whitelisted regions: ": "Wilayah daftar-putih: ",
"Blacklisted regions: ": "Wilayah daftar-hitam: ",
"Shared `x`": "Berbagi `x`",
- "`x` views": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` tampilan",
- "": "`x` tampilan"
- },
"Premieres in `x`": "Tayang dalam `x`",
"Premieres `x`": "Tayang `x`",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Hai! Kelihatannya JavaScript kamu dimatikan. Klik di sini untuk melihat komentar, perlu diingat hal ini mungkin membutuhkan waktu sedikit lebih lama untuk dimuat.",
diff --git a/locales/it.json b/locales/it.json
index befdd665..2722e7bb 100644
--- a/locales/it.json
+++ b/locales/it.json
@@ -1,16 +1,10 @@
{
- "`x` subscribers": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` iscritto",
- "": "`x` iscritti"
- },
- "`x` videos": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` video",
- "": "`x` video"
- },
- "`x` playlists": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` playlist",
- "": "`x` playlist"
- },
+ "generic_subscribers_count": "{{count}} iscritto",
+ "generic_subscribers_count_plural": "{{count}} iscritti",
+ "generic_videos_count": "{{count}} video",
+ "generic_videos_count_plural": "{{count}} video",
+ "generic_playlists_count": "{{count}} playlist",
+ "generic_playlists_count_plural": "{{count}} playlist",
"LIVE": "IN DIRETTA",
"Shared `x` ago": "Condiviso `x` fa",
"Unsubscribe": "Disiscriviti",
@@ -122,10 +116,8 @@
"Subscription manager": "Gestione delle iscrizioni",
"Token manager": "Gestione dei gettoni",
"Token": "Gettone",
- "`x` subscriptions": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` iscrizione",
- "": "`x` iscrizioni"
- },
+ "generic_subscriptions_count": "{{count}} iscrizione",
+ "generic_subscriptions_count_plural": "{{count}} iscrizioni",
"`x` tokens": {
"([^.,0-9]|^)1([^.,0-9]|$)": "`x` gettone",
"": "`x` gettoni"
@@ -166,10 +158,8 @@
"Whitelisted regions: ": "Regioni in lista bianca: ",
"Blacklisted regions: ": "Regioni in lista nera: ",
"Shared `x`": "Condiviso `x`",
- "`x` views": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` visualizzazione",
- "": "`x` visualizzazioni"
- },
+ "generic_views_count": "{{count}} visualizzazione",
+ "generic_views_count_plural": "{{count}} visualizzazioni",
"Premieres in `x`": "In anteprima in `x`",
"Premieres `x`": "In anteprima `x`",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Ciao! Sembra che tu abbia disattivato JavaScript. Clicca qui per visualizzare i commenti. Considera che potrebbe volerci più tempo.",
diff --git a/locales/ja.json b/locales/ja.json
index 7423d2ca..52406f0d 100644
--- a/locales/ja.json
+++ b/locales/ja.json
@@ -1,16 +1,9 @@
{
- "`x` subscribers": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 人の登録者",
- "": "`x` 人の登録者"
- },
- "`x` videos": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 個の動画",
- "": "`x` 個の動画"
- },
- "`x` playlists": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 個の再生リスト",
- "": "`x` 個の再生リスト"
- },
+ "generic_views_count_0": "{{count}} 回視聴",
+ "generic_videos_count_0": "{{count}} 個の動画",
+ "generic_playlists_count_0": "{{count}} 個の再生リスト",
+ "generic_subscribers_count_0": "{{count}} 人の登録者",
+ "generic_subscriptions_count_0": "{{count}} 個の登録チャンネル",
"LIVE": "ライブ",
"Shared `x` ago": "`x`前に共有",
"Unsubscribe": "登録解除",
@@ -127,10 +120,6 @@
"Subscription manager": "登録チャンネルマネージャー",
"Token manager": "トークンマネージャー",
"Token": "トークン",
- "`x` subscriptions": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 個の登録チャンネル",
- "": "`x` 個の登録チャンネル"
- },
"`x` tokens": {
"([^.,0-9]|^)1([^.,0-9]|$)": "`x` 個のトークン",
"": "`x` 個のトークン"
@@ -176,10 +165,6 @@
"Whitelisted regions: ": "ホワイトリストの地域: ",
"Blacklisted regions: ": "ブラックリストの地域: ",
"Shared `x`": "`x`に共有",
- "`x` views": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 回視聴",
- "": "`x` 回視聴"
- },
"Premieres in `x`": "`x`後にプレミア公開",
"Premieres `x`": "`x`にプレミア公開",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "やあ!君は JavaScript を無効にしているのかな?ここをクリックしてコメントを見れるけど、読み込みには少し時間がかかることがあるのを覚えておいてね。",
diff --git a/locales/ko.json b/locales/ko.json
index 96fd41ff..16cf59b9 100644
--- a/locales/ko.json
+++ b/locales/ko.json
@@ -81,18 +81,11 @@
"Subscribe": "구독",
"Unsubscribe": "구독 취소",
"LIVE": "실시간",
- "`x` playlists": {
- "": "`x` 재생목록",
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 재생목록"
- },
- "`x` videos": {
- "": "`x` 동영상",
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 동영상"
- },
- "`x` subscribers": {
- "": "`x` 구독자",
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 구독자"
- },
+ "generic_views_count_0": "{{count}} 조회수",
+ "generic_videos_count_0": "{{count}} 동영상",
+ "generic_playlists_count_0": "{{count}} 재생목록",
+ "generic_subscribers_count_0": "{{count}} 구독자",
+ "generic_subscriptions_count_0": "{{count}} 구독",
"playlist": "재생목록",
"Korean": "한국어",
"Japanese": "일본어",
@@ -158,10 +151,6 @@
"": "`x` 토큰",
"([^.,0-9]|^)1([^.,0-9]|$)": "`x` 토큰"
},
- "`x` subscriptions": {
- "": "`x` 구독",
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 구독"
- },
"Token": "토큰",
"Token manager": "토큰 관리자",
"Subscription manager": "구독 관리자",
@@ -300,10 +289,6 @@
"Shared `x`": "공유된 `x`",
"Whitelisted regions: ": "차단되지 않은 지역: ",
"views": "조회수",
- "`x` views": {
- "": "`x` 조회수",
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 조회수"
- },
"Please log in": "로그인하세요",
"Password cannot be longer than 55 characters": "비밀번호는 55자 이하여야 합니다",
"Password cannot be empty": "비밀번호는 비워둘 수 없습니다",
diff --git a/locales/vi.json b/locales/vi.json
index e433ad55..a8550686 100644
--- a/locales/vi.json
+++ b/locales/vi.json
@@ -1,11 +1,6 @@
{
- "`x` subscribers": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` subscribers",
- "": "`x` subscribers"
- },
- "`x` videos": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` video"
- },
+ "generic_videos_count_0": "{{count}} video",
+ "generic_subscribers_count_0": "{{count}} subscribers",
"LIVE": "TRỰC TIẾP",
"Shared `x` ago": "Đã chia sẻ` x` trước",
"Unsubscribe": "Hủy đăng ký",
diff --git a/locales/zh-CN.json b/locales/zh-CN.json
index 6108a680..f3a6bd98 100644
--- a/locales/zh-CN.json
+++ b/locales/zh-CN.json
@@ -1,16 +1,9 @@
{
- "`x` subscribers": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 位订阅者",
- "": "`x` 位订阅者"
- },
- "`x` videos": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 个视频",
- "": "`x` 个视频"
- },
- "`x` playlists": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 个播放列表",
- "": "`x` 个播放列表"
- },
+ "generic_views_count_0": "{{count}} 播放",
+ "generic_videos_count_0": "{{count}} 个视频",
+ "generic_playlists_count_0": "{{count}} 个播放列表",
+ "generic_subscribers_count_0": "{{count}} 位订阅者",
+ "generic_subscriptions_count_0": "{{count}} 个订阅",
"LIVE": "直播",
"Shared `x` ago": "`x` 前分享",
"Unsubscribe": "取消订阅",
@@ -127,10 +120,6 @@
"Subscription manager": "订阅管理器",
"Token manager": "令牌管理器",
"Token": "令牌",
- "`x` subscriptions": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 个订阅",
- "": "`x` 个订阅"
- },
"`x` tokens": {
"([^.,0-9]|^)1([^.,0-9]|$)": "`x` 个令牌",
"": "`x` 个令牌"
@@ -176,10 +165,6 @@
"Whitelisted regions: ": "白名单地区: ",
"Blacklisted regions: ": "黑名单地区: ",
"Shared `x`": "`x`发布",
- "`x` views": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 播放",
- "": "`x` 次观看"
- },
"Premieres in `x`": "首映于 `x` 后",
"Premieres `x`": "首映于 `x`",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "你好!看起来你关闭了 JavaScript。点击这里阅读评论。注意它们加载的时间可能会稍长。",
diff --git a/locales/zh-TW.json b/locales/zh-TW.json
index d3580c4d..1954e34a 100644
--- a/locales/zh-TW.json
+++ b/locales/zh-TW.json
@@ -1,16 +1,9 @@
{
- "`x` subscribers": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 個訂閱者",
- "": "`x` 個訂閱者"
- },
- "`x` videos": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 部影片",
- "": "`x` 部影片"
- },
- "`x` playlists": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 播放清單",
- "": "`x` 播放清單"
- },
+ "generic_views_count_0": "{{count}} 次檢視",
+ "generic_videos_count_0": "{{count}} 部影片",
+ "generic_playlists_count_0": "{{count}} 播放清單",
+ "generic_subscribers_count_0": "{{count}} 個訂閱者",
+ "generic_subscriptions_count_0": "{{count}} 個訂閱",
"LIVE": "直播",
"Shared `x` ago": "`x` 前分享",
"Unsubscribe": "取消訂閱",
@@ -127,10 +120,6 @@
"Subscription manager": "訂閱管理員",
"Token manager": "Token 管理員",
"Token": "Token",
- "`x` subscriptions": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 個訂閱",
- "": "`x` 個訂閱"
- },
"`x` tokens": {
"([^.,0-9]|^)1([^.,0-9]|$)": "`x` token",
"": "`x` 個存取金鑰"
@@ -176,10 +165,6 @@
"Whitelisted regions: ": "白名單區域: ",
"Blacklisted regions: ": "黑名單區域: ",
"Shared `x`": "`x` 發佈",
- "`x` views": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 次檢視",
- "": "`x` 次檢視"
- },
"Premieres in `x`": "首映於 `x`",
"Premieres `x`": "首映於 `x`",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "嗨!看來您將 JavaScript 關閉了。點擊這裡以檢視留言,請注意,它們可能需要比較長的時間載入。",
diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr
index 9a50f893..4701ecbd 100644
--- a/src/invidious/channels/community.cr
+++ b/src/invidious/channels/community.cr
@@ -158,7 +158,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
view_count = attachment["viewCountText"]?.try &.["simpleText"].as_s.gsub(/\D/, "").to_i64? || 0_i64
json.field "viewCount", view_count
- json.field "viewCountText", translate(locale, "`x` views", number_to_short_text(view_count))
+ json.field "viewCountText", translate_count(locale, "generic_views_count", view_count, NumberFormatting::Short)
end
when .has_key?("backstageImageRenderer")
attachment = attachment["backstageImageRenderer"]
diff --git a/src/invidious/helpers/i18n.cr b/src/invidious/helpers/i18n.cr
index 316e5cda..c7b63f04 100644
--- a/src/invidious/helpers/i18n.cr
+++ b/src/invidious/helpers/i18n.cr
@@ -54,6 +54,14 @@ CONTENT_REGIONS = {
"YE", "ZA", "ZW",
}
+# Enum for the different types of number formats
+enum NumberFormatting
+ None # Print the number as-is
+ Separator # Use a separator for thousands
+ Short # Use short notation (k/M/B)
+ HtmlSpan # Surround with <span id="count"></span>
+end
+
def load_all_locales
locales = {} of String => Hash(String, JSON::Any)
@@ -107,7 +115,7 @@ def translate(locale : String?, key : String, text : String | Nil = nil) : Strin
return translation
end
-def translate_count(locale : String, key : String, count : Int) : String
+def translate_count(locale : String, key : String, count : Int, format = NumberFormatting::None) : String
# Fallback on english if locale doesn't exist
locale = "en-US" if !LOCALES.has_key?(locale)
@@ -134,7 +142,14 @@ def translate_count(locale : String, key : String, count : Int) : String
end
end
- return translation.gsub("{{count}}", count.to_s)
+ case format
+ when .separator? then count_txt = number_with_separator(count)
+ when .short? then count_txt = number_to_short_text(count)
+ when .html_span? then count_txt = "<span id=\"count\">" + count.to_s + "</span>"
+ else count_txt = count.to_s
+ end
+
+ return translation.gsub("{{count}}", count_txt)
end
def translate_bool(locale : String?, translation : Bool)
diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr
index a58571aa..5a93d802 100644
--- a/src/invidious/views/components/item.ecr
+++ b/src/invidious/views/components/item.ecr
@@ -10,8 +10,8 @@
<% end %>
<p dir="auto"><%= HTML.escape(item.author) %></p>
</a>
- <p><%= translate(locale, "`x` subscribers", number_with_separator(item.subscriber_count)) %></p>
- <% if !item.auto_generated %><p><%= translate(locale, "`x` videos", number_with_separator(item.video_count)) %></p><% end %>
+ <p><%= translate_count(locale, "generic_subscribers_count", item.subscriber_count, NumberFormatting::Separator) %></p>
+ <% if !item.auto_generated %><p><%= translate_count(locale, "generic_videos_count", item.video_count, NumberFormatting::Separator) %></p><% end %>
<h5><%= item.description_html %></h5>
<% when SearchPlaylist, InvidiousPlaylist %>
<% if item.id.starts_with? "RD" %>
@@ -24,7 +24,7 @@
<% if !env.get("preferences").as(Preferences).thin_mode %>
<div class="thumbnail">
<img loading="lazy" class="thumbnail" src="<%= URI.parse(item.thumbnail || "/").request_target %>"/>
- <p class="length"><%= number_with_separator(item.video_count) %> videos</p>
+ <p class="length"><%= translate_count(locale, "generic_videos_count", item.video_count, NumberFormatting::Separator) %></p>
</div>
<% end %>
<p dir="auto"><%= HTML.escape(item.title) %></p>
@@ -94,7 +94,7 @@
<% if item.responds_to?(:views) && item.views %>
<div class="flex-right">
- <p dir="auto"><%= translate(locale, "`x` views", number_to_short_text(item.views || 0)) %></p>
+ <p dir="auto"><%= translate_count(locale, "generic_views_count", item.views || 0, NumberFormatting::Short) %></p>
</div>
<% end %>
</div>
@@ -160,7 +160,7 @@
<% if item.responds_to?(:views) && item.views %>
<div class="flex-right">
- <p class="video-data" dir="auto"><%= translate(locale, "`x` views", number_to_short_text(item.views || 0)) %></p>
+ <p class="video-data" dir="auto"><%= translate_count(locale, "generic_views_count", item.views || 0, NumberFormatting::Short) %></p>
</div>
<% end %>
</div>
diff --git a/src/invidious/views/edit_playlist.ecr b/src/invidious/views/edit_playlist.ecr
index 5046abc1..308bd677 100644
--- a/src/invidious/views/edit_playlist.ecr
+++ b/src/invidious/views/edit_playlist.ecr
@@ -11,7 +11,7 @@
<h3><input class="pure-input-1" maxlength="150" name="title" type="text" value="<%= title %>"></h3>
<b>
<%= HTML.escape(playlist.author) %> |
- <%= translate(locale, "`x` videos", "#{playlist.video_count}") %> |
+ <%= translate_count(locale, "generic_videos_count", playlist.video_count) %> |
<%= translate(locale, "Updated `x` ago", recode_date(playlist.updated, locale)) %> |
<i class="icon <%= {"ion-md-globe", "ion-ios-unlock", "ion-ios-lock"}[playlist.privacy.value] %>"></i>
<select name="privacy">
diff --git a/src/invidious/views/feeds/history.ecr b/src/invidious/views/feeds/history.ecr
index 40584979..6c1243c5 100644
--- a/src/invidious/views/feeds/history.ecr
+++ b/src/invidious/views/feeds/history.ecr
@@ -4,11 +4,11 @@
<div class="pure-g h-box">
<div class="pure-u-1-3">
- <h3><%= translate(locale, "`x` videos", %(<span id="count">#{user.watched.size}</span>)) %></h3>
+ <h3><%= translate_count(locale, "generic_videos_count", user.watched.size, NumberFormatting::HtmlSpan) %></h3>
</div>
<div class="pure-u-1-3">
<h3 style="text-align:center">
- <a href="/feed/subscriptions"><%= translate(locale, "`x` subscriptions", %(<span id="count">#{user.subscriptions.size}</span>)) %></a>
+ <a href="/feed/subscriptions"><%= translate_count(locale, "generic_subscriptions_count", user.subscriptions.size, NumberFormatting::HtmlSpan) %></a>
</h3>
</div>
<div class="pure-u-1-3">
diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr
index b720bbc2..df3112db 100644
--- a/src/invidious/views/playlist.ecr
+++ b/src/invidious/views/playlist.ecr
@@ -16,7 +16,7 @@
<% else %>
<%= author %> |
<% end %>
- <%= translate(locale, "`x` videos", "#{playlist.video_count}") %> |
+ <%= translate_count(locale, "generic_videos_count", playlist.video_count) %> |
<%= translate(locale, "Updated `x` ago", recode_date(playlist.updated, locale)) %> |
<% case playlist.as(InvidiousPlaylist).privacy when %>
<% when PlaylistPrivacy::Public %>
@@ -30,7 +30,7 @@
<% else %>
<b>
<a href="/channel/<%= playlist.ucid %>"><%= author %></a> |
- <%= translate(locale, "`x` videos", "#{playlist.video_count}") %> |
+ <%= translate_count(locale, "generic_videos_count", playlist.video_count) %> |
<%= translate(locale, "Updated `x` ago", recode_date(playlist.updated, locale)) %>
</b>
<% end %>
diff --git a/src/invidious/views/subscription_manager.ecr b/src/invidious/views/subscription_manager.ecr
index acf015f5..5fa7d203 100644
--- a/src/invidious/views/subscription_manager.ecr
+++ b/src/invidious/views/subscription_manager.ecr
@@ -6,7 +6,7 @@
<div class="pure-u-1-3">
<h3>
<a href="/feed/subscriptions">
- <%= translate(locale, "`x` subscriptions", %(<span id="count">#{subscriptions.size}</span>)) %>
+ <%= translate_count(locale, "generic_subscriptions_count", subscriptions.size, NumberFormatting::HtmlSpan) %>
</a>
</h3>
</div>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 363f1262..00f5f8b7 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -323,7 +323,7 @@ we're going to need to do it here in order to allow for translations.
<div class="pure-u-10-24" style="text-align:right">
<% if views = rv["short_view_count_text"]?.try &.delete(", views watching") %>
<% if !views.empty? %>
- <b class="width:100%"><%= translate(locale, "`x` views", views) %></b>
+ <b class="width:100%"><%= translate_count(locale, "generic_views_count", views.to_i? || 0) %></b>
<% end %>
<% end %>
</div>