diff --git a/resources/assets/components/partials/profile/ProfileFeed.vue b/resources/assets/components/partials/profile/ProfileFeed.vue index c6c69efb0..748ec5a90 100644 --- a/resources/assets/components/partials/profile/ProfileFeed.vue +++ b/resources/assets/components/partials/profile/ProfileFeed.vue @@ -8,7 +8,7 @@ :class="[ tabIndex === 1 ? 'active' : '' ]" @click="toggleTab(1)" > - Posts + {{ $t("profile.posts")}} {{ $t('profile.editProfile') }} - My Portfolio + {{ $t("profile.myPortifolio") }} NEW @@ -421,10 +421,10 @@ }, getJoinedDate() { - let d = new Date(this.profile.created_at); - let month = new Intl.DateTimeFormat("en-US", { month: "long" }).format(d); - let year = d.getFullYear(); - return `${month} ${year}`; + return new Date(this.profile.created_at).toLocaleDateString(this.$i18n.locale, { + year: 'numeric', + month: 'long', + }); }, follow() { diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index cafd785a2..09f86dabd 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -1,3 +1,5 @@ +import VueI18n from 'vue-i18n'; + require('./polyfill'); window._ = require('lodash'); window.Popper = require('popper.js').default; @@ -19,7 +21,7 @@ if (token) { window.App = window.App || {}; window.App.redirect = function() { - document.querySelectorAll('a').forEach(function(i,k) { + document.querySelectorAll('a').forEach(function(i,k) { let a = i.getAttribute('href'); if(a && a.length > 5 && a.startsWith('https://')) { let url = new URL(a); @@ -31,7 +33,23 @@ window.App.redirect = function() { } window.App.boot = function() { - new Vue({ el: '#content'}); + Vue.use(VueI18n); + + let i18nMessages = { + en: require('./i18n/en.json'), + pt: require('./i18n/pt.json'), + }; + let locale = document.querySelector('html').getAttribute('lang'); + + const i18n = new VueI18n({ + locale: locale, // set locale + fallbackLocale: 'en', + messages: i18nMessages +}); + new Vue({ + el: '#content', + i18n, + }); } window.addEventListener("load", () => { @@ -67,8 +85,8 @@ window.App.util = { console.log('Unsupported method.'); }), }, - time: (function() { - return new Date; + time: (function() { + return new Date; }), version: 1, format: { @@ -78,40 +96,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); + 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 interval + "y"; + return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'year'); } - - interval = Math.floor(seconds / (60 * 60 * 24 * 7)); + interval = Math.floor(seconds / 2592000); if (interval >= 1) { - return interval + "w"; + return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'month'); } - - interval = Math.floor(seconds / (60 * 60 * 24)); + interval = Math.floor(seconds / 604800); if (interval >= 1) { - return interval + "d"; + return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'week'); } - - interval = Math.floor(seconds / (60 * 60)); + interval = Math.floor(seconds / 86400); if (interval >= 1) { - return interval + "h"; + return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'day'); + } + interval = Math.floor(seconds / 3600); + if (interval >= 1) { + return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'hour'); } - interval = Math.floor(seconds / 60); if (interval >= 1) { - return interval + "m"; + return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'minute'); } - - return Math.floor(seconds) + "s"; - }, + return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-seconds, 'second'); + }), timeAhead: (function(ts, short = true) { let date = Date.parse(ts); let diff = date - Date.parse(new Date()); @@ -154,9 +168,9 @@ window.App.util = { tag = '/i/redirect?url=' + encodeURIComponent(tag); } - return tag; + return tag; }) - }, + }, filters: [ ['1984','filter-1977'], ['Azen','filter-aden'], diff --git a/resources/assets/js/components/Profile.vue b/resources/assets/js/components/Profile.vue index 991d4ab62..36c2a3dac 100644 --- a/resources/assets/js/components/Profile.vue +++ b/resources/assets/js/components/Profile.vue @@ -16,7 +16,7 @@
-

You are blocking this account

+

{{ $t("profile.blocking")}}

Click here to view profile

@@ -49,7 +49,7 @@

{{formatCount(profile.statuses_count)}}

-

Posts

+

{{ $t("profile.posts")}}

@@ -57,7 +57,7 @@

{{formatCount(profile.followers_count)}}

-

Followers

+

{{ $t("profile.followers")}}

@@ -65,7 +65,7 @@

{{formatCount(profile.following_count)}}

-

Following

+

{{ $t("profile.following")}}

@@ -86,7 +86,7 @@

@@ -106,7 +106,7 @@ - Edit Profile + {{ $t("profile.editProfile") }} @@ -117,19 +117,19 @@
{{formatCount(profile.statuses_count)}} - Posts + {{ $t("profile.posts")}}
{{formatCount(profile.followers_count)}} - Followers + {{ $t("profile.followers")}}
{{formatCount(profile.following_count)}} - Following + {{ $t("profile.following")}}
@@ -141,11 +141,11 @@

{{formatWebsite(profile.website)}}

- Admin + {{ $t("profile.admin") }} - Follows You + {{ $t("profile.followYou") }} - Joined {{joinedAtFormat(profile.created_at)}} + {{$t("profile.joined")}} {{joinedAtFormat(profile.created_at)}}

@@ -156,7 +156,7 @@

- +