[i18n] Attachments

stable
David Barragán Merino 2015-04-29 21:26:18 +02:00
parent e1e89ad48f
commit fdc6b83f64
7 changed files with 40 additions and 18 deletions

View File

@ -28,9 +28,9 @@ module = angular.module("taigaCommon")
class AttachmentsController extends taiga.Controller class AttachmentsController extends taiga.Controller
@.$inject = ["$scope", "$rootScope", "$tgRepo", "$tgResources", "$tgConfirm", "$q"] @.$inject = ["$scope", "$rootScope", "$tgRepo", "$tgResources", "$tgConfirm", "$q", "$translate"]
constructor: (@scope, @rootscope, @repo, @rs, @confirm, @q) -> constructor: (@scope, @rootscope, @repo, @rs, @confirm, @q, @translate) ->
bindMethods(@) bindMethods(@)
@.type = null @.type = null
@.objectId = null @.objectId = null
@ -75,10 +75,13 @@ class AttachmentsController extends taiga.Controller
promise = promise.then null, (data) => promise = promise.then null, (data) =>
@scope.$emit("attachments:size-error") if data.status == 413 @scope.$emit("attachments:size-error") if data.status == 413
index = @.uploadingAttachments.indexOf(attachment) index = @.uploadingAttachments.indexOf(attachment)
@.uploadingAttachments.splice(index, 1) @.uploadingAttachments.splice(index, 1)
@confirm.notify("error", "We have not been able to upload '#{attachment.name}'.
#{data.data._error_message}") message = @translate.instant("ATTACHMENT.ERROR_UPLOAD_ATTACHMENT", {
fileName: attachment.name, errorMessage: data.data._error_message})
@confirm.notify("error", message)
return @q.reject(data) return @q.reject(data)
return promise return promise
@ -130,8 +133,8 @@ class AttachmentsController extends taiga.Controller
# Remove one concrete attachment. # Remove one concrete attachment.
removeAttachment: (attachment) -> removeAttachment: (attachment) ->
title = "Delete attachment" #TODO: i18in title = @translate.instant("ATTACHMENT.TITLE_LIGHTBOX_DELETE_ATTACHMENT")
message = "the attachment '#{attachment.name}'" #TODO: i18in message = @translate.instant("ATTACHMENT.MSG_LIGHTBOX_DELETE_ATTACHMENT", {fileName: attachment.name})
return @confirm.askOnDelete(title, message).then (finish) => return @confirm.askOnDelete(title, message).then (finish) =>
onSuccess = => onSuccess = =>
@ -143,7 +146,8 @@ class AttachmentsController extends taiga.Controller
onError = => onError = =>
finish(false) finish(false)
@confirm.notify("error", null, "We have not been able to delete #{message}.") message = @translate.instant("ATTACHMENT.ERROR_DELETE_ATTACHMENT", {errorMessage: message})
@confirm.notify("error", null, message)
return @q.reject() return @q.reject()
return @repo.remove(attachment).then(onSuccess, onError) return @repo.remove(attachment).then(onSuccess, onError)
@ -242,7 +246,7 @@ AttachmentsDirective = ($config, $confirm, $templates) ->
module.directive("tgAttachments", ["$tgConfig", "$tgConfirm", "$tgTemplate", AttachmentsDirective]) module.directive("tgAttachments", ["$tgConfig", "$tgConfirm", "$tgTemplate", AttachmentsDirective])
AttachmentDirective = ($template, $compile) -> AttachmentDirective = ($template, $compile, $translate) ->
template = $template.get("attachment/attachment.html", true) template = $template.get("attachment/attachment.html", true)
templateEdit = $template.get("attachment/attachment-edit.html", true) templateEdit = $template.get("attachment/attachment-edit.html", true)
@ -254,14 +258,16 @@ AttachmentDirective = ($template, $compile) ->
ctx = { ctx = {
id: attachment.id id: attachment.id
name: attachment.name name: attachment.name
created_date: moment(attachment.created_date).format("ATTACHMENT.DATE") title : $translate.instant("ATTACHMENT.TITLE", {
fileName: attachment.name,
date: moment(attachment.created_date).format($translate.instant("ATTACHMENT.DATE"))})
url: attachment.url url: attachment.url
size: sizeFormat(attachment.size) size: sizeFormat(attachment.size)
description: attachment.description description: attachment.description
isDeprecated: attachment.is_deprecated isDeprecated: attachment.is_deprecated
modifyPermission: modifyPermission modifyPermission: modifyPermission
} }
console.log ctx.title
if edit if edit
html = $compile(templateEdit(ctx))($scope) html = $compile(templateEdit(ctx))($scope)
else else
@ -322,4 +328,4 @@ AttachmentDirective = ($template, $compile) ->
restrict: "AE" restrict: "AE"
} }
module.directive("tgAttachment", ["$tgTemplate", "$compile", AttachmentDirective]) module.directive("tgAttachment", ["$tgTemplate", "$compile", "$translate", AttachmentDirective])

