From 6474e7df977abf83a04dd5f8f0dca0ec21d449ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sun, 21 Jul 2013 13:01:08 +0200 Subject: [PATCH] uploads selector texts is now different when attachments are enabled --- .../discourse/components/utilities.js | 9 +++++++ .../controllers/upload_selector_controller.js | 16 ++++++++++- .../templates/composer.js.handlebars | 2 +- .../modal/upload_selector.js.handlebars | 12 ++++----- .../views/modal/upload_selector_view.js | 3 ++- config/locales/client.cs.yml | 6 ++--- config/locales/client.da.yml | 6 ++--- config/locales/client.de.yml | 6 ++--- config/locales/client.en.yml | 23 ++++++++++------ config/locales/client.es.yml | 6 ++--- config/locales/client.fr.yml | 27 ++++++++++++------- config/locales/client.id.yml | 6 ++--- config/locales/client.it.yml | 6 ++--- config/locales/client.ko.yml | 6 ++--- config/locales/client.nb_NO.yml | 6 ++--- config/locales/client.nl.yml | 6 ++--- config/locales/client.pseudo.yml | 6 ++--- config/locales/client.pt.yml | 6 ++--- config/locales/client.pt_BR.yml | 6 ++--- config/locales/client.ru.yml | 6 ++--- config/locales/client.sv.yml | 6 ++--- config/locales/client.zh_CN.yml | 10 +++---- config/locales/client.zh_TW.yml | 6 ++--- 23 files changed, 115 insertions(+), 77 deletions(-) diff --git a/app/assets/javascripts/discourse/components/utilities.js b/app/assets/javascripts/discourse/components/utilities.js index ccb3937ca8e..f4f70f5c830 100644 --- a/app/assets/javascripts/discourse/components/utilities.js +++ b/app/assets/javascripts/discourse/components/utilities.js @@ -257,6 +257,15 @@ Discourse.Utilities = { isUploadForbidden: function(path) { if (Discourse.User.current('trust_level') > 0) { return false; } return Discourse.Utilities.isAnImage(path) ? Discourse.SiteSettings.newuser_max_images === 0 : Discourse.SiteSettings.newuser_max_attachments === 0; + }, + + /** + Determines whether we allow attachments or not + + @method allowsAttachments + **/ + allowsAttachments: function() { + return _.difference(Discourse.SiteSettings.authorized_extensions.split("|"), [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tif", ".tiff"]).length > 0; } }; diff --git a/app/assets/javascripts/discourse/controllers/upload_selector_controller.js b/app/assets/javascripts/discourse/controllers/upload_selector_controller.js index 6300983dafa..b3462a9ea77 100644 --- a/app/assets/javascripts/discourse/controllers/upload_selector_controller.js +++ b/app/assets/javascripts/discourse/controllers/upload_selector_controller.js @@ -12,6 +12,20 @@ Discourse.UploadSelectorController = Discourse.Controller.extend(Discourse.Modal remoteSelected: Em.computed.not('localSelected'), selectLocal: function() { this.set('localSelected', true); }, - selectRemote: function() { this.set('localSelected', false); } + selectRemote: function() { this.set('localSelected', false); }, + + localTitle: function() { return Discourse.UploadSelectorController.translate("local_title") }.property(), + remoteTitle: function() { return Discourse.UploadSelectorController.translate("remote_title") }.property(), + localTip: function() { return Discourse.UploadSelectorController.translate("local_tip") }.property(), + remoteTip: function() { return Discourse.UploadSelectorController.translate("remote_tip") }.property(), + uploadTitle: function() { return Discourse.UploadSelectorController.translate("upload_title") }.property(), + addTitle: function() { return Discourse.UploadSelectorController.translate("add_title") }.property() }); + +Discourse.UploadSelectorController.reopenClass({ + translate: function(key) { + if (Discourse.Utilities.allowsAttachments()) key += "_with_attachments"; + return I18n.t("upload_selector." + key); + } +}); diff --git a/app/assets/javascripts/discourse/templates/composer.js.handlebars b/app/assets/javascripts/discourse/templates/composer.js.handlebars index 693c8bb21af..3213ed8c3b0 100644 --- a/app/assets/javascripts/discourse/templates/composer.js.handlebars +++ b/app/assets/javascripts/discourse/templates/composer.js.handlebars @@ -77,7 +77,7 @@
{{#if view.isUploading}}
- {{i18n upload_selector.upload_file}} {{view.uploadProgress}}% {{i18n cancel}} + {{i18n upload_selector.uploading}} {{view.uploadProgress}}% {{i18n cancel}}
{{/if}} {{/if}} diff --git a/app/assets/javascripts/discourse/templates/modal/upload_selector.js.handlebars b/app/assets/javascripts/discourse/templates/modal/upload_selector.js.handlebars index f1dfbbd0963..32abb16770d 100644 --- a/app/assets/javascripts/discourse/templates/modal/upload_selector.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/upload_selector.js.handlebars @@ -1,8 +1,8 @@ @@ -11,26 +11,26 @@ {{else}} {{/if}} diff --git a/app/assets/javascripts/discourse/views/modal/upload_selector_view.js b/app/assets/javascripts/discourse/views/modal/upload_selector_view.js index fdd3134274a..be8b17a6203 100644 --- a/app/assets/javascripts/discourse/views/modal/upload_selector_view.js +++ b/app/assets/javascripts/discourse/views/modal/upload_selector_view.js @@ -9,7 +9,8 @@ Discourse.UploadSelectorView = Discourse.ModalBodyView.extend({ templateName: 'modal/upload_selector', classNames: ['upload-selector'], - title: I18n.t('upload_selector.title'), + + title: function() { return Discourse.UploadSelectorController.translate("title"); }.property(), upload: function() { $('#reply-control').fileupload('add', { fileInput: $('#filename-input') }); diff --git a/config/locales/client.cs.yml b/config/locales/client.cs.yml index 7697aa60bbc..0a6e67c0809 100644 --- a/config/locales/client.cs.yml +++ b/config/locales/client.cs.yml @@ -510,13 +510,13 @@ cs: title: "Vložit obrázek" from_my_computer: "Z mého zařízení" from_the_web: "Z webu" - add_image: "Přidat obrázek" + add_title: "Přidat obrázek" remote_title: "obrázek ze vzdáleného úložistě" remote_tip: "zadejte adresu obrázku ve formátu http://example.com/image.jpg" local_title: "obrázek z lokálního úložiště" local_tip: "klikněte sem pro výběr obrázku z vašeho zařízení" - upload: "Nahrát" - upload_file: "Nahrávám obrázek" + upload_title: "Nahrát" + uploading: "Nahrávám obrázek" search: title: "hledání témat, příspěvků, uživatelů a kategorií" diff --git a/config/locales/client.da.yml b/config/locales/client.da.yml index 254be5415af..468d81f5ff5 100644 --- a/config/locales/client.da.yml +++ b/config/locales/client.da.yml @@ -350,11 +350,11 @@ da: title: "Indsæt billede" from_my_computer: "Fra min computer" from_the_web: "Fra nettet" - add_image: "Indsæt billede" + add_title: "Indsæt billede" remote_tip: "skriv adressen på et billede i formen http://example.com/billede.jpg" local_tip: "klik for at vælge et billede fra din computer." - upload: "Upload" - upload_file: "Uploader billede" + upload_title: "Upload" + uploading: "Uploader billede" search: title: "søg efter emner, indlæg, brugere eller kategorier" diff --git a/config/locales/client.de.yml b/config/locales/client.de.yml index 78b081bf5c7..2f30ccd8edb 100644 --- a/config/locales/client.de.yml +++ b/config/locales/client.de.yml @@ -494,13 +494,13 @@ de: title: "Bild einfügen" from_my_computer: "von meinem Gerät" from_the_web: "aus dem Web" - add_image: "Bild hinzufügen" + add_title: "Bild hinzufügen" remote_title: "Entferntes Bild" remote_tip: "Gib die Adresse eines Bildes wie folgt ein: http://example.com/image.jpg" local_title: "Lokales Bild" local_tip: "Klicke hier, um ein Bild von deinem Gerät zu wählen." - upload: "Hochladen" - upload_file: "Bild wird hochgeladen" + upload_title: "Hochladen" + uploading: "Bild wird hochgeladen" search: title: "Such nach Themen, Beiträgen, Nutzern oder Kategorien" diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 5e558f033a8..5e7c49e239d 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -484,16 +484,23 @@ en: total_flagged: "total flagged posts" upload_selector: - title: "Upload file" + title: "Upload an image" + title_with_attachments: "Upload an image or a file" from_my_computer: "From My Device" from_the_web: "From The Web" - add_image: "Add File" - remote_title: "remote file" - remote_tip: "enter address of a file in the form http://example.com/image.jpg" - local_title: "local file" - local_tip: "click to select a file from your device." - upload: "Upload" - upload_file: "Uploading" + add_title: "Add image" + add_title_with_attachments: "Add image or file" + remote_title: "remote image" + remote_title_with_attachments: "remote image or file" + remote_tip: "enter address of an image in the form http://example.com/image.jpg" + remote_tip_with_attachments: "enter address of an image or a file in the form http://example.com/file.ext" + local_title: "local image" + local_title_with_attachments: "local image or file" + local_tip: "click to select an image from your device." + local_tip_with_attachments: "click to select an image or a file from your device." + upload_title: "Upload image" + upload_title_with_attachments: "Upload image or file" + uploading: "Uploading" search: title: "search for topics, posts, users, or categories" diff --git a/config/locales/client.es.yml b/config/locales/client.es.yml index 645cc66fae9..4f2de1b859d 100644 --- a/config/locales/client.es.yml +++ b/config/locales/client.es.yml @@ -426,11 +426,11 @@ es: title: "Insertar Imagen" from_my_computer: "Desde Mí Dispositivo" from_the_web: "Desde La Web" - add_image: "Agregar Imagen" + add_title: "Agregar Imagen" remote_tip: "ingrese una dirección de una imagen en la siguiente forma http://ejemplo.com/imagen.jpg" local_tip: "click para seleccionar la imagen desde su dispositivo." - upload: "Subir" - upload_file: "Subiendo imagen" + upload_title: "Subir" + uploading: "Subiendo imagen" search: title: "buscar por temas, publicaciones, usuarios o categorías" diff --git a/config/locales/client.fr.yml b/config/locales/client.fr.yml index 5403068f96a..961ab8c857a 100644 --- a/config/locales/client.fr.yml +++ b/config/locales/client.fr.yml @@ -487,16 +487,23 @@ fr: total_flagged: "Nombre total de messages signalés" upload_selector: - title: "Insérer un fichier" - from_my_computer: "Local" - from_the_web: "Depuis internet" - add_image: "Ajouter un fichier" - remote_title: "Fichier distant" - remote_tip: "saisissez l'url du fichier" - local_title: "Fichier local" - local_tip: "Cliquez pour sélectionner un fichier depuis votre ordinateur." - upload: "Envoyer" - upload_file: "Fichier en cours d'envoi" + title: "Insérer une image" + title_with_attachments: "Insérer une image ou un fichier" + from_my_computer: "Depuis mon ordinateur" + from_the_web: "Depuis le Web" + add_title: "Ajouter l'image" + add_title_with_attachments: "Ajouter le fichier" + remote_title: "Image distante" + remote_title_with_attachments: "Fichier distant" + remote_tip: "saisissez l'url de l'image (par exemple : http://monsite.com/image.jpg)" + remote_tip_with_attachments: "saisissez l'url du fichier (par exemple : http://monsite.com/fichier.txt)" + local_title: "Image locale" + local_title_with_attachments: "Fichier local" + local_tip: "Cliquez pour sélectionner une image depuis votre ordinateur." + local_tip_with_attachments: "Cliquez pour sélectionner un fichier depuis votre ordinateur." + upload_title: "Envoyer l'image" + upload_title_with_attachments: "Envoyer le fichier" + uploading: "Fichier en cours d'envoi..." search: title: "Rechercher les discussions, messages, utilisateurs ou catégories" diff --git a/config/locales/client.id.yml b/config/locales/client.id.yml index 28b4f3755c5..f88b892e739 100644 --- a/config/locales/client.id.yml +++ b/config/locales/client.id.yml @@ -314,11 +314,11 @@ id: title: "Insert Image" from_my_computer: "From My Device" from_the_web: "From The Web" - add_image: "Add Image" + add_title: "Add Image" remote_tip: "enter address of an image in the form http://example.com/image.jpg" local_tip: "click to select an image from your device." - upload: "Upload" - upload_file: "Uploading image" + upload_title: "Upload" + uploading: "Uploading image" search: title: "search for topics, posts, users, or categories" diff --git a/config/locales/client.it.yml b/config/locales/client.it.yml index 8089a8b4abe..c3d04e360ce 100644 --- a/config/locales/client.it.yml +++ b/config/locales/client.it.yml @@ -419,13 +419,13 @@ it: title: "Inserisci Immagine" from_my_computer: "Dal mio dispositivo" from_the_web: "Dal Web" - add_image: "Aggiungi Immagine" + add_title: "Aggiungi Immagine" remote_title: "immagine remota" remote_tip: "inserisci l'indirizzo dell'immagine (es. http://example.com/image.jpg)" local_title: "immagine locale" local_tip: "clicca per selezionare un'immagine dal tuo dispositivo." - upload: "Upload" - upload_file: "Carico l'immagine" + upload_title: "Upload" + uploading: "Carico l'immagine" search: title: "cerca topic, post, utenti o categorie" diff --git a/config/locales/client.ko.yml b/config/locales/client.ko.yml index 2731d10eed3..ffaeda68b7c 100644 --- a/config/locales/client.ko.yml +++ b/config/locales/client.ko.yml @@ -384,13 +384,13 @@ ko: title: "이미지 삽입" from_my_computer: "나의 장치로 부터" from_the_web: "웹으로부터" - add_image: "이미지 추가" + add_title: "이미지 추가" remote_title: "원격 이미지" remote_tip: "양식에서 http://example.com/image.jpg 의 이미지 주소 입력" local_title: "기본 이미지" local_tip: "당신의 장치로부터 이미지를 선택하여 클릭해주세요" - upload: "업로드" - uploading_image: "이미지 업로드중 ..." + upload_title: "업로드" + uploading: "이미지 업로드중 ..." search: title: "주제, 게시물, 사용자, 카테고리를 검색합니다" diff --git a/config/locales/client.nb_NO.yml b/config/locales/client.nb_NO.yml index 77e398cec45..e3bcb42b4e5 100644 --- a/config/locales/client.nb_NO.yml +++ b/config/locales/client.nb_NO.yml @@ -430,13 +430,13 @@ nb_NO: title: "Legg til Bilde" from_my_computer: "Fra Min Enhet" from_the_web: "Fra Nettet" - add_image: "Legg til Bilde" + add_title: "Legg til Bilde" remote_title: "eksternt bilde" remote_tip: "skriv inn addressen til et bilde, f.eks. http://example.com/image.jpg" local_title: "lokalt bilde" local_tip: "klikk for å velge et bilde fra din enhet." - upload: "Last opp" - upload_file: "Laster opp bilde" + upload_title: "Last opp" + uploading: "Laster opp bilde" search: title: "søk etter emner, innlegg, brukere eller kategorier" diff --git a/config/locales/client.nl.yml b/config/locales/client.nl.yml index fc0cfcdb7be..b668375c471 100644 --- a/config/locales/client.nl.yml +++ b/config/locales/client.nl.yml @@ -490,13 +490,13 @@ nl: title: Voeg afbeelding toe from_my_computer: Vanaf mijn apparaat from_the_web: Vanaf het web - add_image: Voeg afbeelding toe + add_title: Voeg afbeelding toe remote_title: externe afbeelding remote_tip: "vul een internetadres in van een afbeelding in deze vorm: http://example.com/image.jpg" local_title: lokale afbeelding local_tip: "klik om een afbeelding vanaf je apparaat te selecteren." - upload: Uploaden - upload_file: Afbeelding uploaden + upload_title: Uploaden + uploading: Afbeelding uploaden search: title: "zoek naar topics, posts, leden of categoriëen" diff --git a/config/locales/client.pseudo.yml b/config/locales/client.pseudo.yml index 1566e18e3e0..3e876b435a5 100644 --- a/config/locales/client.pseudo.yml +++ b/config/locales/client.pseudo.yml @@ -474,14 +474,14 @@ pseudo: title: '[[ Íɳšéřť Íɱáǧé ]]' from_my_computer: '[[ Ƒřóɱ Ϻý Ďéνíčé ]]' from_the_web: '[[ Ƒřóɱ Ťĥé Ŵéƀ ]]' - add_image: '[[ Áďď Íɱáǧé ]]' + add_title: '[[ Áďď Íɱáǧé ]]' remote_title: '[[ řéɱóťé íɱáǧé ]]' remote_tip: '[[ éɳťéř áďďřéšš óƒ áɳ íɱáǧé íɳ ťĥé ƒóřɱ ĥťťƿ://éхáɱƿłé.čóɱ/íɱáǧé.ʲƿǧ ]]' local_title: '[[ łóčáł íɱáǧé ]]' local_tip: '[[ čłíčǩ ťó šéłéčť áɳ íɱáǧé ƒřóɱ ýóůř ďéνíčé. ]]' - upload: '[[ Ůƿłóáď ]]' - upload_file: '[[ Ůƿłóáďíɳǧ íɱáǧé ]]' + upload_title: '[[ Ůƿłóáď ]]' + uploading: '[[ Ůƿłóáďíɳǧ íɱáǧé ]]' search: title: '[[ šéářčĥ ƒóř ťóƿíčš, ƿóšťš, ůšéřš, óř čáťéǧóříéš ]]' placeholder: '[[ ťýƿé ýóůř šéářčĥ ťéřɱš ĥéřé ]]' diff --git a/config/locales/client.pt.yml b/config/locales/client.pt.yml index 18adc1962fa..e160d9c3f5d 100644 --- a/config/locales/client.pt.yml +++ b/config/locales/client.pt.yml @@ -304,11 +304,11 @@ pt: upload_selector: from_my_computer: "Do meu dispositivo" from_the_web: "Da internet" - add_image: "Adicionar Imagem" + add_title: "Adicionar Imagem" remote_tip: "insere o endereço de uma imagem no formato http://example.com/image.jpg" local_tip: "clica para selecionar uma imagem no teu dispositivo." - upload: "Enviar" - upload_file: "A enviar imagem" + upload_title: "Enviar" + uploading: "A enviar imagem" search: title: "procurar por tópicos, posts, utilizadores, ou categorias" diff --git a/config/locales/client.pt_BR.yml b/config/locales/client.pt_BR.yml index 4a9ea165584..24dd28885dc 100644 --- a/config/locales/client.pt_BR.yml +++ b/config/locales/client.pt_BR.yml @@ -432,13 +432,13 @@ pt_BR: title: "Enviar arquivo" from_my_computer: "Do Meu Dispositivo" from_the_web: "Da Internet" - add_image: "Adicionar Arquivo" + add_title: "Adicionar Arquivo" remote_title: "arquivo remoto" remote_tip: "digite o endereço de um arquivo na forma http://exemplo.com/imagem.jpg" local_title: "arquivo local" local_tip: "clique para selecionar um arquivo do seu dispositivo" - upload: "Enviar" - upload_file: "Enviando" + upload_title: "Enviar" + uploading: "Enviando" search: title: "procurar por tópicos, posts, usuários, ou categorias" placeholder: "escreve aqui o seu termo de buscar" diff --git a/config/locales/client.ru.yml b/config/locales/client.ru.yml index 83265850ea1..cab26f521ae 100644 --- a/config/locales/client.ru.yml +++ b/config/locales/client.ru.yml @@ -490,13 +490,13 @@ ru: title: Загрузить файл from_my_computer: С устройства from_the_web: Из интернета - add_image: Добавить файл + add_title: Добавить файл remote_title: удаленный файл remote_tip: введите адрес файла в формате http://example.com/image.jpg local_title: локальный файл local_tip: кликните для выбора файла на вашем устройстве. - upload: Загрузить - upload_file: Загрузка + upload_title: Загрузить + uploading: Загрузка search: title: поиск по темам, сообщениям, пользователям или категориям placeholder: условия поиска... diff --git a/config/locales/client.sv.yml b/config/locales/client.sv.yml index e346404db52..2effc5016ba 100644 --- a/config/locales/client.sv.yml +++ b/config/locales/client.sv.yml @@ -356,11 +356,11 @@ sv: title: "Infoga Bild" from_my_computer: "Från Min Enhet" from_the_web: "Från Internet" - add_image: "Lägg Till Bild" + add_title: "Lägg Till Bild" remote_tip: "skriv in en adress till en bild i formen http://exempel.se/bild.jpg" local_tip: "klicka för att välja en bild från din enhet." - upload: "Ladda Upp" - upload_file: "Laddar upp bild" + upload_title: "Ladda Upp" + uploading: "Laddar upp bild" search: title: "sök efter trådar, inlägg, användare, eller kategorier" diff --git a/config/locales/client.zh_CN.yml b/config/locales/client.zh_CN.yml index 70e2271e7ee..3afbb300e5d 100644 --- a/config/locales/client.zh_CN.yml +++ b/config/locales/client.zh_CN.yml @@ -496,13 +496,13 @@ zh_CN: title: "插入图片" from_my_computer: "来自我的设备" from_the_web: "来自网络" - add_image: "添加图片" + add_title: "添加图片" remote_title: "网络图片" remote_tip: "输入图片网络,格式为:http://example.com/image.jpg" local_title: "本地图片" local_tip: "点击从你的设备中选择一张图片。" - upload: "上传" - upload_file: "上传图片中" + upload_title: "上传" + uploading: "上传图片中" search: title: "搜索主题、帖子、用户或分类" @@ -568,10 +568,10 @@ zh_CN: not_found: title: "未找到主题" description: "抱歉,无法找到此主题。有可能它被论坛版主删掉了?" - unread_posts: + unread_posts: one: "此主题中你有一个帖子未阅" other: "此主题中你有 {{unread}} 个帖子未阅" - new_posts: + new_posts: other: "从你最近一次阅读此主题后,又有一个新帖子发表" other: "从你最近一次阅读此主题后,又有 {{new_posts}} 个新帖子发表" diff --git a/config/locales/client.zh_TW.yml b/config/locales/client.zh_TW.yml index 88e42e81a88..a601869a4f9 100644 --- a/config/locales/client.zh_TW.yml +++ b/config/locales/client.zh_TW.yml @@ -419,13 +419,13 @@ zh_TW: title: "插入圖片" from_my_computer: "來自我的設備" from_the_web: "來自網絡" - add_image: "添加圖片" + add_title: "添加圖片" remote_title: "網絡圖片" remote_tip: "輸入圖片網絡,格式爲:http://example.com/image.jpg" local_title: "本地圖片" local_tip: "點擊從你的設備中選擇一張圖片。" - upload: "上傳" - upload_file: "上傳圖片中" + upload_title: "上傳" + uploading: "上傳圖片中" search: title: "搜索主題、帖子、用戶或分類"