-
+
diff --git a/customize.dist/languageSelector.js b/customize.dist/languageSelector.js
deleted file mode 100644
index eac1b2bcc..000000000
--- a/customize.dist/languageSelector.js
+++ /dev/null
@@ -1,50 +0,0 @@
-define(['/bower_components/jquery/dist/jquery.min.js'], function() {
- var $ = window.jQuery;
- var out = {};
-
- var LS_LANG = "CRYPTPAD_LANG";
-
- var getStoredLanguage = function () {
- return localStorage.getItem(LS_LANG);
- };
-
- var storeLanguage = function (l) {
- localStorage.setItem(LS_LANG, l);
- };
-
- var getBrowserLanguage = function () {
- return navigator.language || navigator.userLanguage;
- };
-
- var getLanguage = out.getLanguage = function () {
- return getStoredLanguage() || getBrowserLanguage();
- };
-
- var main = out.main = function ($select) {
- var selector = $select || $('#language-selector');
-
- if (!selector.length) { return; }
-
- var $button = $(selector).find('button .buttonTitle');
- // Select the current language in the list
- var language = getLanguage();
- var option = $(selector).find('[data-value="' + language + '"]');
- if ($(option).length) {
- $button.text($(option).text());
- }
- else {
- $button.text('English');
- }
-
- // Listen for language change
- $(selector).find('a.languageValue').on('click', function () {
- var newLanguage = $(this).attr('data-value');
- storeLanguage(newLanguage);
- if (newLanguage !== language) {
- window.location.reload();
- }
- });
- };
-
- return out;
-});
diff --git a/customize.dist/main.js b/customize.dist/main.js
index 58bbe4838..af302e964 100644
--- a/customize.dist/main.js
+++ b/customize.dist/main.js
@@ -3,9 +3,8 @@ define([
'/customize/application_config.js',
'/common/cryptpad-common.js',
'/bower_components/lil-uri/uri.min.js',
- '/customize/languageSelector.js',
'/bower_components/jquery/dist/jquery.min.js',
-], function (Messages, Config, Cryptpad, LilUri, LS) {
+], function (Messages, Config, Cryptpad, LilUri) {
var $ = window.$;
var APP = window.APP = {
diff --git a/customize.dist/messages.js b/customize.dist/messages.js
index 9cda3aba2..dd78c6ebb 100644
--- a/customize.dist/messages.js
+++ b/customize.dist/messages.js
@@ -1,70 +1,76 @@
-define(['/customize/languageSelector.js',
- '/customize/translations/messages.js',
- '/customize/translations/messages.es.js',
- '/customize/translations/messages.fr.js',
-
- // 1) additional translation files can be added here...
- '/customize/translations/messages.pl.js',
- '/customize/translations/messages.de.js',
- '/customize/translations/messages.pt-br.js',
-
-
- '/bower_components/jquery/dist/jquery.min.js'],
-
- // 2) name your language module here...
- function(LS, Default, Spanish, French, Polish, German, BrPortuguese) {
+(function () {
+var LS_LANG = "CRYPTPAD_LANG";
+
+var getStoredLanguage = function () { return localStorage.getItem(LS_LANG); };
+var getBrowserLanguage = function () { return navigator.language || navigator.userLanguage; };
+var getLanguage = function () { return getStoredLanguage() || getBrowserLanguage(); };
+var language = getLanguage();
+
+// add your module to this map so it gets used
+var map = {
+ 'fr': 'Français',
+ 'es': 'Español',
+ 'pl': 'Polski',
+ 'de': 'Deutsch',
+ 'pt-br': 'Português do Brasil'
+};
+
+var req = ['/customize/translations/messages.js'];
+if (language && map[language]) { req.push('/customize/translations/messages.' + language + '.js'); }
+req.push('/bower_components/jquery/dist/jquery.min.js');
+
+define(req, function(Default, Language) {
var $ = window.jQuery;
- // 3) add your module to this map so it gets used
- var map = {
- 'fr': French,
- 'es': Spanish,
- 'pl': Polish,
- 'de': German,
- 'pt-br': BrPortuguese,
- };
+ var externalMap = JSON.parse(JSON.stringify(map));
+ map.en = 'English';
var defaultLanguage = 'en';
- var language = LS.getLanguage();
-
var messages;
- if (!language || language === defaultLanguage || language === 'default' || !map[language]) {
+ if (!Language || !language || language === defaultLanguage || language === 'default' || !map[language]) {
messages = Default;
}
else {
// Add the translated keys to the returned object
- messages = $.extend(true, {}, Default, map[language]);
+ messages = $.extend(true, {}, Default, Language);
}
- // messages_languages return the available translations and their name in an object :
- // { "en": "English", "fr": "French", ... }
- messages._languages = {
- 'en': Default._languageName
- };
- for (var l in map) {
- messages._languages[l] = map[l]._languageName || l;
- }
+ messages._languages = map;
- messages._initSelector = LS.main;
- messages._checkTranslationState = function () {
+ messages._checkTranslationState = function (cb) {
+ if (typeof(cb) !== "function") { return; }
var missing = [];
- Object.keys(map).forEach(function (code) {
- var translation = map[code];
- Object.keys(Default).forEach(function (k) {
- if (/^_/.test(k) || /nitialState$/.test(k)) { return; }
- if (!translation[k]) {
- var warning = "key [" + k + "] is missing from translation [" + code + "]";
+ var reqs = [];
+ Object.keys(externalMap).forEach(function (code) {
+ reqs.push('/customize/translations/messages.' + code + '.js');
+ });
+ require(reqs, function () {
+ var langs = arguments;
+ Object.keys(externalMap).forEach(function (code, i) {
+ var translation = langs[i];
+ Object.keys(Default).forEach(function (k) {
+ if (/^_/.test(k) || /nitialState$/.test(k)) { return; }
+ if (!translation[k]) {
+ var warning = "key [" + k + "] is missing from translation [" + code + "]";
+ missing.push(warning);
+ }
+ });
+ Object.keys(translation).forEach(function (k) {
+ if (/^_/.test(k) || /nitialState$/.test(k)) { return; }
+ if (!Default[k]) {
+ var warning = "key [" + k + "] from [" + code + "] is not needed anymore and should be removed";
+ missing.push(warning);
+ }
+ });
+ /*if (typeof(translation._languageName) !== 'string') {
+ var warning = 'key [_languageName] is missing from translation [' + code + ']';
missing.push(warning);
- }
+ }*/
});
- if (typeof(translation._languageName) !== 'string') {
- var warning = 'key [_languageName] is missing from translation [' + code + ']';
- missing.push(warning);
- }
+ cb(missing);
});
- return missing;
};
// Get keys with parameters
@@ -76,6 +82,35 @@ define(['/customize/languageSelector.js',
});
};
+ // Add handler to the language selector
+ var storeLanguage = function (l) {
+ localStorage.setItem(LS_LANG, l);
+ };
+ messages._initSelector = function ($select) {
+ var selector = $select || $('#language-selector');
+
+ if (!selector.length) { return; }
+
+ var $button = $(selector).find('button .buttonTitle');
+ // Select the current language in the list
+ var option = $(selector).find('[data-value="' + language + '"]');
+ if ($(option).length) {
+ $button.text($(option).text());
+ }
+ else {
+ $button.text('English');
+ }
+
+ // Listen for language change
+ $(selector).find('a.languageValue').on('click', function () {
+ var newLanguage = $(this).attr('data-value');
+ storeLanguage(newLanguage);
+ if (newLanguage !== language) {
+ window.location.reload();
+ }
+ });
+ };
+
var translateText = function (i, e) {
var $el = $(e);
var key = $el.data('localization');
@@ -126,4 +161,6 @@ define(['/customize/languageSelector.js',
'{"metadata":{"defaultTitle":"' + messages.driveReadmeTitle + '","title":"' + messages.driveReadmeTitle + '"}}]';
return messages;
+
});
+}());
diff --git a/customize.dist/src/fragments/index.html b/customize.dist/src/fragments/index.html
index 90f6f9d0e..67452a2fa 100644
--- a/customize.dist/src/fragments/index.html
+++ b/customize.dist/src/fragments/index.html
@@ -5,7 +5,7 @@
-
+
diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js
index 492a611d8..4dbf5a2c9 100644
--- a/customize.dist/translations/messages.fr.js
+++ b/customize.dist/translations/messages.fr.js
@@ -1,10 +1,6 @@
define(function () {
var out = {};
- // translations must set this key for their language to be available in
- // the language dropdowns that are shown throughout Cryptpad's interface
- out._languageName = "Français";
-
out.main_title = "Cryptpad: Éditeur collaboratif en temps réel, zero knowledge";
out.main_slogan = "L'unité est la force, la collaboration est la clé";
@@ -102,9 +98,6 @@ define(function () {
out.cancel = "Annuler";
out.cancelButton = 'Annuler (Echap)';
- out.loginText = '
Développez vos idées en groupe avec des documents partagés; la technologie Zero Knowledge sécurise vos données."; + out.main_info = "
Développez vos idées en groupe avec des documents partagés; la technologie Zero Knowledge sécurise vos données."; out.main_howitworks = 'Comment ça fonctionne'; out.main_zeroKnowledge = 'Zero Knowledge'; @@ -287,8 +277,6 @@ define(function () { out.footer_contact = "Contact"; out.footer_aboutUs = "À propos de nous"; - out.form_title = "Tous vos pads, partout où vous allez !"; - out.about = "À propos"; out.privacy = "Vie privée"; out.contact = "Contact"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index d9875ef73..9ba0402ac 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -1,11 +1,6 @@ define(function () { var out = {}; - // translations must set this key for their language to be available in - // the language dropdowns that are shown throughout Cryptpad's interface - // NOTE: translate that name in your language ("Français" and not "French") - out._languageName = 'English'; - out.main_title = "Cryptpad: Zero Knowledge, Collaborative Real Time Editing"; out.main_slogan = "Unity is Strength - Collaboration is Key"; // TODO remove? @@ -259,7 +254,7 @@ define(function () { // index.html - out.main_p1 = "
Grow your ideas together with shared documents while Zero Knowledge technology secures your privacy; even from us."; + out.main_info = "
Grow your ideas together with shared documents while Zero Knowledge technology secures your privacy; even from us."; out.main_howitworks = 'How It Works'; out.main_zeroKnowledge = 'Zero Knowledge'; diff --git a/www/assert/main.js b/www/assert/main.js index 07966a874..51bdf00a8 100644 --- a/www/assert/main.js +++ b/www/assert/main.js @@ -142,16 +142,18 @@ define([ }); assert(function () { - var missing = Cryptpad.Messages._checkTranslationState(); + var todo = function (missing) { + if (missing.length !== 0) { + missing.forEach(function (msg) { + console.log('* ' + msg); + }); - if (missing.length !== 0) { - missing.forEach(function (msg) { - console.log('* ' + msg); - }); + // No, this is crappy, it's going to cause tests to fail basically all of the time. + //return false; + } + }; + Cryptpad.Messages._checkTranslationState(todo); - // No, this is crappy, it's going to cause tests to fail basically all of the time. - //return false; - } return true; }, "expected all translation keys in default language to be present in all translations. See console for details."); diff --git a/www/assert/translations/main.js b/www/assert/translations/main.js index 6ff862213..0324e55f2 100644 --- a/www/assert/translations/main.js +++ b/www/assert/translations/main.js @@ -5,17 +5,19 @@ define([ var $ = window.jQuery; var $body = $('body'); - var missing = Cryptpad.Messages._checkTranslationState(); var pre = function (text, opt) { return $('
Votre nom d\'utilisateur et votre mot de passe sont utilisés pour générer une clé unique qui reste inconnue de notre serveur.
\n' + - 'Faites attention de ne pas oublier vos identifiants puisqu\'ils seront impossible à récupérer.
'; //TODO - // Polls out.poll_title = "Sélecteur de date Zero Knowledge"; @@ -206,9 +199,6 @@ define(function () { out.logoutButton = "Déconnexion"; out.settingsButton = "Préférences"; - out.username_label = "Nom d'utilisateur : "; - out.displayname_label = "Nom affiché : "; - out.login_username = "Nom d'utilisateur"; out.login_password = "Mot de passe"; out.login_confirm = "Confirmer votre mot de passe"; @@ -261,7 +251,7 @@ define(function () { // index.html - out.main_p1 = "Collaborez avec confiance
Développez vos idées en groupe avec des documents partagés; la technologie Zero Knowledge sécurise vos données."; + out.main_info = "
Collaborez avec confiance
Développez vos idées en groupe avec des documents partagés; la technologie Zero Knowledge sécurise vos données."; out.main_howitworks = 'Comment ça fonctionne'; out.main_zeroKnowledge = 'Zero Knowledge'; @@ -287,8 +277,6 @@ define(function () { out.footer_contact = "Contact"; out.footer_aboutUs = "À propos de nous"; - out.form_title = "Tous vos pads, partout où vous allez !"; - out.about = "À propos"; out.privacy = "Vie privée"; out.contact = "Contact"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index d9875ef73..9ba0402ac 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -1,11 +1,6 @@ define(function () { var out = {}; - // translations must set this key for their language to be available in - // the language dropdowns that are shown throughout Cryptpad's interface - // NOTE: translate that name in your language ("Français" and not "French") - out._languageName = 'English'; - out.main_title = "Cryptpad: Zero Knowledge, Collaborative Real Time Editing"; out.main_slogan = "Unity is Strength - Collaboration is Key"; // TODO remove? @@ -259,7 +254,7 @@ define(function () { // index.html - out.main_p1 = "
Collaborate in Confidence
Grow your ideas together with shared documents while Zero Knowledge technology secures your privacy; even from us."; + out.main_info = "
Collaborate in Confidence
Grow your ideas together with shared documents while Zero Knowledge technology secures your privacy; even from us."; out.main_howitworks = 'How It Works'; out.main_zeroKnowledge = 'Zero Knowledge'; diff --git a/www/assert/main.js b/www/assert/main.js index 07966a874..51bdf00a8 100644 --- a/www/assert/main.js +++ b/www/assert/main.js @@ -142,16 +142,18 @@ define([ }); assert(function () { - var missing = Cryptpad.Messages._checkTranslationState(); + var todo = function (missing) { + if (missing.length !== 0) { + missing.forEach(function (msg) { + console.log('* ' + msg); + }); - if (missing.length !== 0) { - missing.forEach(function (msg) { - console.log('* ' + msg); - }); + // No, this is crappy, it's going to cause tests to fail basically all of the time. + //return false; + } + }; + Cryptpad.Messages._checkTranslationState(todo); - // No, this is crappy, it's going to cause tests to fail basically all of the time. - //return false; - } return true; }, "expected all translation keys in default language to be present in all translations. See console for details."); diff --git a/www/assert/translations/main.js b/www/assert/translations/main.js index 6ff862213..0324e55f2 100644 --- a/www/assert/translations/main.js +++ b/www/assert/translations/main.js @@ -5,17 +5,19 @@ define([ var $ = window.jQuery; var $body = $('body'); - var missing = Cryptpad.Messages._checkTranslationState(); var pre = function (text, opt) { return $('
', opt).text(text); }; - if (missing.length) { - $body.append(pre(missing.map(function (msg) { - return '* ' + msg; - }).join('\n'))); - } else { - $body.text('All keys are present in all translations'); - } + var todo = function (missing) { + if (missing.length) { + $body.append(pre(missing.map(function (msg) { + return '* ' + msg; + }).join('\n'))); + } else { + $body.text('All keys are present in all translations'); + } + }; + Cryptpad.Messages._checkTranslationState(todo); }); diff --git a/www/login/main.js b/www/login/main.js index 2a67748d6..e18732671 100644 --- a/www/login/main.js +++ b/www/login/main.js @@ -1,9 +1,8 @@ define([ '/common/cryptpad-common.js', - '/customize/languageSelector.js', '/common/login.js', '/bower_components/jquery/dist/jquery.min.js', -], function (Cryptpad, LS, Login) { +], function (Cryptpad, Login) { var $ = window.$; var APP = window.APP = { diff --git a/www/settings/index.html b/www/settings/index.html index 5257175c5..e786f19ed 100644 --- a/www/settings/index.html +++ b/www/settings/index.html @@ -18,6 +18,7 @@