From e2d283d6b51661b96e4316e6fe3fbc06167ae6ce Mon Sep 17 00:00:00 2001 From: Felipe Mateus Date: Wed, 12 Mar 2025 07:52:43 -0300 Subject: [PATCH] translate notifications --- resources/assets/components/Notifications.vue | 30 ++++----- .../partials/timeline/Notification.vue | 60 +++++++++-------- .../components/sections/Notifications.vue | 39 +++++------ resources/assets/js/spa.js | 64 +++++++++---------- resources/lang/en/web.php | 17 +++++ resources/lang/pt/web.php | 62 +++++++++++------- 6 files changed, 153 insertions(+), 119 deletions(-) diff --git a/resources/assets/components/Notifications.vue b/resources/assets/components/Notifications.vue index 2fb085b4e..27217b699 100644 --- a/resources/assets/components/Notifications.vue +++ b/resources/assets/components/Notifications.vue @@ -9,7 +9,7 @@
@@ -19,7 +19,7 @@

- Follow Requests + {{ $t("notifications.followRequests") }}

@@ -141,13 +141,13 @@ class="btn btn-outline-success py-1 btn-sm font-weight-bold rounded-pill mr-2 mb-1" @click.prevent="handleFollowRequest('accept', index)" > - Accept + {{ $t('notifications.accept') }} @@ -161,7 +161,7 @@
-

Filtering results may not include older notifications

+

{{ $t("notifications.filteringResults") }}

@@ -244,40 +244,40 @@ { id: 'mentions', - name: 'Mentions', - description: 'Replies to your posts and posts you were mentioned in', + name: this.$t("notifications.mentions"), + description: this.$t("notifications.mentionsDescription"), icon: 'far fa-at', types: ['comment', 'mention'] }, { id: 'likes', - name: 'Likes', - description: 'Accounts that liked your posts', + name: this.$t("notifications.likes"), + description: this.$t("notifications.likesDescription"), icon: 'far fa-heart', types: ['favourite'] }, { id: 'followers', - name: 'Followers', - description: 'Accounts that followed you', + name: this.$t("notifications.followers"), + description: this.$t("notifications.followersDescription"), icon: 'far fa-user-plus', types: ['follow'] }, { id: 'reblogs', - name: 'Reblogs', - description: 'Accounts that shared or reblogged your posts', + name: this.$t("notifications.reblogs"), + description:this.$t("notifications.reblogsDescription"), icon: 'far fa-retweet', types: ['share'] }, { id: 'direct', - name: 'DMs', - description: 'Direct messages you have with other accounts', + name: this.$t("notifications.dms"), + description: this.$t("notifications.dmsDescription"), icon: 'far fa-envelope', types: ['direct'] }, diff --git a/resources/assets/components/partials/timeline/Notification.vue b/resources/assets/components/partials/timeline/Notification.vue index 8f6a011a4..078717a6a 100644 --- a/resources/assets/components/partials/timeline/Notification.vue +++ b/resources/assets/components/partials/timeline/Notification.vue @@ -7,13 +7,13 @@

- @{{n.account.acct}} {{ $t('notifications.liked') }} post. + @{{n.account.acct}} {{ $t('notifications.liked') }} {{ $t("notifications.post")}}.

- @{{n.account.acct}} {{ $t('notifications.commented') }} post. + @{{n.account.acct}} {{ $t('notifications.commented') }} {{ $t("notifications.post")}}.

@@ -25,7 +25,7 @@

- @{{n.account.acct}} {{ $t('notifications.reacted') }} story. + @{{n.account.acct}} {{ $t('notifications.reacted') }} {{ $t('notifications.story') }}.

