From fdc6b83f649c056a846315f4238d1c57179231e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Wed, 29 Apr 2015 21:26:18 +0200 Subject: [PATCH] [i18n] Attachments --- app/coffee/modules/common/attachments.coffee | 28 ++++++++++++-------- app/locales/locale-en.json | 6 ++++- app/locales/locale-es.json | 6 ++++- app/locales/locale-fi.json | 6 ++++- app/locales/locale-fr.json | 6 ++++- app/partials/attachment/attachment-edit.jade | 2 +- app/partials/attachment/attachment.jade | 4 +-- 7 files changed, 40 insertions(+), 18 deletions(-) diff --git a/app/coffee/modules/common/attachments.coffee b/app/coffee/modules/common/attachments.coffee index cd575c55..06cc2920 100644 --- a/app/coffee/modules/common/attachments.coffee +++ b/app/coffee/modules/common/attachments.coffee @@ -28,9 +28,9 @@ module = angular.module("taigaCommon") 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(@) @.type = null @.objectId = null @@ -75,10 +75,13 @@ class AttachmentsController extends taiga.Controller promise = promise.then null, (data) => @scope.$emit("attachments:size-error") if data.status == 413 + index = @.uploadingAttachments.indexOf(attachment) @.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 promise @@ -130,8 +133,8 @@ class AttachmentsController extends taiga.Controller # Remove one concrete attachment. removeAttachment: (attachment) -> - title = "Delete attachment" #TODO: i18in - message = "the attachment '#{attachment.name}'" #TODO: i18in + title = @translate.instant("ATTACHMENT.TITLE_LIGHTBOX_DELETE_ATTACHMENT") + message = @translate.instant("ATTACHMENT.MSG_LIGHTBOX_DELETE_ATTACHMENT", {fileName: attachment.name}) return @confirm.askOnDelete(title, message).then (finish) => onSuccess = => @@ -143,7 +146,8 @@ class AttachmentsController extends taiga.Controller onError = => 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 @repo.remove(attachment).then(onSuccess, onError) @@ -242,7 +246,7 @@ AttachmentsDirective = ($config, $confirm, $templates) -> module.directive("tgAttachments", ["$tgConfig", "$tgConfirm", "$tgTemplate", AttachmentsDirective]) -AttachmentDirective = ($template, $compile) -> +AttachmentDirective = ($template, $compile, $translate) -> template = $template.get("attachment/attachment.html", true) templateEdit = $template.get("attachment/attachment-edit.html", true) @@ -254,14 +258,16 @@ AttachmentDirective = ($template, $compile) -> ctx = { id: attachment.id 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 size: sizeFormat(attachment.size) description: attachment.description isDeprecated: attachment.is_deprecated modifyPermission: modifyPermission } - + console.log ctx.title if edit html = $compile(templateEdit(ctx))($scope) else @@ -322,4 +328,4 @@ AttachmentDirective = ($template, $compile) -> restrict: "AE" } -module.directive("tgAttachment", ["$tgTemplate", "$compile", AttachmentDirective]) +module.directive("tgAttachment", ["$tgTemplate", "$compile", "$translate", AttachmentDirective]) diff --git a/app/locales/locale-en.json b/app/locales/locale-en.json index 905183df..a9e6b873 100644 --- a/app/locales/locale-en.json +++ b/app/locales/locale-en.json @@ -173,7 +173,7 @@ }, "ATTACHMENT": { "SECTION_NAME": "attachments", - "TITLE": "<%- name %> uploaded on <%- created_date %>", + "TITLE": "{{ fileName }} uploaded on {{ date }}", "DESCIPTION": "Type a short description", "DEPRECATED_FILE": "Deprecated?", "ADD": "Add new attachment. <%- maxFileSizeMsg %>", @@ -183,6 +183,10 @@ "COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} deprecated)", "MAX_UPLOAD_SIZE": "Maximum upload size is {{maxFileSize}}", "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": { "IS_DEPRECATED": "is deprecated" } diff --git a/app/locales/locale-es.json b/app/locales/locale-es.json index 6c6a7381..f46a5bc3 100644 --- a/app/locales/locale-es.json +++ b/app/locales/locale-es.json @@ -171,7 +171,7 @@ }, "ATTACHMENT": { "SECTION_NAME": "adjuntos", - "TITLE": "<%- name %> Subido en <%- created_date %>", + "TITLE": "{{ fileName }} subido el {{ date }}", "DESCIPTION": "Escribe una descripción corta", "DEPRECATED_FILE": "¿Desactualizado?", "ADD": "Agrega nuevos adjunto", @@ -181,6 +181,10 @@ "COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} obsoleto)", "MAX_UPLOAD_SIZE": "El tamaño máximo de subida es de {{maxFileSize}}", "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": { "IS_DEPRECATED": "Está desactualizado" } diff --git a/app/locales/locale-fi.json b/app/locales/locale-fi.json index dfb3aeca..3691f941 100644 --- a/app/locales/locale-fi.json +++ b/app/locales/locale-fi.json @@ -171,7 +171,7 @@ }, "ATTACHMENT": { "SECTION_NAME": "liitteet", - "TITLE": "<%- name %> ladattu <%- created_date %>", + "TITLE": "{{ fileName }} ladattu {{ date }}\n", "DESCIPTION": "Kirjoita lyhyt kuvaus", "DEPRECATED_FILE": "Vanhentunut?", "ADD": "Lisää liite. <%- maxFileSizeMsg %>", @@ -181,6 +181,10 @@ "COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} vanhentunutta)", "MAX_UPLOAD_SIZE": "Maksimi tiedoston koko {{maxFileSize}}", "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": { "IS_DEPRECATED": "on vanhentunut" } diff --git a/app/locales/locale-fr.json b/app/locales/locale-fr.json index 9a4b9867..5554b4ca 100644 --- a/app/locales/locale-fr.json +++ b/app/locales/locale-fr.json @@ -171,7 +171,7 @@ }, "ATTACHMENT": { "SECTION_NAME": "pièces jointes", - "TITLE": "<%- name %> transmis le <%- created_date %>", + "TITLE": "{{ fileName }} transmis le {{ date }}\n", "DESCIPTION": "Entrez une courte description", "DEPRECATED_FILE": "Obsolète?", "ADD": "Ajouter une pièce jointe. <%- maxFileSizeMsg %>", @@ -181,6 +181,10 @@ "COUNT_DEPRECATED": "({{ctrl.deprecatedAttachmentsCount }} obsolète)", "MAX_UPLOAD_SIZE": "La taille maximum d'upload est {{maxFileSize}}", "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": { "IS_DEPRECATED": "est obsolète" } diff --git a/app/partials/attachment/attachment-edit.jade b/app/partials/attachment/attachment-edit.jade index 6d810b52..ceb287ad 100644 --- a/app/partials/attachment/attachment-edit.jade +++ b/app/partials/attachment/attachment-edit.jade @@ -1,6 +1,6 @@ .attachment-name span.icon.icon-document - a(href!="<%- url %>", title!="{{ 'ATTACHMENT.TITLE' | translate}}", target="_blank") + a(href!="<%- url %>", title!="<%- title %>", target="_blank") | <%- name %> .attachment-size span <%- size %> diff --git a/app/partials/attachment/attachment.jade b/app/partials/attachment/attachment.jade index 9c783580..b4476f51 100644 --- a/app/partials/attachment/attachment.jade +++ b/app/partials/attachment/attachment.jade @@ -1,5 +1,5 @@ .attachment-name - a(href!="<%- url %>", title!="{{ 'ATTACHMENT.TITLE' | translate}}", target="_blank") + a(href!="<%- url %>", title!="<%- title %>", target="_blank") span.icon.icon-documents span <%- name %> .attachment-size @@ -16,4 +16,4 @@ a.settings.icon.icon-edit(href="", title="{{'COMMON.EDIT' | translate}}") a.settings.icon.icon-delete(href="", title="{{'COMMON.DELETE' | translate}}") a.settings.icon.icon-drag-v(href="", title="{{'COMMON.DRAG' | translate}}") -<% } %> \ No newline at end of file +<% } %>