From ebea32faf908bc8da41e56e3218ff8364704a351 Mon Sep 17 00:00:00 2001 From: wvffle Date: Thu, 8 Sep 2022 14:32:45 +0000 Subject: [PATCH] Replace gettext with i18n --- front/package.json | 1 - front/src/components/About.vue | 46 +-- front/src/components/AboutPod.vue | 80 ++-- front/src/components/Home.vue | 77 ++-- front/src/components/PageNotFound.vue | 12 +- front/src/components/Queue.vue | 60 +-- front/src/components/RemoteSearchForm.vue | 32 +- front/src/components/SetInstanceModal.vue | 26 +- front/src/components/ShortcutsModal.vue | 48 +-- front/src/components/Sidebar.vue | 100 +++-- front/src/components/admin/SettingsGroup.vue | 8 +- .../components/admin/SignupFormBuilder.vue | 42 +- front/src/components/audio/ChannelCard.vue | 10 +- front/src/components/audio/ChannelEntries.vue | 2 +- front/src/components/audio/ChannelForm.vue | 46 +-- .../src/components/audio/ChannelSerieCard.vue | 2 +- front/src/components/audio/ChannelSeries.vue | 4 +- front/src/components/audio/ChannelsWidget.vue | 2 +- front/src/components/audio/EmbedWizard.vue | 20 +- .../components/audio/LibraryFollowButton.vue | 6 +- front/src/components/audio/PlayButton.vue | 44 +-- front/src/components/audio/Player.vue | 38 +- front/src/components/audio/Search.vue | 16 +- front/src/components/audio/SearchBar.vue | 30 +- front/src/components/audio/VolumeControl.vue | 10 +- front/src/components/audio/album/Card.vue | 2 +- front/src/components/audio/album/Widget.vue | 2 +- front/src/components/audio/artist/Card.vue | 4 +- front/src/components/audio/artist/Widget.vue | 2 +- .../components/audio/podcast/MobileRow.vue | 6 +- front/src/components/audio/podcast/Modal.vue | 30 +- .../src/components/audio/track/MobileRow.vue | 6 +- front/src/components/audio/track/Modal.vue | 30 +- front/src/components/audio/track/Table.vue | 10 +- front/src/components/audio/track/Widget.vue | 4 +- front/src/components/auth/ApplicationEdit.vue | 26 +- front/src/components/auth/ApplicationForm.vue | 28 +- front/src/components/auth/ApplicationNew.vue | 19 +- front/src/components/auth/Authorize.vue | 30 +- front/src/components/auth/LoginForm.vue | 23 +- front/src/components/auth/Logout.vue | 16 +- front/src/components/auth/Plugin.vue | 14 +- front/src/components/auth/Settings.vue | 148 +++---- front/src/components/auth/SignupForm.vue | 32 +- .../src/components/auth/SubsonicTokenForm.vue | 42 +- front/src/components/channels/AlbumForm.vue | 4 +- front/src/components/channels/AlbumModal.vue | 8 +- front/src/components/channels/AlbumSelect.vue | 8 +- .../src/components/channels/LicenseSelect.vue | 6 +- .../components/channels/SubscribeButton.vue | 10 +- front/src/components/channels/UploadForm.vue | 36 +- .../channels/UploadMetadataForm.vue | 10 +- front/src/components/channels/UploadModal.vue | 32 +- front/src/components/common/ActionTable.vue | 38 +- .../src/components/common/AttachmentInput.vue | 10 +- front/src/components/common/CollapseLink.vue | 4 +- front/src/components/common/ContentForm.vue | 14 +- front/src/components/common/CopyInput.vue | 4 +- .../src/components/common/DangerousButton.vue | 6 +- front/src/components/common/Duration.vue | 4 +- front/src/components/common/EmptyState.vue | 4 +- front/src/components/common/ExpandableDiv.vue | 4 +- .../src/components/common/InlineSearchBar.vue | 10 +- front/src/components/common/LoginModal.vue | 12 +- .../components/common/RenderedDescription.vue | 14 +- front/src/components/common/UserMenu.vue | 43 +- front/src/components/common/UserModal.vue | 40 +- front/src/components/favorites/List.vue | 24 +- .../favorites/TrackFavoriteIcon.vue | 12 +- .../src/components/federation/FetchButton.vue | 48 +-- .../components/federation/LibraryWidget.vue | 4 +- front/src/components/forms/PasswordInput.vue | 10 +- front/src/components/library/AlbumBase.vue | 18 +- front/src/components/library/AlbumDetail.vue | 9 +- .../src/components/library/AlbumDropdown.vue | 32 +- front/src/components/library/AlbumEdit.vue | 6 +- front/src/components/library/Albums.vue | 30 +- front/src/components/library/ArtistBase.vue | 32 +- front/src/components/library/ArtistDetail.vue | 16 +- front/src/components/library/ArtistEdit.vue | 6 +- front/src/components/library/Artists.vue | 32 +- front/src/components/library/EditCard.vue | 32 +- front/src/components/library/EditForm.vue | 40 +- front/src/components/library/FileUpload.vue | 69 ++-- front/src/components/library/FsBrowser.vue | 2 +- front/src/components/library/FsLogs.vue | 2 +- front/src/components/library/Home.vue | 16 +- .../components/library/ImportStatusModal.vue | 36 +- front/src/components/library/Podcasts.vue | 38 +- front/src/components/library/Radios.vue | 34 +- front/src/components/library/TagDetail.vue | 10 +- front/src/components/library/TagsSelector.vue | 2 +- front/src/components/library/TrackBase.vue | 44 +-- front/src/components/library/TrackDetail.vue | 52 +-- front/src/components/library/TrackEdit.vue | 6 +- .../src/components/library/radios/Builder.vue | 44 +-- .../src/components/library/radios/Filter.vue | 8 +- front/src/components/manage/ChannelsTable.vue | 38 +- .../components/manage/library/AlbumsTable.vue | 40 +- .../manage/library/ArtistsTable.vue | 38 +- .../manage/library/EditsCardList.vue | 28 +- .../manage/library/LibrariesTable.vue | 42 +- .../components/manage/library/TagsTable.vue | 32 +- .../components/manage/library/TracksTable.vue | 38 +- .../manage/library/UploadsTable.vue | 62 +-- .../manage/moderation/AccountsTable.vue | 36 +- .../manage/moderation/DomainsTable.vue | 48 +-- .../manage/moderation/InstancePolicyCard.vue | 18 +- .../manage/moderation/InstancePolicyForm.vue | 52 +-- .../manage/moderation/InstancePolicyModal.vue | 8 +- .../components/manage/moderation/NoteForm.vue | 10 +- .../manage/moderation/NotesThread.vue | 8 +- .../manage/moderation/ReportCard.vue | 68 ++-- .../manage/moderation/UserRequestCard.vue | 38 +- .../manage/users/InvitationForm.vue | 18 +- .../manage/users/InvitationsTable.vue | 40 +- .../components/manage/users/UsersTable.vue | 50 +-- .../src/components/moderation/FilterModal.vue | 26 +- .../moderation/ReportCategoryDropdown.vue | 8 +- .../src/components/moderation/ReportModal.vue | 32 +- .../notifications/NotificationRow.vue | 28 +- front/src/components/playlists/Card.vue | 2 +- front/src/components/playlists/Editor.vue | 30 +- front/src/components/playlists/Form.vue | 22 +- .../components/playlists/PlaylistModal.vue | 44 +-- .../playlists/TrackPlaylistIcon.vue | 8 +- front/src/components/playlists/Widget.vue | 6 +- front/src/components/radios/Button.vue | 20 +- front/src/components/radios/Card.vue | 2 +- front/src/components/tags/List.vue | 2 +- front/src/components/vui/Pagination.vue | 10 +- front/src/composables/audio/usePlayOptions.ts | 8 +- .../src/composables/locale/useSharedLabels.ts | 164 ++++---- .../composables/moderation/useEditConfigs.ts | 24 +- front/src/composables/moderation/useReport.ts | 36 +- .../moderation/useReportConfigs.ts | 44 +-- front/src/composables/useErrorHandler.ts | 10 +- front/src/composables/useThemeList.ts | 10 +- front/src/init/axios.ts | 18 +- front/src/init/locale.ts | 87 ++++- front/src/init/sentry.ts | 13 +- front/src/init/serviceWorker.ts | 12 +- front/src/store/ui.ts | 4 +- front/src/views/Notifications.vue | 52 +-- front/src/views/Search.vue | 30 +- front/src/views/admin/ChannelDetail.vue | 66 ++-- front/src/views/admin/CommonList.vue | 24 +- front/src/views/admin/Settings.vue | 30 +- front/src/views/admin/library/AlbumDetail.vue | 64 +-- .../src/views/admin/library/ArtistDetail.vue | 66 ++-- front/src/views/admin/library/Base.vue | 24 +- front/src/views/admin/library/EditsList.vue | 8 +- .../src/views/admin/library/LibraryDetail.vue | 56 +-- front/src/views/admin/library/TagDetail.vue | 28 +- front/src/views/admin/library/TrackDetail.vue | 74 ++-- .../src/views/admin/library/UploadDetail.vue | 62 +-- .../views/admin/moderation/AccountsDetail.vue | 100 ++--- front/src/views/admin/moderation/Base.vue | 16 +- .../views/admin/moderation/DomainsDetail.vue | 80 ++-- .../views/admin/moderation/DomainsList.vue | 16 +- .../views/admin/moderation/ReportsList.vue | 28 +- .../views/admin/moderation/RequestsList.vue | 30 +- front/src/views/admin/users/Base.vue | 12 +- front/src/views/auth/Callback.vue | 2 +- front/src/views/auth/EmailConfirm.vue | 18 +- front/src/views/auth/Login.vue | 8 +- front/src/views/auth/PasswordReset.vue | 20 +- front/src/views/auth/PasswordResetConfirm.vue | 22 +- front/src/views/auth/Plugins.vue | 6 +- front/src/views/auth/ProfileActivity.vue | 6 +- front/src/views/auth/ProfileBase.vue | 16 +- front/src/views/auth/ProfileOverview.vue | 24 +- front/src/views/auth/Signup.vue | 8 +- front/src/views/channels/DetailBase.vue | 68 ++-- front/src/views/channels/DetailOverview.vue | 26 +- .../src/views/channels/SubscriptionsList.vue | 16 +- front/src/views/content/Base.vue | 12 +- front/src/views/content/Home.vue | 28 +- front/src/views/content/libraries/Card.vue | 12 +- .../views/content/libraries/FilesTable.vue | 58 +-- front/src/views/content/libraries/Form.vue | 38 +- front/src/views/content/libraries/Home.vue | 8 +- front/src/views/content/libraries/Quota.vue | 42 +- front/src/views/content/remote/Card.vue | 48 +-- front/src/views/content/remote/Home.vue | 10 +- front/src/views/content/remote/ScanForm.vue | 12 +- front/src/views/library/DetailAlbums.vue | 4 +- front/src/views/library/DetailOverview.vue | 4 +- front/src/views/library/DetailTracks.vue | 4 +- front/src/views/library/Edit.vue | 26 +- front/src/views/library/LibraryBase.vue | 40 +- front/src/views/playlists/Detail.vue | 34 +- front/src/views/playlists/List.vue | 30 +- front/src/views/radios/Detail.vue | 16 +- front/test/specs/views/admin/library.test.ts | 3 +- front/tsconfig.json | 1 - front/yarn.lock | 366 +----------------- 197 files changed, 2623 insertions(+), 2932 deletions(-) diff --git a/front/package.json b/front/package.json index 43116ca50..051076f21 100644 --- a/front/package.json +++ b/front/package.json @@ -76,7 +76,6 @@ "@vue/eslint-config-typescript": "11.0.2", "@vue/test-utils": "2.2.4", "@vue/tsconfig": "0.1.3", - "easygettext": "2.17.0", "eslint": "8.28.0", "eslint-config-standard": "17.0.0", "eslint-plugin-html": "7.1.0", diff --git a/front/src/components/About.vue b/front/src/components/About.vue index 6e2bf9815..fddb6a1ba 100644 --- a/front/src/components/About.vue +++ b/front/src/components/About.vue @@ -1,6 +1,6 @@ @@ -20,13 +20,13 @@ const labels = computed(() => ({

- + Page not found!

- + Sorry, the page you asked for does not exist:

@@ -36,7 +36,7 @@ const labels = computed(() => ({ class="ui icon labeled right button" to="/" > - + Go to home page diff --git a/front/src/components/Queue.vue b/front/src/components/Queue.vue index 763058190..e90b613fa 100644 --- a/front/src/components/Queue.vue +++ b/front/src/components/Queue.vue @@ -4,7 +4,6 @@ import type { QueueItemSource } from '~/types' import { whenever, watchDebounced, useCurrentElement, useScrollLock, useFullscreen, useIdle, refAutoReset, useStorage } from '@vueuse/core' import { nextTick, ref, computed, watchEffect, onMounted } from 'vue' import { useFocusTrap } from '@vueuse/integrations/useFocusTrap' -import { useGettext } from 'vue3-gettext' import { useRouter } from 'vue-router' import { useStore } from '~/store' @@ -18,6 +17,11 @@ import TrackFavoriteIcon from '~/components/favorites/TrackFavoriteIcon.vue' import TrackPlaylistIcon from '~/components/playlists/TrackPlaylistIcon.vue' import PlayerControls from '~/components/audio/PlayerControls.vue' import MilkDrop from '~/components/audio/visualizer/MilkDrop.vue' +import { whenever, watchDebounced, useCurrentElement, useScrollLock } from '@vueuse/core' +import { useI18n } from 'vue-i18n' +import useQueue from '~/composables/audio/useQueue' +import usePlayer from '~/composables/audio/usePlayer' + import VirtualList from '~/components/vui/list/VirtualList.vue' import QueueItem from '~/components/QueueItem.vue' @@ -49,24 +53,24 @@ const { currentSound } = useTracks() const queueModal = ref() const { activate, deactivate } = useFocusTrap(queueModal, { allowOutsideClick: true, preventScroll: true }) -const { $pgettext } = useGettext() +const { t } = useI18n() const scrollLock = useScrollLock(document.body) const store = useStore() const labels = computed(() => ({ - queue: $pgettext('*/*/*', 'Queue'), - populating: $pgettext('*/*/*', 'Fetching radio track'), - duration: $pgettext('*/*/*', 'Duration'), - addArtistContentFilter: $pgettext('Sidebar/Player/Icon.Tooltip/Verb', 'Hide content from this artist…'), - restart: $pgettext('*/*/*', 'Restart track'), - previous: $pgettext('*/*/*', 'Previous track'), - next: $pgettext('*/*/*', 'Next track'), - pause: $pgettext('*/*/*', 'Pause'), - play: $pgettext('*/*/*', 'Play'), - fullscreen: $pgettext('*/*/*', 'Fullscreen'), - exitFullscreen: $pgettext('*/*/*', 'Exit fullscreen'), - showCoverArt: $pgettext('*/*/*', 'Show cover art'), - showVisualizer: $pgettext('*/*/*', 'Show visualizer') + queue: t('Queue'), + populating: t('Fetching radio track'), + duration: t('Duration'), + addArtistContentFilter: t('Hide content from this artist…'), + restart: t('Restart track'), + previous: t('Previous track'), + next: t('Next track'), + pause: t('Pause'), + play: t('Play'), + fullscreen: t('Fullscreen'), + exitFullscreen: t('Exit fullscreen'), + showCoverArt: t('Show cover art'), + showVisualizer: t('Show visualizer') })) watchEffect(async () => { @@ -125,10 +129,11 @@ const queueItems = computed(() => queue.value.map((track, index) => ({ ...track, key: `${index}-${track.id}`, labels: { - remove: $pgettext('*/*/*', 'Remove'), - selectTrack: $pgettext('*/*/*', 'Select track'), - favorite: $pgettext('*/*/*', 'Favorite track') - } + remove: t('Remove'), + selectTrack: t('Select track'), + favorite: t('Favorite track') + }, + duration: time.durationFormatted(track.uploads[0]?.duration ?? 0) ?? '' }) as QueueItemSource)) const reorderTracks = async (from: number, to: number) => { @@ -296,18 +301,18 @@ const coverType = useStorage('queue:cover-type', CoverType.COVER_ART) class="ui small warning message" >

- + The track cannot be loaded

- + The next track will play automatically in a few seconds…

- + You may have a connectivity issue.

@@ -408,7 +413,7 @@ const coverType = useStorage('queue:cover-type', CoverType.COVER_ART) class="ui right floated basic button" @click="$store.commit('ui/queueFocused', null)" > - + Close @@ -416,7 +421,7 @@ const coverType = useStorage('queue:cover-type', CoverType.COVER_ART) class="ui right floated basic button danger" @click="clear" > - + Clear @@ -424,7 +429,6 @@ const coverType = useStorage('queue:cover-type', CoverType.COVER_ART)
Track %{ index } of %{ length } @@ -473,12 +477,12 @@ const coverType = useStorage('queue:cover-type', CoverType.COVER_ART) >

- + You have a radio playing

- + New tracks will be appended here automatically.

@@ -486,7 +490,7 @@ const coverType = useStorage('queue:cover-type', CoverType.COVER_ART) class="ui basic primary button" @click="$store.dispatch('radios/stop')" > - + Stop radio diff --git a/front/src/components/RemoteSearchForm.vue b/front/src/components/RemoteSearchForm.vue index 5c50fd996..777f108a8 100644 --- a/front/src/components/RemoteSearchForm.vue +++ b/front/src/components/RemoteSearchForm.vue @@ -2,7 +2,7 @@ import type { BackendError } from '~/types' import { ref, computed, watch } from 'vue' -import { useGettext } from 'vue3-gettext' +import { useI18n } from 'vue-i18n' import { useRouter } from 'vue-router' import { useStore } from '~/store' @@ -37,17 +37,17 @@ const type = ref(props.initialType) const id = ref(props.initialId) const errors = ref([] as string[]) -const { $pgettext } = useGettext() +const { t } = useI18n() const labels = computed(() => ({ title: type.value === 'rss' - ? $pgettext('Head/Fetch/Title', 'Subscribe to a podcast RSS feed') - : $pgettext('Head/Fetch/Title', 'Subscribe to a podcast hosted on the Fediverse'), + ? t('Subscribe to a podcast RSS feed') + : t('Subscribe to a podcast hosted on the Fediverse'), fieldLabel: type.value === 'rss' - ? $pgettext('*/*/*', 'RSS feed location') - : $pgettext('*/*/*', 'Fediverse object'), + ? t('RSS feed location') + : t('Fediverse object'), fieldPlaceholder: type.value === 'rss' - ? $pgettext('Head/Fetch/Field.Placeholder', 'https://website.example.com/rss.xml') - : $pgettext('Head/Fetch/Field.Placeholder', '@username@example.com') + ? t('https://website.example.com/rss.xml') + : t('@username@example.com') })) const obj = ref() @@ -117,7 +117,7 @@ const createFetch = async () => { obj.value = response.data if (response.data.status === 'errored' || response.data.status === 'skipped') { - errors.value.push($pgettext('Content/*/Error message.Title', 'This object cannot be retrieved')) + errors.value.push(t('This object cannot be retrieved')) } } catch (error) { errors.value = (error as BackendError).backendErrors @@ -172,7 +172,7 @@ watch(() => props.initialId, () => { @click.prevent="type = 'rss'" > - + RSS @@ -182,7 +182,7 @@ watch(() => props.initialId, () => { @click.prevent="type = 'artists'" > - + Fediverse @@ -199,7 +199,7 @@ watch(() => props.initialId, () => { class="ui negative message" >

- + Error while fetching object

@@ -217,12 +217,12 @@ watch(() => props.initialId, () => { {{ labels.fieldLabel }}

- + Use this form to subscribe to an RSS feed from its URL.

- + Use this form to subscribe to a channel hosted somewhere else on the Fediverse.

@@ -241,7 +241,7 @@ watch(() => props.initialId, () => { :class="['ui', 'primary', {loading: isLoading}, 'button']" :disabled="isLoading || !id || id.length === 0" > - + Search @@ -252,7 +252,7 @@ watch(() => props.initialId, () => { class="ui warning message" >

- + This kind of object isn't supported yet

diff --git a/front/src/components/SetInstanceModal.vue b/front/src/components/SetInstanceModal.vue index ec50c76fd..70b00fb09 100644 --- a/front/src/components/SetInstanceModal.vue +++ b/front/src/components/SetInstanceModal.vue @@ -1,6 +1,6 @@ @@ -73,7 +73,7 @@ const labels = computed(() => ({