@@ -141,30 +141,36 @@ return text.slice(0, limit) + '...' }, - timeAgo(ts) { - let date = Date.parse(ts); - let seconds = Math.floor((new Date() - date) / 1000); - let interval = Math.floor(seconds / 31536000); - if (interval >= 1) { - return interval + "y"; - } - interval = Math.floor(seconds / 604800); - if (interval >= 1) { - return interval + "w"; - } - interval = Math.floor(seconds / 86400); - if (interval >= 1) { - return interval + "d"; - } - interval = Math.floor(seconds / 3600); - if (interval >= 1) { - return interval + "h"; - } - interval = Math.floor(seconds / 60); - if (interval >= 1) { - return interval + "m"; - } - return Math.floor(seconds) + "s"; + timeAgo(ts) { + let date = new Date(ts); + let now = new Date(); + let seconds = Math.floor((now - date) / 1000); + let interval = Math.floor(seconds / 31536000); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'year'); + } + interval = Math.floor(seconds / 2592000); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'month'); + } + interval = Math.floor(seconds / 604800); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'week'); + } + interval = Math.floor(seconds / 86400); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'day'); + } + interval = Math.floor(seconds / 3600); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'hour'); + } + interval = Math.floor(seconds / 60); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'minute'); + } + return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-seconds, 'second'); + }, mentionUrl(status) { diff --git a/resources/assets/components/sections/Notifications.vue b/resources/assets/components/sections/Notifications.vue index 1ddf522fc..d20d472d8 100644 --- a/resources/assets/components/sections/Notifications.vue +++ b/resources/assets/components/sections/Notifications.vue @@ -3,7 +3,7 @@
- Notifications + {{ $t("notifications.title")}}
@@ -49,27 +49,28 @@ class="mr-2 rounded-circle shadow-sm" :src="n.account.avatar" width="32" + height="32" onerror="this.onerror=null;this.src='/storage/avatars/default.png';">

- Your recent post has been unlisted. + {{ $t("notifications.youRecent")}} {{ $t("notifications.post")}} {{ $t("notifications.hasUnlisted")}}.

Click here for more info. @@ -77,64 +78,64 @@

- {{truncate(n.account.username)}} updated a modlog. + {{truncate(n.account.username)}} {{ $t("notifications.updatedA")}} modlog.

- Your application to join the {{truncate(n.group.name)}} group was approved! + {{ $t("notifications.yourApplication")}} {{truncate(n.group.name)}} {{ $t("notifications.wasApproved")}}

- Your application to join {{truncate(n.group.name)}} was rejected. + {{ $t("notifications.yourApplication")}} {{truncate(n.group.name)}} {{ $t("notifications.wasRejected")}}

@@ -146,11 +147,11 @@

- We cannot display this notification at this time. + {{ $t("notifications.cannotDisplay")}}

-
{{timeAgo(n.created_at)}}
+
{{timeAgo(n.created_at)}}
diff --git a/resources/assets/js/spa.js b/resources/assets/js/spa.js index 73bd22f2e..0d74c6dc8 100644 --- a/resources/assets/js/spa.js +++ b/resources/assets/js/spa.js @@ -697,40 +697,36 @@ window.App.util = { } return new Intl.NumberFormat(locale, { notation: notation , compactDisplay: "short" }).format(count); }), - timeAgo: function(ts) { - const date = new Date(ts); - const now = new Date(); - - const seconds = Math.floor((now - date) / 1000); - - const secondsInYear = 60 * 60 * 24 * 365.25; - let interval = Math.floor(seconds / secondsInYear); - if (interval >= 1) { - return interval + "y"; - } - - interval = Math.floor(seconds / (60 * 60 * 24 * 7)); - if (interval >= 1) { - return interval + "w"; - } - - interval = Math.floor(seconds / (60 * 60 * 24)); - if (interval >= 1) { - return interval + "d"; - } - - interval = Math.floor(seconds / (60 * 60)); - if (interval >= 1) { - return interval + "h"; - } - - interval = Math.floor(seconds / 60); - if (interval >= 1) { - return interval + "m"; - } - - return Math.floor(seconds) + "s"; - }, + timeAgo: (function(ts) { + let date = new Date(ts); + let now = new Date(); + let seconds = Math.floor((now - date) / 1000); + let interval = Math.floor(seconds / 31536000); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(i18n.locale, { numeric: 'auto', style: 'short' }).format(-interval, 'year'); + } + interval = Math.floor(seconds / 2592000); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(i18n.locale, { numeric: 'auto', style: 'short' }).format(-interval, 'month'); + } + interval = Math.floor(seconds / 604800); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(i18n.locale, { numeric: 'auto', style: 'short' }).format(-interval, 'week'); + } + interval = Math.floor(seconds / 86400); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(i18n.locale, { numeric: 'auto', style: 'short' }).format(-interval, 'day'); + } + interval = Math.floor(seconds / 3600); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(i18n.locale, { numeric: 'auto', style: 'short' }).format(-interval, 'hour'); + } + interval = Math.floor(seconds / 60); + if (interval >= 1) { + return new Intl.RelativeTimeFormat(i18n.locale, { numeric: 'auto', style: 'short' }).format(-interval, 'minute'); + } + return new Intl.RelativeTimeFormat(i18n.locale, { numeric: 'auto', style: 'short' }).format(-seconds, 'second'); + }), timeAhead: (function(ts, short = true) { let date = Date.parse(ts); let diff = date - Date.parse(new Date()); diff --git a/resources/lang/en/web.php b/resources/lang/en/web.php index 3acde415b..d20781257 100644 --- a/resources/lang/en/web.php +++ b/resources/lang/en/web.php @@ -104,6 +104,23 @@ return [ 'post' => 'post', 'story' => 'story', 'noneFound' => 'No notifications found', + 'youRecent' => 'You recent', + 'hasUnlisted' => 'has been unlisted', + 'cannotDisplay' => 'We cannot display this notification at this time.', + 'followRequest' => 'Follow Requests', + 'filteringResults' => 'Filtering results may not include older notifications', + 'mentions' => 'Mentions', + 'mentionsDescription' => 'Replies to your posts and posts you were mentioned in', + 'likes' => 'Likes', + 'likesDescription' => 'Accounts that liked your posts', + 'followers' => 'Followers', + 'followersDescription' => 'Accounts that followed you', + 'reblogs' => 'Reblogs', + 'reblogsDescription' => 'Accounts that shared or reblogged your posts', + 'dms' => 'DMs', + 'dmsDescription' => 'Direct messages you have with other accounts', + 'accept' => 'Accept', + 'reject' => 'Reject' ], 'post' => [ diff --git a/resources/lang/pt/web.php b/resources/lang/pt/web.php index 6b6c8aded..2051d7a23 100644 --- a/resources/lang/pt/web.php +++ b/resources/lang/pt/web.php @@ -79,30 +79,44 @@ return [ 'requests' => 'Pedidos' ], - 'notifications' => [ - 'liked' => 'gostou do seu', - 'commented' => 'comentou no seu', - 'reacted' => 'reagiu ao seu', - 'shared' => 'partilhou o teu', - 'tagged' => 'etiquetou-te numa publicação', - - 'updatedA' => 'atualizou uma', - 'sentA' => 'enviou uma', - - 'followed' => 'seguiu-te', - 'mentioned' => 'mencionou-te', - 'you' => 'tu', - - 'yourApplication' => 'O teu pedido de adesão', - 'applicationApproved' => 'foi aprovado!', - 'applicationRejected' => 'foi rejeitado. Podes voltar a candidatar-te dentro de 6 meses.', - - 'dm' => 'md', - 'groupPost' => 'publicação de grupo', - 'modlog' => 'histórico de moderação', - 'post' => 'publicação', - 'story' => 'estória', - 'noneFound' => 'Nenhuma notificação encontrada', + 'notifications' => [ + 'title' => 'Notificações', + 'liked' => 'curtiu sua', + 'commented' => 'comentou na sua', + 'reacted' => 'reagiu à sua', + 'shared' => 'compartilhou a sua', + 'tagged' => 'marcou você numa publicação', + 'updatedA' => 'atualizou', + 'sentA' => 'enviou um', + 'followed' => 'seguiu', + 'mentioned' => 'mencionou', + 'you' => 'você', + 'yourApplication' => 'A sua candidatura para se juntar', + 'applicationApproved' => 'foi aprovada!', + 'applicationRejected' => 'foi rejeitada. Você pode inscrever-se novamente em 6 meses.', + 'dm' => 'mensagem direta', + 'groupPost' => 'publicação de grupo', + 'modlog' => 'histórico de moderação', + 'post' => 'publicação', + 'story' => 'estória', + 'noneFound' => 'Nenhuma notificação encontrada', + 'youRecent' => 'Você recente', + 'hasUnlisted' => 'foi removida da lista', + 'cannotDisplay' => 'Não podemos exibir esta notificação no momento.', + 'followRequest' => 'Pedidos de Seguimento', + 'filteringResults' => 'Os resultados do filtro podem não incluir notificações mais antigas', + 'mentions' => 'Menções', + 'mentionsDescription' => 'Respostas às suas publicações e publicações em que você foi mencionado', + 'likes' => 'Curtidas', + 'likesDescription' => 'Contas que curtiram das suas publicações', + 'followers' => 'Seguidores', + 'followersDescription' => 'Contas que seguiram você', + 'reblogs' => 'Reblogs', + 'reblogsDescription' => 'Contas que compartilharam ou reblogaram suas publicações', + 'dms' => 'DMs', + 'dmsDescription' => 'Mensagens diretas que você tem com outras contas', + 'accept' => 'Aceitar', + 'reject' => 'Rejeitar' ], 'post' => [