From 37c953e6339f2983bd7dde405ec7405de5ddaa31 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Wed, 5 Jan 2022 02:42:49 +0100 Subject: [PATCH] i18n: Use plurals for tokens/replies/unseen notifications --- locales/en-US.json | 24 +++++++-------------- locales/fa.json | 20 ++++------------- locales/fr.json | 24 +++++++-------------- locales/id.json | 20 ++++------------- locales/it.json | 12 ++++------- locales/ja.json | 20 ++++------------- locales/ko.json | 20 ++++------------- locales/pt-BR.json | 6 ++---- locales/pt-PT.json | 6 ++---- locales/pt.json | 6 ++---- locales/zh-CN.json | 20 ++++------------- locales/zh-TW.json | 20 ++++------------- src/invidious/comments.cr | 10 +++++++-- src/invidious/views/feeds/subscriptions.ecr | 2 +- src/invidious/views/token_manager.ecr | 2 +- 15 files changed, 60 insertions(+), 152 deletions(-) diff --git a/locales/en-US.json b/locales/en-US.json index 9d3a70d2..ac8b0c11 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -144,18 +144,14 @@ "Subscription manager": "Subscription manager", "Token manager": "Token manager", "Token": "Token", - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` token", - "": "`x` tokens" - }, + "tokens_count": "{{count}} token", + "tokens_count_plural": "{{count}} tokens", "Import/export": "Import/export", "unsubscribe": "unsubscribe", "revoke": "revoke", "Subscriptions": "Subscriptions", - "`x` unseen notifications": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` unseen notification", - "": "`x` unseen notifications" - }, + "subscriptions_unseen_notifs_count": "{{count}} unseen notification", + "subscriptions_unseen_notifs_count_plural": "{{count}} unseen notifications", "search": "search", "Log out": "Log out", "Released under the AGPLv3 on Github.": "Released under the AGPLv3 on Github.", @@ -222,16 +218,12 @@ "This channel does not exist.": "This channel does not exist.", "Could not get channel info.": "Could not get channel info.", "Could not fetch comments": "Could not fetch comments", - "View `x` replies": { - "([^.,0-9]|^)1([^.,0-9]|$)": "View `x` reply", - "": "View `x` replies" - }, + "comments_view_x_replies": "View {{count}} reply", + "comments_view_x_replies_plural": "View {{count}} replies", "`x` ago": "`x` ago", "Load more": "Load more", - "`x` points": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` point", - "": "`x` points" - }, + "comments_points_count": "{{count}} point", + "comments_points_count_plural": "{{count}} points", "Could not create mix.": "Could not create mix.", "Empty playlist": "Empty playlist", "Not a playlist.": "Not a playlist.", diff --git a/locales/fa.json b/locales/fa.json index 22ca416c..48b5a17d 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -120,18 +120,12 @@ "Subscription manager": "مدیریت اشتراک", "Token manager": "مدیر توکن", "Token": "توکن", - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` توکن ها", - "": "`x` توکن ها" - }, + "tokens_count_0": "{{count}} توکن ها", "Import/export": "وارد کردن/خارج کردن", "unsubscribe": "لغو اشتراک", "revoke": "ابطال", "Subscriptions": "اشتراک ها", - "`x` unseen notifications": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` اعلان نادیده", - "": "`x` اعلان نادیده" - }, + "subscriptions_unseen_notifs_count_0": "{{count}} اعلان نادیده", "search": "جستجو", "Log out": "خروج", "Released under the AGPLv3 on Github.": "منتشر شده تحت پروانه AGPLv3 روی گیت‌هاب.", @@ -198,16 +192,10 @@ "This channel does not exist.": "این کانال وجود ندارد.", "Could not get channel info.": "نمیتوان اطلاعات کانال را دریافت کرد.", "Could not fetch comments": "نمیتوان نظرات را دریافت کرد", - "View `x` replies": { - "([^.,0-9]|^)1([^.,0-9]|$)": "نمایش `x` پاسخ ها", - "": "نمایش `x` پاسخ ها" - }, + "comments_view_x_replies_0": "نمایش {{count}} پاسخ ها", "`x` ago": "`x` پیش", "Load more": "بارگذاری بیشتر", - "`x` points": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` نقطه ها", - "": "`x` نقطه ها" - }, + "comments_points_count_0": "{{count}} نقطه ها", "Could not create mix.": "نمیتوان میکس ساخت.", "Empty playlist": "سیاههٔ پخش خالی", "Not a playlist.": "یک سیاههٔ پخش نیست.", diff --git a/locales/fr.json b/locales/fr.json index d14a20ac..72d7daf6 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -125,18 +125,14 @@ "Subscription manager": "Gestionnaire d'abonnement", "Token manager": "Gestionnaire de token", "Token": "Token", - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` token", - "": "`x` tokens" - }, + "tokens_count": "{{count}} token", + "tokens_count_plural": "{{count}} tokens", "Import/export": "Importer/Exporter", "unsubscribe": "se désabonner", "revoke": "révoquer", "Subscriptions": "Abonnements", - "`x` unseen notifications": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` notification non vue", - "": "`x` notifications non vues" - }, + "subscriptions_unseen_notifs_count": "{{count}} notification non vue", + "subscriptions_unseen_notifs_count_plural": "{{count}} notifications non vues", "search": "rechercher", "Log out": "Se déconnecter", "Released under the AGPLv3 on Github.": "Publié sous licence AGPLv3 sur Github.", @@ -203,16 +199,12 @@ "This channel does not exist.": "Cette chaine n'existe pas.", "Could not get channel info.": "Impossible de charger les informations de cette chaîne.", "Could not fetch comments": "Impossible de charger les commentaires", - "View `x` replies": { - "([^.,0-9]|^)1([^.,0-9]|$)": "Voir `x` réponse", - "": "Voir `x` réponses" - }, + "comments_view_x_replies": "Voir {{count}} réponse", + "comments_view_x_replies_plural": "Voir {{count}} réponses", "`x` ago": "il y a `x`", "Load more": "Voir plus", - "`x` points": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` point", - "": "`x` points" - }, + "comments_points_count": "{{count}} point", + "comments_points_count_plural": "{{count}} points", "Could not create mix.": "Impossible de charger cette liste de lecture.", "Empty playlist": "La liste de lecture est vide", "Not a playlist.": "La liste de lecture est invalide.", diff --git a/locales/id.json b/locales/id.json index 949cc69a..b7dbf598 100644 --- a/locales/id.json +++ b/locales/id.json @@ -120,18 +120,12 @@ "Subscription manager": "Pengatur langganan", "Token manager": "Pengatur token", "Token": "Token", - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` token", - "": "`x` token" - }, + "tokens_count_0": "{{count}} token", "Import/export": "Impor/ekspor", "unsubscribe": "batal langganan", "revoke": "cabut", "Subscriptions": "Langganan", - "`x` unseen notifications": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` pemberitahuan belum dilihat", - "": "`x` pemberitahuan belum dilihat" - }, + "subscriptions_unseen_notifs_count_0": "{{count}} pemberitahuan belum dilihat", "search": "cari", "Log out": "Keluar", "Released under the AGPLv3 on Github.": "Dirilis di bawah AGPLv3 di Github.", @@ -198,16 +192,10 @@ "This channel does not exist.": "Kanal ini tidak ada.", "Could not get channel info.": "Tidak bisa mendapatkan info kanal.", "Could not fetch comments": "Tidak dapat memuat komentar", - "View `x` replies": { - "([^.,0-9]|^)1([^.,0-9]|$)": "Lihat`x` balasan", - "": "Lihat `x` balasan" - }, + "comments_view_x_replies_0": "Lihat {{count}} balasan", "`x` ago": "`x` lalu", "Load more": "Muat lebih banyak", - "`x` points": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` poin", - "": "`x` poin" - }, + "comments_points_count_0": "{{count}} poin", "Could not create mix.": "Tidak dapat membuat mix.", "Empty playlist": "Daftar putar kosong", "Not a playlist.": "Bukan daftar putar.", diff --git a/locales/it.json b/locales/it.json index 2722e7bb..cef2bf13 100644 --- a/locales/it.json +++ b/locales/it.json @@ -118,18 +118,14 @@ "Token": "Gettone", "generic_subscriptions_count": "{{count}} iscrizione", "generic_subscriptions_count_plural": "{{count}} iscrizioni", - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` gettone", - "": "`x` gettoni" - }, + "tokens_count": "{{count}} gettone", + "tokens_count_plural": "{{count}} gettoni", "Import/export": "Importa/esporta", "unsubscribe": "disiscriviti", "revoke": "revoca", "Subscriptions": "Iscrizioni", - "`x` unseen notifications": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` notifica non visualizzata", - "": "`x` notifiche non visualizzate" - }, + "subscriptions_unseen_notifs_count": "{{count}} notifica non visualizzata", + "subscriptions_unseen_notifs_count_plural": "{{count}} notifiche non visualizzate", "search": "Cerca", "Log out": "Esci", "Source available here.": "Codice sorgente.", diff --git a/locales/ja.json b/locales/ja.json index 52406f0d..5cb1244d 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -120,18 +120,12 @@ "Subscription manager": "登録チャンネルマネージャー", "Token manager": "トークンマネージャー", "Token": "トークン", - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 個のトークン", - "": "`x` 個のトークン" - }, + "tokens_count_0": "{{count}} 個のトークン", "Import/export": "インポート/エクスポート", "unsubscribe": "登録解除", "revoke": "取り消す", "Subscriptions": "登録チャンネル", - "`x` unseen notifications": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 個の未読通知", - "": "`x` 個の未読通知" - }, + "subscriptions_unseen_notifs_count_0": "{{count}} 個の未読通知", "search": "検索", "Log out": "ログアウト", "Released under the AGPLv3 on Github.": "GitHub 上で AGPLv3 の元で公開されています。", @@ -198,16 +192,10 @@ "This channel does not exist.": "このチャンネルは存在しません。", "Could not get channel info.": "チャンネル情報を取得できませんでした。", "Could not fetch comments": "コメントを取得できませんでした", - "View `x` replies": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 件の返信を見る", - "": "`x` 件の返信を見る" - }, + "comments_view_x_replies_0": "{{count}} 件の返信を見る", "`x` ago": "`x`前", "Load more": "もっと読み込む", - "`x` points": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` ポイント", - "": "`x` ポイント" - }, + "comments_points_count_0": "{{count}} ポイント", "Could not create mix.": "ミックスを作成できませんでした。", "Empty playlist": "空の再生リスト", "Not a playlist.": "再生リストではありません。", diff --git a/locales/ko.json b/locales/ko.json index 16cf59b9..a579fe56 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -139,18 +139,12 @@ "Source available here.": "소스는 여기에서 사용할 수 있습니다.", "Log out": "로그아웃", "search": "검색", - "`x` unseen notifications": { - "": "`x` 읽지 않은 알림", - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 읽지 않은 알림" - }, + "subscriptions_unseen_notifs_count_0": "{{count}} 읽지 않은 알림", "Subscriptions": "구독", "revoke": "철회", "unsubscribe": "구독 취소", "Import/export": "가져오기/내보내기", - "`x` tokens": { - "": "`x` 토큰", - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 토큰" - }, + "tokens_count_0": "{{count}} 토큰", "Token": "토큰", "Token manager": "토큰 관리자", "Subscription manager": "구독 관리자", @@ -251,10 +245,7 @@ "Could not pull trending pages.": "인기 급상승 페이지를 가져올 수 없습니다.", "Could not create mix.": "믹스를 생성할 수 없습니다.", "`x` ago": "`x` 전", - "View `x` replies": { - "": "답글 `x`개 보기", - "([^.,0-9]|^)1([^.,0-9]|$)": "답글 `x`개 보기" - }, + "comments_view_x_replies_0": "답글 {{count}}개 보기", "View Reddit comments": "Reddit의 댓글 보기", "Engagement: ": "약속: ", "Wilson score: ": "Wilson Score: ", @@ -347,10 +338,7 @@ "Tajik": "타지크어", "Swedish": "스웨덴어", "Spanish (Latin America)": "스페인어 (라틴 아메리카)", - "`x` points": { - "": "`x` 포인트", - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 포인트" - }, + "comments_points_count_0": "{{count}} 포인트", "Invidious Private Feed for `x`": "`x` 에 대한 Invidious 비공개 피드", "Premieres `x`": "최초 공개 `x`", "Premieres in `x`": "`x` 에 최초 공개", diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 01407669..abf27194 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -131,10 +131,8 @@ "([^.,0-9]|^)1([^.,0-9]|$)": "`x` inscrições", "": "`x` inscrições" }, - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` tokens", - "": "Símbolos `x`" - }, + "tokens_count": "{{count}} token", + "tokens_count_plural": "{{count}} tokens", "Import/export": "Importar/Exportar", "unsubscribe": "cancelar inscrição", "revoke": "revogar", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 83b59ab5..3c562467 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -131,10 +131,8 @@ "([^.,0-9]|^)1([^.,0-9]|$)": "`x` subscrições", "": "`x` subscrições" }, - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` tokens", - "": "`x` tokens" - }, + "tokens_count": "{{count}} token", + "tokens_count_plural": "{{count}} tokens", "Import/export": "Importar / exportar", "unsubscribe": "anular subscrição", "revoke": "revogar", diff --git a/locales/pt.json b/locales/pt.json index 065170fb..9382da48 100644 --- a/locales/pt.json +++ b/locales/pt.json @@ -191,10 +191,8 @@ }, "Subscriptions": "Subscrições", "revoke": "revogar", - "`x` tokens": { - "": "`x` tokens", - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` tokens" - }, + "tokens_count": "{{count}} token", + "tokens_count_plural": "{{count}} tokens", "`x` subscriptions": { "": "`x` subscrições", "([^.,0-9]|^)1([^.,0-9]|$)": "`x` subscrições" diff --git a/locales/zh-CN.json b/locales/zh-CN.json index f3a6bd98..10b767d9 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -120,18 +120,12 @@ "Subscription manager": "订阅管理器", "Token manager": "令牌管理器", "Token": "令牌", - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 个令牌", - "": "`x` 个令牌" - }, + "tokens_count_0": "{{count}} 个令牌", "Import/export": "导入/导出", "unsubscribe": "取消订阅", "revoke": "吊销", "Subscriptions": "订阅", - "`x` unseen notifications": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 条未读通知", - "": "`x` 条未读通知" - }, + "subscriptions_unseen_notifs_count_0": "{{count}} 条未读通知", "search": "搜索", "Log out": "登出", "Released under the AGPLv3 on Github.": "依据 AGPLv3 许可证发布于 Github。", @@ -198,16 +192,10 @@ "This channel does not exist.": "频道不存在。", "Could not get channel info.": "无法获取频道信息。", "Could not fetch comments": "无法获取评论", - "View `x` replies": { - "([^.,0-9]|^)1([^.,0-9]|$)": "查看 `x` 条回复", - "": "查看 `x` 条回复" - }, + "comments_view_x_replies_0": "查看 {{count}} 条回复", "`x` ago": "`x` 前", "Load more": "加载更多", - "`x` points": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 分", - "": "`x` 分" - }, + "comments_points_count_0": "{{count}} 分", "Could not create mix.": "无法创建合集。", "Empty playlist": "空播放列表", "Not a playlist.": "非播放列表。", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 1954e34a..c2800114 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -120,18 +120,12 @@ "Subscription manager": "訂閱管理員", "Token manager": "Token 管理員", "Token": "Token", - "`x` tokens": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` token", - "": "`x` 個存取金鑰" - }, + "tokens_count_0": "{{count}} 個存取金鑰", "Import/export": "匯入/匯出", "unsubscribe": "取消訂閱", "revoke": "撤銷", "Subscriptions": "訂閱", - "`x` unseen notifications": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 個未讀的通知", - "": "`x` 個未讀的通知" - }, + "subscriptions_unseen_notifs_count_0": "{{count}} 個未讀的通知", "search": "搜尋", "Log out": "登出", "Released under the AGPLv3 on Github.": "在 GitHub 上以 AGPLv3 釋出。", @@ -198,16 +192,10 @@ "This channel does not exist.": "此頻道不存在。", "Could not get channel info.": "無法取得頻道資訊。", "Could not fetch comments": "無法擷取留言", - "View `x` replies": { - "([^.,0-9]|^)1([^.,0-9]|$)": "檢視 `x` 則回覆", - "": "檢視 `x` 則回覆" - }, + "comments_view_x_replies_0": "檢視 {{count}} 則回覆", "`x` ago": "`x` 以前", "Load more": "載入更多", - "`x` points": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` 點", - "": "`x` 點" - }, + "comments_points_count_0": "{{count}} 點", "Could not create mix.": "無法建立混合。", "Empty playlist": "空的播放清單", "Not a playlist.": "不是播放清單。", diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 5b7d63e0..50059fa2 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -303,13 +303,19 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false) root = comments["comments"].as_a root.each do |child| if child["replies"]? + replies_count_text = translate_count(locale, + "comments_view_x_replies", + child["replies"]["replyCount"].as_s.to_i? || 0, + NumberFormatting::Separator + ) + replies_html = <<-END_HTML

