Skip to content

Commit

Permalink
Remove %{type} from translation strings and use explicit strings for …
Browse files Browse the repository at this point in the history
…file and folder

And use proper ngettext function for plural translation
  • Loading branch information
DeepDiver1975 committed Jul 13, 2020
1 parent 604e8b5 commit d7382d0
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 24 deletions.
8 changes: 5 additions & 3 deletions apps/files/src/components/FileList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ export default {
data() {
return {
labelSelectAllItems: this.$gettext('Select all items'),
labelSelectSingleItemText: this.$gettext('Select %{type} %{name}'),
rowActions: [],
rowActionsDisplayed: false,
rowActionsItem: {}
Expand Down Expand Up @@ -219,9 +218,12 @@ export default {
]),
labelSelectSingleItem(item) {
const labelSelectSingleFileText = this.$gettext('Select file %{name}')
const labelSelectSingleFolderText = this.$gettext('Select folder %{name}')
return this.$gettextInterpolate(
this.labelSelectSingleItemText,
{ name: item.name, type: item.type },
item.type === 'file' ? labelSelectSingleFileText : labelSelectSingleFolderText,
{ name: item.name },
true
)
},
Expand Down
5 changes: 3 additions & 2 deletions apps/files/src/components/FileSharingSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,9 @@ export default {
return this.highlightedFile.canShare()
},
noResharePermsMessage() {
const translated = this.$gettext("You don't have permission to share this %{type}.")
return this.$gettextInterpolate(translated, { type: this.highlightedFile.type }, false)
const translatedFile = this.$gettext("You don't have permission to share this file.")
const translatedFolder = this.$gettext("You don't have permission to share this folder.")
return this.highlightedFile.type === 'file' ? translatedFile : translatedFolder
},
currentUsersPermissions() {
Expand Down
12 changes: 10 additions & 2 deletions apps/files/src/components/LocationPicker/LocationPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,18 @@ export default {
if (this.currentAction === 'move') {
title = this.$gettext('An error occurred while moving several resources')
desc = this.$gettext('%{count} resources could not be moved')
desc = this.$ngettext(
'%{count} resource could not be moved',
'%{count} resources could not be moved',
errors.length
)
} else if (this.currentAction === 'copy') {
title = this.$gettext('An error occurred while copying several resources')
desc = this.$gettext('%{count} resources could not be copied')
desc = this.$ngettext(
'%{count} resource could not be copied',
'%{count} resources could not be copied',
errors.length
)
}
this.showMessage({
Expand Down
46 changes: 29 additions & 17 deletions apps/files/src/mixins/deleteResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,56 @@ export default {
let title = null

if (resources.length === 1) {
title = this.$_deleteResources_isInTrashbin
? this.$gettext('Permanently delete %{type} %{name}')
: this.$gettext('Delete %{type} %{name}')

if (isFolder) {
title = this.$_deleteResources_isInTrashbin
? this.$gettext('Permanently delete folder %{name}')
: this.$gettext('Delete folder %{name}')
} else {
title = this.$_deleteResources_isInTrashbin
? this.$gettext('Permanently delete file %{name}')
: this.$gettext('Delete file %{name}')
}
return this.$gettextInterpolate(
title,
{
type: isFolder ? this.$gettext('folder') : this.$gettext('file'),
name: resources[0].name
},
true
)
}

title = this.$_deleteResources_isInTrashbin
? this.$gettext('Permanently delete %{amount} selected resources?')
: this.$gettext('Delete %{amount} selected resources')
? this.$ngettext(
'Permanently delete %{amount} selected resource?',
'Permanently delete %{amount} selected resources?',
resources.length
)
: this.$ngettext(
'Delete %{amount} selected resource?',
'Delete %{amount} selected resources?',
resources.length
)

return this.$gettextInterpolate(title, { amount: resources.length }, false)
},

$_deleteResources_dialogMessage() {
const resources = this.$_deleteResources_resources
const isFolder = resources[0].type === 'folder'
let message = null

if (resources.length === 1) {
message = this.$_deleteResources_isInTrashbin
if (isFolder) {
return this.$_deleteResources_isInTrashbin
? this.$gettext(
'Are you sure you want to delete this folder? All it’s content will be permanently removed. This action cannot be undone.'
)
: this.$gettext('Are you sure you want to delete this folder?')
}
return this.$_deleteResources_isInTrashbin
? this.$gettext(
'Are you sure you want to delete this %{type}? All it’s content will be permanently removed. This action cannot be undone.'
'Are you sure you want to delete this file? All it’s content will be permanently removed. This action cannot be undone.'
)
: this.$gettext('Are you sure you want to delete this %{type}?')

return this.$gettextInterpolate(
message,
{ type: isFolder ? this.$gettext('folder') : this.$gettext('file') },
true
)
: this.$gettext('Are you sure you want to delete this file?')
}

return this.$_deleteResources_isInTrashbin
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/3769
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix translations string

Allow better translations of various strings.

https://github.com/owncloud/phoenix/pull/3766
https://github.com/owncloud/phoenix/pull/3769

0 comments on commit d7382d0

Please sign in to comment.