From 2d96d1358bc1c037ba84847ad2f23ea09087c07c Mon Sep 17 00:00:00 2001 From: webfansplz <308241863@qq.com> Date: Mon, 16 Jan 2023 16:56:36 +0800 Subject: [PATCH] refactor(i18n): confirm module (#1210) --- components/account/AccountMoreButton.vue | 52 +++++++++++++++--------- components/modal/ModalConfirm.vue | 4 +- components/status/StatusActionsMore.vue | 6 +-- locales/ar-EG.json | 21 +++++----- locales/de-DE.json | 22 +++++----- locales/en-US.json | 39 +++++++++++++----- locales/es-ES.json | 22 +++++----- locales/fr-FR.json | 22 +++++----- locales/pt-PT.json | 22 +++++----- locales/tr-TR.json | 22 +++++----- locales/uk-UA.json | 21 +++++----- locales/zh-CN.json | 39 +++++++++++++----- locales/zh-TW.json | 39 +++++++++++++----- 13 files changed, 206 insertions(+), 125 deletions(-) diff --git a/components/account/AccountMoreButton.vue b/components/account/AccountMoreButton.vue index 52276d75..4c915194 100644 --- a/components/account/AccountMoreButton.vue +++ b/components/account/AccountMoreButton.vue @@ -12,12 +12,12 @@ const isSelf = $(useSelfAccount(() => account)) const { t } = useI18n() const { client } = $(useMasto()) -const isConfirmed = async (title: string) => { - return await openConfirmDialog(t('common.confirm_dialog.title', [title])) === 'confirm' -} - -const toggleMute = async (title: string) => { - if (!await isConfirmed(title)) +const toggleMute = async () => { + if (!relationship!.muting && await openConfirmDialog({ + title: t('confirm.mute_account.title', [account.acct]), + confirm: t('confirm.mute_account.confirm'), + cancel: t('confirm.mute_account.cancel'), + }) !== 'confirm') return relationship!.muting = !relationship!.muting @@ -28,24 +28,36 @@ const toggleMute = async (title: string) => { : await client.v1.accounts.unmute(account.id) } -const toggleBlockUser = async (title: string) => { - if (!await isConfirmed(title)) +const toggleBlockUser = async () => { + if (!relationship!.blocking && await openConfirmDialog({ + title: t('confirm.block_account.title', [account.acct]), + confirm: t('confirm.block_account.confirm'), + cancel: t('confirm.block_account.cancel'), + }) !== 'confirm') return relationship!.blocking = !relationship!.blocking relationship = await client.v1.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id) } -const toggleBlockDomain = async (title: string) => { - if (!await isConfirmed(title)) +const toggleBlockDomain = async () => { + if (!relationship!.domainBlocking && await openConfirmDialog({ + title: t('confirm.block_domain.title', [getServerName(account)]), + confirm: t('confirm.block_domain.confirm'), + cancel: t('confirm.block_domain.cancel'), + }) !== 'confirm') return relationship!.domainBlocking = !relationship!.domainBlocking await client.v1.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account)) } -const toggleReblogs = async (title: string) => { - if (!await isConfirmed(title)) +const toggleReblogs = async () => { + if (!relationship!.showingReblogs && await openConfirmDialog({ + title: t('confirm.show_reblogs.title', [account.acct]), + confirm: t('confirm.show_reblogs.confirm'), + cancel: t('confirm.show_reblogs.cancel'), + }) !== 'confirm') return const showingReblogs = !relationship?.showingReblogs @@ -90,14 +102,14 @@ const toggleReblogs = async (title: string) => { icon="i-ri:repeat-line" :text="$t('menu.show_reblogs', [`@${account.acct}`])" :command="command" - @click="toggleReblogs($t('menu.show_reblogs', [`@${account.acct}`]))" + @click="toggleReblogs()" /> { :text="$t('menu.mute_account', [`@${account.acct}`])" icon="i-ri:volume-up-fill" :command="command" - @click="toggleMute($t('menu.mute_account', [`@${account.acct}`]))" + @click="toggleMute()" /> { :text="$t('menu.block_account', [`@${account.acct}`])" icon="i-ri:forbid-2-line" :command="command" - @click="toggleBlockUser($t('menu.block_account', [`@${account.acct}`]))" + @click="toggleBlockUser()" /> diff --git a/components/modal/ModalConfirm.vue b/components/modal/ModalConfirm.vue index b0516bb9..9820238b 100644 --- a/components/modal/ModalConfirm.vue +++ b/components/modal/ModalConfirm.vue @@ -18,10 +18,10 @@ const emit = defineEmits<{
diff --git a/components/status/StatusActionsMore.vue b/components/status/StatusActionsMore.vue index 9082ded0..69fd870c 100644 --- a/components/status/StatusActionsMore.vue +++ b/components/status/StatusActionsMore.vue @@ -63,9 +63,9 @@ const shareLink = async (status: mastodon.v1.Status) => { const deleteStatus = async () => { if (await openConfirmDialog({ - title: t('menu.delete_confirm.title'), - confirm: t('menu.delete_confirm.confirm'), - cancel: t('menu.delete_confirm.cancel'), + title: t('confirm.delete_posts.title'), + confirm: t('confirm.delete_posts.confirm'), + cancel: t('confirm.delete_posts.cancel'), }) !== 'confirm') return diff --git a/locales/ar-EG.json b/locales/ar-EG.json index b6cdec01..40d246c8 100644 --- a/locales/ar-EG.json +++ b/locales/ar-EG.json @@ -86,11 +86,6 @@ "toggle_zen_mode": "تبديل وضع الهدوء" }, "common": { - "confirm_dialog": { - "cancel": "كلا", - "confirm": "نعم", - "title": "هل أنت متأكد؟" - }, "end_of_list": "نهاية القائمة", "error": "حدث خطأ", "in": "في", @@ -101,6 +96,17 @@ "draft_title": "مسودة {0}", "drafts": "المسودات ({v})" }, + "confirm": { + "common": { + "cancel": "كلا", + "confirm": "نعم" + }, + "delete_posts": { + "cancel": "إلغاء", + "confirm": "حذف", + "title": "هل أنت متأكد أنك تريد حذف هذا المنشور؟" + } + }, "conversation": { "with": "مع" }, @@ -131,11 +137,6 @@ "copy_link_to_post": "انسخ الرابط إلى هذا المنشور", "delete": "حذف", "delete_and_redraft": "حذف وإعادة صياغة", - "delete_confirm": { - "cancel": "إلغاء", - "confirm": "حذف", - "title": "هل أنت متأكد أنك تريد حذف هذا المنشور؟" - }, "direct_message_account": "إرسال رسالة مباشرة إلى {0}", "edit": "تعديل", "hide_reblogs": "إخفاء المشاركات من {0}", diff --git a/locales/de-DE.json b/locales/de-DE.json index e60e2059..f865209f 100644 --- a/locales/de-DE.json +++ b/locales/de-DE.json @@ -89,11 +89,6 @@ "toggle_zen_mode": "Zen-Modus ändern" }, "common": { - "confirm_dialog": { - "cancel": "Abbrechen", - "confirm": "OK", - "title": "Bist du sicher, {0}?" - }, "end_of_list": "Ende der Liste", "error": "FEHLER", "in": "in", @@ -104,6 +99,18 @@ "draft_title": "Entwurf {0}", "drafts": "Entwürfe ({v})" }, + "confirm": { + "common": { + "cancel": "Abbrechen", + "confirm": "OK", + "title": "Bist du sicher, {0}?" + }, + "delete_posts": { + "cancel": "Abbrechen", + "confirm": "Löschen", + "title": "Möchtest du diesen Beitrag wirklich löschen?" + } + }, "conversation": { "with": "mit" }, @@ -134,11 +141,6 @@ "copy_link_to_post": "Link zu diesem Beitrag kopieren", "delete": "Löschen", "delete_and_redraft": "Löschen und neu erstellen", - "delete_confirm": { - "cancel": "Abbrechen", - "confirm": "Löschen", - "title": "Möchtest du diesen Beitrag wirklich löschen?" - }, "direct_message_account": "Direktnachricht an {0}", "edit": "Bearbeiten", "hide_reblogs": "Boosts von {0} ausblenden", diff --git a/locales/en-US.json b/locales/en-US.json index 8d915cc3..985943f5 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -89,11 +89,6 @@ "toggle_zen_mode": "Toggle zen mode" }, "common": { - "confirm_dialog": { - "cancel": "No", - "confirm": "Yes", - "title": "Are you sure {0}?" - }, "end_of_list": "End of the list", "error": "ERROR", "in": "in", @@ -105,6 +100,35 @@ "drafts": "Drafts ({v})" }, "confirm": { + "block_account": { + "cancel": "Cancel", + "confirm": "Block", + "title": "Are you sure you want to block {0}?" + }, + "block_domain": { + "cancel": "Cancel", + "confirm": "Block", + "title": "Are you sure you want to block {0}?" + }, + "common": { + "cancel": "No", + "confirm": "Yes" + }, + "delete_posts": { + "cancel": "Cancel", + "confirm": "Delete", + "title": "Are you sure you want to delete this post?" + }, + "mute_account": { + "cancel": "Cancel", + "confirm": "Mute", + "title": "Are you sure you want to mute {0}?" + }, + "show_reblogs": { + "cancel": "Cancel", + "confirm": "Show", + "title": "Are you sure you want to show boosts from {0}?" + }, "unfollow": { "cancel": "Cancel", "confirm": "Unfollow", @@ -141,11 +165,6 @@ "copy_link_to_post": "Copy link to this post", "delete": "Delete", "delete_and_redraft": "Delete & re-draft", - "delete_confirm": { - "cancel": "Cancel", - "confirm": "Delete", - "title": "Are you sure you want to delete this post?" - }, "direct_message_account": "Direct message {0}", "edit": "Edit", "hide_reblogs": "Hide boosts from {0}", diff --git a/locales/es-ES.json b/locales/es-ES.json index 47307a5f..41f79445 100644 --- a/locales/es-ES.json +++ b/locales/es-ES.json @@ -86,11 +86,6 @@ "toggle_zen_mode": "Cambiar a modo zen" }, "common": { - "confirm_dialog": { - "cancel": "No", - "confirm": "Si", - "title": "¿Estás seguro?" - }, "end_of_list": "Fin", "error": "ERROR", "in": "en", @@ -101,6 +96,18 @@ "draft_title": "Borrador {0}", "drafts": "Borradores ({v})" }, + "confirm": { + "common": { + "cancel": "No", + "confirm": "Si", + "title": "¿Estás seguro?" + }, + "delete_posts": { + "cancel": "Cancelar", + "confirm": "Eliminar", + "title": "¿Estás seguro que deseas eliminar esta publicación?" + } + }, "conversation": { "with": "con" }, @@ -131,11 +138,6 @@ "copy_link_to_post": "Copiar enlace", "delete": "Borrar", "delete_and_redraft": "Borrar y volver a borrador", - "delete_confirm": { - "cancel": "Cancelar", - "confirm": "Eliminar", - "title": "¿Estás seguro que deseas eliminar esta publicación?" - }, "direct_message_account": "Mensaje directo a {0}", "edit": "Editar", "hide_reblogs": "Ocultar retoots de {0}", diff --git a/locales/fr-FR.json b/locales/fr-FR.json index ef7bc03e..b654bce8 100644 --- a/locales/fr-FR.json +++ b/locales/fr-FR.json @@ -83,11 +83,6 @@ "toggle_zen_mode": "Passer en mode zen" }, "common": { - "confirm_dialog": { - "cancel": "Non", - "confirm": "Oui", - "title": "Êtes-vous sûr·e ?" - }, "end_of_list": "Fin de liste", "error": "ERREUR", "in": "sur", @@ -98,6 +93,18 @@ "draft_title": "Brouillon {0}", "drafts": "Brouillons ({v})" }, + "confirm": { + "common": { + "cancel": "Non", + "confirm": "Oui", + "title": "Êtes-vous sûr·e ?" + }, + "delete_posts": { + "cancel": "Annuler", + "confirm": "Supprimer", + "title": "Certain·e de vouloir supprimer ce message ?" + } + }, "conversation": { "with": "avec" }, @@ -128,11 +135,6 @@ "copy_link_to_post": "Copier le lien du message", "delete": "Supprimer", "delete_and_redraft": "Supprimer et réécrire", - "delete_confirm": { - "cancel": "Annuler", - "confirm": "Supprimer", - "title": "Certain·e de vouloir supprimer ce message ?" - }, "direct_message_account": "Message direct à {0}", "edit": "Éditer", "hide_reblogs": "Cacher les boosts de {0}", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index d7ff4a04..162cb51f 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -89,11 +89,6 @@ "toggle_zen_mode": "Alternar modo zen" }, "common": { - "confirm_dialog": { - "cancel": "Não", - "confirm": "Sim", - "title": "Tem a certeza?" - }, "end_of_list": "Fim da lista", "error": "ERRO", "in": "em", @@ -104,6 +99,18 @@ "draft_title": "Rascunho {0}", "drafts": "Rascunhos ({v})" }, + "confirm": { + "common": { + "cancel": "Não", + "confirm": "Sim", + "title": "Tem a certeza?" + }, + "delete_posts": { + "cancel": "Cancelar", + "confirm": "Eliminar", + "title": "Tem a certeza que pretende eliminar esta publicação?" + } + }, "conversation": { "with": "com" }, @@ -134,11 +141,6 @@ "copy_link_to_post": "Copiar ligação para esta publicação", "delete": "Eliminar", "delete_and_redraft": "Eliminar & re-editar", - "delete_confirm": { - "cancel": "Cancelar", - "confirm": "Eliminar", - "title": "Tem a certeza que pretende eliminar esta publicação?" - }, "direct_message_account": "Mensagem direta a {0}", "edit": "Editar", "hide_reblogs": "Esconder partilhas de {0}", diff --git a/locales/tr-TR.json b/locales/tr-TR.json index 30aadd0d..7adbb919 100644 --- a/locales/tr-TR.json +++ b/locales/tr-TR.json @@ -86,11 +86,6 @@ "toggle_zen_mode": "Zen mod durumunu değiştir" }, "common": { - "confirm_dialog": { - "cancel": "Hayır", - "confirm": "Evet", - "title": "Emin misiniz?" - }, "end_of_list": "Listenin sonu", "error": "HATA", "in": "içinde", @@ -101,6 +96,18 @@ "draft_title": "Taslak {0}", "drafts": "Taslaklar ({v})" }, + "confirm": { + "common": { + "cancel": "Hayır", + "confirm": "Evet", + "title": "Emin misiniz?" + }, + "delete_posts": { + "cancel": "İptal et", + "confirm": "Sil", + "title": "Bu gönderiyi silmek istediğinizden emin misiniz?" + } + }, "conversation": { "with": "ile" }, @@ -131,11 +138,6 @@ "copy_link_to_post": "Bu gönderinin linkini kopyala", "delete": "Sil", "delete_and_redraft": "Sil & yeniden taslak yap", - "delete_confirm": { - "cancel": "İptal et", - "confirm": "Sil", - "title": "Bu gönderiyi silmek istediğinizden emin misiniz?" - }, "direct_message_account": "{0} özel mesaj gönder", "edit": "Düzenle", "hide_reblogs": "{0} boostlarını gizle", diff --git a/locales/uk-UA.json b/locales/uk-UA.json index a558ea44..5a5a7c0d 100644 --- a/locales/uk-UA.json +++ b/locales/uk-UA.json @@ -86,11 +86,6 @@ "toggle_zen_mode": "Перемкнути режим Zen" }, "common": { - "confirm_dialog": { - "cancel": "Відмінити", - "confirm": "Так", - "title": "Ви впевнені?" - }, "end_of_list": "Кінець списку", "error": "ПОМИЛКА", "in": "в", @@ -101,6 +96,17 @@ "draft_title": "Чернетка {0}", "drafts": "Чернетки ({v})" }, + "confirm": { + "common": { + "cancel": "Відмінити", + "confirm": "Так" + }, + "delete_posts": { + "cancel": "Скасувати", + "confirm": "Видалити", + "title": "Ви впевнені, що хочете видалити цей допис?" + } + }, "conversation": { "with": "з" }, @@ -131,11 +137,6 @@ "copy_link_to_post": "Скопіювати посилання на цей допис", "delete": "Видалити", "delete_and_redraft": "Видалити і переписати", - "delete_confirm": { - "cancel": "Скасувати", - "confirm": "Видалити", - "title": "Ви впевнені, що хочете видалити цей допис?" - }, "direct_message_account": "Пряме повідомлення {0}", "edit": "Редагувати", "mention_account": "Згадати {0}", diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 72ac4665..823736e0 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -85,11 +85,6 @@ "toggle_zen_mode": "切换禅模式" }, "common": { - "confirm_dialog": { - "cancel": "否", - "confirm": "是", - "title": "你确定 {0} 吗?" - }, "end_of_list": "列表到底啦", "error": "错误", "in": "在", @@ -101,6 +96,35 @@ "drafts": "草稿 ({v})" }, "confirm": { + "block_account": { + "cancel": "取消", + "confirm": "拉黑", + "title": "你确定拉黑 {0} 吗?" + }, + "block_domain": { + "cancel": "取消", + "confirm": "拉黑", + "title": "你确定拉黑域名 {0} 吗?" + }, + "common": { + "cancel": "否", + "confirm": "是" + }, + "delete_posts": { + "cancel": "取消", + "confirm": "删除", + "title": "你确定要删除这条帖文吗?" + }, + "mute_account": { + "cancel": "取消", + "confirm": "屏蔽", + "title": "你确定屏蔽 {0} 吗?" + }, + "show_reblogs": { + "cancel": "取消", + "confirm": "显示", + "title": "你确定要显示来自 {0} 的转发吗?" + }, "unfollow": { "cancel": "取消", "confirm": "取消关注", @@ -137,11 +161,6 @@ "copy_link_to_post": "复制这篇帖文的链接", "delete": "删除", "delete_and_redraft": "删除并重新编辑", - "delete_confirm": { - "cancel": "取消", - "confirm": "删除", - "title": "你确定要删除这条帖文吗?" - }, "direct_message_account": "私信 {0}", "edit": "编辑", "hide_reblogs": "隐藏来自 {0} 的转发", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index f6976cb4..15d0cc25 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -88,11 +88,6 @@ "toggle_zen_mode": "切換禪模式" }, "common": { - "confirm_dialog": { - "cancel": "否", - "confirm": "是", - "title": "你確定 {0} 嗎?" - }, "end_of_list": "清單到底啦", "error": "錯誤", "in": "在", @@ -104,6 +99,35 @@ "drafts": "草稿 ({v})" }, "confirm": { + "block_account": { + "cancel": "取消", + "confirm": "拉黑", + "title": "你确定將 {0} 加入黑名單吗?" + }, + "block_domain": { + "cancel": "取消", + "confirm": "拉黑", + "title": "你确定將 {0} 加入域名黑名單吗?" + }, + "common": { + "cancel": "否", + "confirm": "是" + }, + "delete_posts": { + "cancel": "取消", + "confirm": "刪除", + "title": "你確定要刪除這則貼文嗎?" + }, + "mute_account": { + "cancel": "取消", + "confirm": "靜音", + "title": "你确定要靜音 {0}吗?" + }, + "show_reblogs": { + "cancel": "取消", + "confirm": "顯示", + "title": "你确定要顯示來自 {0} 的轉發吗?" + }, "unfollow": { "cancel": "取消", "confirm": "取消關注", @@ -140,11 +164,6 @@ "copy_link_to_post": "複製這篇貼文的連結", "delete": "刪除", "delete_and_redraft": "刪除並重新編輯", - "delete_confirm": { - "cancel": "取消", - "confirm": "刪除", - "title": "你確定要刪除這則貼文嗎?" - }, "direct_message_account": "私訊 {0}", "edit": "編輯", "hide_reblogs": "隱藏來自 {0} 的轉發",