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'
setup() {
return {
STEP,
-
- n: translatePlural,
- t: translate,
+ n,
+ t,
isShareByMailEnabled: sharingConfig.isMailShareAllowed,
}
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 })
},
},
// 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
}
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
}
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
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
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 })
},
<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'
setup() {
return {
- t: translate,
+ t,
// Default expiration date if defaultExpireDateEnabled is true
defaultExpireDate: sharingConfig.defaultExpireDate,
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 ''
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'
setup() {
return {
- n: translatePlural,
- t: translate,
+ n, t,
}
},
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?.()
// 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
}
// 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 = ''
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'
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 !== '/')