View File

@ -173,7 +173,7 @@
}, },
"ATTACHMENT": { "ATTACHMENT": {
"SECTION_NAME": "attachments", "SECTION_NAME": "attachments",
"TITLE": "<%- name %> uploaded on <%- created_date %>", "TITLE": "{{ fileName }} uploaded on {{ date }}",
"DESCIPTION": "Type a short description", "DESCIPTION": "Type a short description",
"DEPRECATED_FILE": "Deprecated?", "DEPRECATED_FILE": "Deprecated?",
"ADD": "Add new attachment. <%- maxFileSizeMsg %>", "ADD": "Add new attachment. <%- maxFileSizeMsg %>",
@ -183,6 +183,10 @@
"COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} deprecated)", "COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} deprecated)",
"MAX_UPLOAD_SIZE": "Maximum upload size is {{maxFileSize}}", "MAX_UPLOAD_SIZE": "Maximum upload size is {{maxFileSize}}",
"DATE": "DD MMM YYYY [at] hh:mm", "DATE": "DD MMM YYYY [at] hh:mm",
"ERROR_UPLOAD_ATTACHMENT": "We have not been able to upload '{{fileName}}'. {{errorMessage}}",
"TITLE_LIGHTBOX_DELETE_ATTACHMENT": "Delete attachment...",
"MSG_LIGHTBOX_DELETE_ATTACHMENT": "the attachment '{{fileName}}'",
"ERROR_DELETE_ATTACHMENT": "We have not been able to delete: {{errorMessage}}",
"FIELDS": { "FIELDS": {
"IS_DEPRECATED": "is deprecated" "IS_DEPRECATED": "is deprecated"
} }

View File

@ -171,7 +171,7 @@
}, },
"ATTACHMENT": { "ATTACHMENT": {
"SECTION_NAME": "adjuntos", "SECTION_NAME": "adjuntos",
"TITLE": "<%- name %> Subido en <%- created_date %>", "TITLE": "{{ fileName }} subido el {{ date }}",
"DESCIPTION": "Escribe una descripción corta", "DESCIPTION": "Escribe una descripción corta",
"DEPRECATED_FILE": "¿Desactualizado?", "DEPRECATED_FILE": "¿Desactualizado?",
"ADD": "Agrega nuevos adjunto", "ADD": "Agrega nuevos adjunto",
@ -181,6 +181,10 @@
"COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} obsoleto)", "COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} obsoleto)",
"MAX_UPLOAD_SIZE": "El tamaño máximo de subida es de {{maxFileSize}}", "MAX_UPLOAD_SIZE": "El tamaño máximo de subida es de {{maxFileSize}}",
"DATE": "DD MMM YYYY [a las] hh:mm\n", "DATE": "DD MMM YYYY [a las] hh:mm\n",
"ERROR_UPLOAD_ATTACHMENT": "No hemos podido subir el fichero '{{fileName}}'. {{errorMessage}}",
"TITLE_LIGHTBOX_DELETE_ATTACHMENT": "Borrar adjunto...",
"MSG_LIGHTBOX_DELETE_ATTACHMENT": "el adjunto '{{fileName}}'",
"ERROR_DELETE_ATTACHMENT": "No hemos podido borrarlo: {{errorMessage}}",
"FIELDS": { "FIELDS": {
"IS_DEPRECATED": "Está desactualizado" "IS_DEPRECATED": "Está desactualizado"
} }

View File

@ -171,7 +171,7 @@
}, },
"ATTACHMENT": { "ATTACHMENT": {
"SECTION_NAME": "liitteet", "SECTION_NAME": "liitteet",
"TITLE": "<%- name %> ladattu <%- created_date %>", "TITLE": "{{ fileName }} ladattu {{ date }}\n",
"DESCIPTION": "Kirjoita lyhyt kuvaus", "DESCIPTION": "Kirjoita lyhyt kuvaus",
"DEPRECATED_FILE": "Vanhentunut?", "DEPRECATED_FILE": "Vanhentunut?",
"ADD": "Lisää liite. <%- maxFileSizeMsg %>", "ADD": "Lisää liite. <%- maxFileSizeMsg %>",
@ -181,6 +181,10 @@
"COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} vanhentunutta)", "COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} vanhentunutta)",
"MAX_UPLOAD_SIZE": "Maksimi tiedoston koko {{maxFileSize}}", "MAX_UPLOAD_SIZE": "Maksimi tiedoston koko {{maxFileSize}}",
"DATE": "DD MMM YYYY - hh:mm", "DATE": "DD MMM YYYY - hh:mm",
"ERROR_UPLOAD_ATTACHMENT": "We have not been able to upload '{{fileName}}'. {{errorMessage}}",
"TITLE_LIGHTBOX_DELETE_ATTACHMENT": "Delete attachment...",
"MSG_LIGHTBOX_DELETE_ATTACHMENT": "the attachment '{{fileName}}'",
"ERROR_DELETE_ATTACHMENT": "We have not been able to delete: {{errorMessage}}",
"FIELDS": { "FIELDS": {
"IS_DEPRECATED": "on vanhentunut" "IS_DEPRECATED": "on vanhentunut"
} }

View File

@ -171,7 +171,7 @@
}, },
"ATTACHMENT": { "ATTACHMENT": {
"SECTION_NAME": "pièces jointes", "SECTION_NAME": "pièces jointes",
"TITLE": "<%- name %> transmis le <%- created_date %>", "TITLE": "{{ fileName }} transmis le {{ date }}\n",
"DESCIPTION": "Entrez une courte description", "DESCIPTION": "Entrez une courte description",
"DEPRECATED_FILE": "Obsolète?", "DEPRECATED_FILE": "Obsolète?",
"ADD": "Ajouter une pièce jointe. <%- maxFileSizeMsg %>", "ADD": "Ajouter une pièce jointe. <%- maxFileSizeMsg %>",
@ -181,6 +181,10 @@
"COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} obsolète)", "COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} obsolète)",
"MAX_UPLOAD_SIZE": "La taille maximum d'upload est {{maxFileSize}}", "MAX_UPLOAD_SIZE": "La taille maximum d'upload est {{maxFileSize}}",
"DATE": "DD MMM YYYY [at] hh:mm", "DATE": "DD MMM YYYY [at] hh:mm",
"ERROR_UPLOAD_ATTACHMENT": "We have not been able to upload '{{fileName}}'. {{errorMessage}}",
"TITLE_LIGHTBOX_DELETE_ATTACHMENT": "Delete attachment...",
"MSG_LIGHTBOX_DELETE_ATTACHMENT": "the attachment '{{fileName}}'",
"ERROR_DELETE_ATTACHMENT": "We have not been able to delete: {{errorMessage}}",
"FIELDS": { "FIELDS": {
"IS_DEPRECATED": "est obsolète" "IS_DEPRECATED": "est obsolète"
} }

View File

@ -1,6 +1,6 @@
.attachment-name .attachment-name
span.icon.icon-document span.icon.icon-document
a(href!="<%- url %>", title!="{{ 'ATTACHMENT.TITLE' | translate}}", target="_blank") a(href!="<%- url %>", title!="<%- title %>", target="_blank")
| <%- name %> | <%- name %>
.attachment-size .attachment-size
span <%- size %> span <%- size %>

View File

@ -1,5 +1,5 @@
.attachment-name .attachment-name
a(href!="<%- url %>", title!="{{ 'ATTACHMENT.TITLE' | translate}}", target="_blank") a(href!="<%- url %>", title!="<%- title %>", target="_blank")
span.icon.icon-documents span.icon.icon-documents
span <%- name %> span <%- name %>
.attachment-size .attachment-size
@ -16,4 +16,4 @@
a.settings.icon.icon-edit(href="", title="{{'COMMON.EDIT' | translate}}") a.settings.icon.icon-edit(href="", title="{{'COMMON.EDIT' | translate}}")
a.settings.icon.icon-delete(href="", title="{{'COMMON.DELETE' | translate}}") a.settings.icon.icon-delete(href="", title="{{'COMMON.DELETE' | translate}}")
a.settings.icon.icon-drag-v(href="", title="{{'COMMON.DRAG' | translate}}") a.settings.icon.icon-drag-v(href="", title="{{'COMMON.DRAG' | translate}}")
<% } %> <% } %>