mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(files_sharing): file request use l10n t and n aliases
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
This commit is contained in:
parent
365b647b60
commit
018e4c001d
4 changed files with 31 additions and 33 deletions
|
|
@ -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 })
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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 ''
|
||||
|
|
|
|||
|
|
@ -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 = ''
|
||||
|
|
|
|||
|
|
@ -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 !== '/')
|
||||
|
|
|
|||
Loading…
Reference in a new issue