#{translate(locale, "View `x` replies", number_with_separator(child["replies"]["replyCount"]))} + data-onclick="get_youtube_replies" data-load-replies>#{replies_count_text}

@@ -471,7 +477,7 @@ def template_reddit_comments(root, locale)

[ - ] #{child.author} - #{translate(locale, "`x` points", number_with_separator(child.score))} + #{translate_count(locale, "comments_points_count", child.score, NumberFormatting::Separator)} #{translate(locale, "`x` ago", recode_date(child.created_utc, locale))} #{translate(locale, "permalink")}

diff --git a/src/invidious/views/feeds/subscriptions.ecr b/src/invidious/views/feeds/subscriptions.ecr index 97184e2b..8d56ad14 100644 --- a/src/invidious/views/feeds/subscriptions.ecr +++ b/src/invidious/views/feeds/subscriptions.ecr @@ -24,7 +24,7 @@
- <%= translate(locale, "`x` unseen notifications", "#{notifications.size}") %> + <%= translate_count(locale, "subscriptions_unseen_notifs_count", notifications.size) %>
<% if !notifications.empty? %> diff --git a/src/invidious/views/token_manager.ecr b/src/invidious/views/token_manager.ecr index e48aec2f..12e0e8c9 100644 --- a/src/invidious/views/token_manager.ecr +++ b/src/invidious/views/token_manager.ecr @@ -5,7 +5,7 @@

- <%= translate(locale, "`x` tokens", %(#{tokens.size})) %> + <%= translate_count(locale, "tokens_count", tokens.size, NumberFormatting::HtmlSpan) %>