]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files_sharing): file request use l10n `t` and `n` aliases
authorskjnldsv <skjnldsv@protonmail.com>
Tue, 16 Jul 2024 16:01:55 +0000 (18:01 +0200)
committerskjnldsv <skjnldsv@protonmail.com>
Thu, 18 Jul 2024 17:47:11 +0000 (19:47 +0200)
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
apps/files_sharing/src/components/NewFileRequestDialog.vue
apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogDatePassword.vue
apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogFinish.vue
apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogIntro.vue

index 2e15babeae573063d93a93092866d2a4964e8cad..3bca39d4f3840dd68c1dd81ff2d8a8d9ee6fe1c6 100644 (file)
@@ -115,7 +115,7 @@ import { generateOcsUrl } from '@nextcloud/router'
 import { Permission } from '@nextcloud/files'
 import { ShareType } from '@nextcloud/sharing'
 import { showError, showSuccess } from '@nextcloud/dialogs'
-import { translate, translatePlural } from '@nextcloud/l10n'
+import { n, t } from '@nextcloud/l10n'
 import axios from '@nextcloud/axios'
 
 import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
@@ -170,9 +170,8 @@ export default defineComponent({
        setup() {
                return {
                        STEP,
-
-                       n: translatePlural,
-                       t: translate,
+                       n,
+                       t,
 
                        isShareByMailEnabled: sharingConfig.isMailShareAllowed,
                }
@@ -199,9 +198,9 @@ export default defineComponent({
        computed: {
                finishButtonLabel() {
                        if (this.emails.length === 0) {
-                               return this.t('files_sharing', 'Close')
+                               return t('files_sharing', 'Close')
                        }
-                       return this.n('files_sharing', 'Close and send email', 'Close and send {count} emails', this.emails.length, { count: this.emails.length })
+                       return n('files_sharing', 'Close and send email', 'Close and send {count} emails', this.emails.length, { count: this.emails.length })
                },
        },
 
@@ -216,7 +215,7 @@ export default defineComponent({
                        // cannot share root
                        if (this.destination === '/' || this.destination === '') {
                                const destinationInput = form.querySelector('input[name="destination"]') as HTMLInputElement
-                               destinationInput?.setCustomValidity(this.t('files_sharing', 'Please select a folder, you cannot share the root directory.'))
+                               destinationInput?.setCustomValidity(t('files_sharing', 'Please select a folder, you cannot share the root directory.'))
                                form.reportValidity()
                                return
                        }
@@ -240,7 +239,7 @@ export default defineComponent({
 
                async onFinish() {
                        if (this.emails.length === 0 || this.isShareByMailEnabled === false) {
-                               showSuccess(this.t('files_sharing', 'File request created'))
+                               showSuccess(t('files_sharing', 'File request created'))
                                this.$emit('close')
                                return
                        }
@@ -248,9 +247,9 @@ export default defineComponent({
                        if (sharingConfig.isMailShareAllowed && this.emails.length > 0) {
                                await this.setShareEmails()
                                await this.sendEmails()
-                               showSuccess(this.n('files_sharing', 'File request created and email sent', 'File request created and {count} emails sent', this.emails.length, { count: this.emails.length }))
+                               showSuccess(n('files_sharing', 'File request created and email sent', 'File request created and {count} emails sent', this.emails.length, { count: this.emails.length }))
                        } else {
-                               showSuccess(this.t('files_sharing', 'File request created'))
+                               showSuccess(t('files_sharing', 'File request created'))
                        }
 
                        // Show success then close
@@ -306,8 +305,8 @@ export default defineComponent({
                                const errorMessage = (error as AxiosError<OCSResponse>)?.response?.data?.ocs?.meta?.message
                                showError(
                                        errorMessage
-                                               ? this.t('files_sharing', 'Error creating the share: {errorMessage}', { errorMessage })
-                                               : this.t('files_sharing', 'Error creating the share'),
+                                               ? t('files_sharing', 'Error creating the share: {errorMessage}', { errorMessage })
+                                               : t('files_sharing', 'Error creating the share'),
                                )
                                logger.error('Error while creating share', { error, errorMessage })
                                throw error
@@ -378,8 +377,8 @@ export default defineComponent({
                        const errorMessage = error.response?.data?.ocs?.meta?.message
                        showError(
                                errorMessage
-                                       ? this.t('files_sharing', 'Error sending emails: {errorMessage}', { errorMessage })
-                                       : this.t('files_sharing', 'Error sending emails'),
+                                       ? t('files_sharing', 'Error sending emails: {errorMessage}', { errorMessage })
+                                       : t('files_sharing', 'Error sending emails'),
                        )
                        logger.error('Error while sending emails', { error, errorMessage })
                },
index 9bb1863e1d1baef8b5fae775d4eec5a8746c0d11..e88496c84161907468321156a053107d90c91a29 100644 (file)
@@ -81,7 +81,7 @@
 
 <script lang="ts">
 import { defineComponent, type PropType } from 'vue'
-import { translate } from '@nextcloud/l10n'
+import { t } from '@nextcloud/l10n'
 
 import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
 import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
@@ -133,7 +133,7 @@ export default defineComponent({
 
        setup() {
                return {
-                       t: translate,
+                       t,
 
                        // Default expiration date if defaultExpireDateEnabled is true
                        defaultExpireDate: sharingConfig.defaultExpireDate,
@@ -159,19 +159,19 @@ export default defineComponent({
        computed: {
                passwordAndExpirationSummary(): string {
                        if (this.expirationDate && this.password) {
-                               return this.t('files_sharing', 'The request will expire on {date} at midnight and will be password protected.', {
+                               return t('files_sharing', 'The request will expire on {date} at midnight and will be password protected.', {
                                        date: this.expirationDate.toLocaleDateString(),
                                })
                        }
 
                        if (this.expirationDate) {
-                               return this.t('files_sharing', 'The request will expire on {date} at midnight.', {
+                               return t('files_sharing', 'The request will expire on {date} at midnight.', {
                                        date: this.expirationDate.toLocaleDateString(),
                                })
                        }
 
                        if (this.password) {
-                               return this.t('files_sharing', 'The request will be password protected.')
+                               return t('files_sharing', 'The request will be password protected.')
                        }
 
                        return ''
index 19753b8e6e25d3bd46a435cc7c989bc5b3a25339..243ae9a584c187760a649369b27acd2b7cd50081 100644 (file)
@@ -61,7 +61,7 @@ import Share from '../../models/Share'
 import { defineComponent } from 'vue'
 import { generateUrl, getBaseUrl } from '@nextcloud/router'
 import { showError, showSuccess } from '@nextcloud/dialogs'
-import { translate, translatePlural } from '@nextcloud/l10n'
+import { n, t } from '@nextcloud/l10n'
 
 import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
 import NcInputField from '@nextcloud/vue/dist/Components/NcInputField.js'
@@ -104,8 +104,7 @@ export default defineComponent({
 
        setup() {
                return {
-                       n: translatePlural,
-                       t: translate,
+                       n, t,
                }
        },
 
@@ -131,13 +130,13 @@ export default defineComponent({
 
                        if (!navigator.clipboard) {
                                // Clipboard API not available
-                               window.prompt(this.t('files_sharing', 'Automatically copying failed, please copy the share link manually'), this.shareLink)
+                               window.prompt(t('files_sharing', 'Automatically copying failed, please copy the share link manually'), this.shareLink)
                                return
                        }
 
                        await navigator.clipboard.writeText(this.shareLink)
 
-                       showSuccess(this.t('files_sharing', 'Link copied to clipboard'))
+                       showSuccess(t('files_sharing', 'Link copied to clipboard'))
                        this.isCopied = true
                        event.target?.select?.()
 
@@ -155,13 +154,13 @@ export default defineComponent({
 
                                // The email is already in the list
                                if (this.emails.includes(this.email.trim())) {
-                                       e.target.setCustomValidity(this.t('files_sharing', 'Email already added'))
+                                       e.target.setCustomValidity(t('files_sharing', 'Email already added'))
                                        e.target.reportValidity()
                                        return
                                }
 
                                if (!this.isValidEmail(this.email.trim())) {
-                                       e.target.setCustomValidity(this.t('files_sharing', 'Invalid email address'))
+                                       e.target.setCustomValidity(t('files_sharing', 'Invalid email address'))
                                        e.target.reportValidity()
                                        return
                                }
@@ -188,16 +187,16 @@ export default defineComponent({
 
                        // Warn about invalid emails
                        if (invalidEmails.length > 0) {
-                               showError(this.n('files_sharing', 'The following email address is not valid: {emails}', 'The following email addresses are not valid: {emails}', invalidEmails.length, { emails: invalidEmails.join(', ') }))
+                               showError(n('files_sharing', 'The following email address is not valid: {emails}', 'The following email addresses are not valid: {emails}', invalidEmails.length, { emails: invalidEmails.join(', ') }))
                        }
 
                        // Warn about duplicate emails
                        if (duplicateEmails.length > 0) {
-                               showError(this.n('files_sharing', '1 email address already added', '{count} email addresses already added', duplicateEmails.length, { count: duplicateEmails.length }))
+                               showError(n('files_sharing', '1 email address already added', '{count} email addresses already added', duplicateEmails.length, { count: duplicateEmails.length }))
                        }
 
                        if (validEmails.length > 0) {
-                               showSuccess(this.n('files_sharing', '1 email address added', '{count} email addresses added', validEmails.length, { count: validEmails.length }))
+                               showSuccess(n('files_sharing', '1 email address added', '{count} email addresses added', validEmails.length, { count: validEmails.length }))
                        }
 
                        this.email = ''
index c995cdc2442644b3cdf266c530418b74f4dda983..231ed94c460a12e1908b51fd07df3d8a66aa5be7 100644 (file)
@@ -66,7 +66,7 @@ import type { Folder, Node } from '@nextcloud/files'
 
 import { defineComponent } from 'vue'
 import { getFilePickerBuilder } from '@nextcloud/dialogs'
-import { translate } from '@nextcloud/l10n'
+import { t } from '@nextcloud/l10n'
 
 import IconFolder from 'vue-material-design-icons/Folder.vue'
 import NcTextArea from '@nextcloud/vue/dist/Components/NcTextArea.js'
@@ -113,17 +113,17 @@ export default defineComponent({
 
        setup() {
                return {
-                       t: translate,
+                       t,
                }
        },
 
        methods: {
                onPickDestination() {
-                       const filepicker = getFilePickerBuilder(this.t('files_sharing', 'Select a destination'))
+                       const filepicker = getFilePickerBuilder(t('files_sharing', 'Select a destination'))
                                .addMimeTypeFilter('httpd/unix-directory')
                                .allowDirectories(true)
                                .addButton({
-                                       label: this.t('files_sharing', 'Select'),
+                                       label: t('files_sharing', 'Select'),
                                        callback: this.onPickedDestination,
                                })
                                .setFilter(node => node.path !== '/')