2016-09-15 00:08:52 +08:00
|
|
|
define(['/customize/languageSelector.js',
|
|
|
|
'/customize/translations/messages.js',
|
2016-10-24 17:41:36 +08:00
|
|
|
'/customize/translations/messages.es.js',
|
2016-09-15 00:08:52 +08:00
|
|
|
'/customize/translations/messages.fr.js',
|
2016-11-04 18:51:52 +08:00
|
|
|
|
|
|
|
// 1) additional translation files can be added here...
|
|
|
|
|
|
|
|
'/bower_components/jquery/dist/jquery.min.js'],
|
|
|
|
|
|
|
|
// 2) name your language module here...
|
|
|
|
function(LS, Default, Spanish, French) {
|
2016-09-15 00:08:52 +08:00
|
|
|
var $ = window.jQuery;
|
2014-11-03 23:07:39 +08:00
|
|
|
|
2016-11-04 18:51:52 +08:00
|
|
|
// 3) add your module to this map so it gets used
|
2016-09-15 00:08:52 +08:00
|
|
|
var map = {
|
2016-10-24 17:41:36 +08:00
|
|
|
'fr': French,
|
|
|
|
'es': Spanish,
|
2016-09-15 00:08:52 +08:00
|
|
|
};
|
2014-11-03 23:07:39 +08:00
|
|
|
|
2016-09-15 00:08:52 +08:00
|
|
|
var defaultLanguage = 'en';
|
2014-11-03 23:07:39 +08:00
|
|
|
|
2016-09-15 00:08:52 +08:00
|
|
|
var language = LS.getLanguage();
|
2016-07-11 23:36:53 +08:00
|
|
|
|
2016-09-15 00:08:52 +08:00
|
|
|
var messages;
|
2016-07-11 23:36:53 +08:00
|
|
|
|
2016-09-16 00:35:09 +08:00
|
|
|
if (!language || language === defaultLanguage || language === 'default' || !map[language]) {
|
|
|
|
messages = Default;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Add the translated keys to the returned object
|
|
|
|
messages = $.extend(true, {}, Default, map[language]);
|
|
|
|
}
|
2016-07-11 23:36:53 +08:00
|
|
|
|
2016-10-25 23:29:13 +08:00
|
|
|
// messages_languages return the available translations and their name in an object :
|
|
|
|
// { "en": "English", "fr": "French", ... }
|
2016-10-25 21:22:35 +08:00
|
|
|
messages._languages = {
|
|
|
|
'en': Default._languageName
|
2016-10-25 23:29:13 +08:00
|
|
|
};
|
2016-10-25 21:22:35 +08:00
|
|
|
for (var l in map) {
|
|
|
|
messages._languages[l] = map[l]._languageName || l;
|
|
|
|
}
|
|
|
|
|
|
|
|
messages._initSelector = LS.main;
|
2016-10-24 17:41:36 +08:00
|
|
|
messages._checkTranslationState = function () {
|
|
|
|
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 + "]";
|
|
|
|
missing.push(warning);
|
|
|
|
}
|
|
|
|
});
|
2016-11-03 23:05:02 +08:00
|
|
|
if (typeof(translation._languageName) !== 'string') {
|
|
|
|
var warning = 'key [_languageName] is missing from translation [' + code + ']';
|
|
|
|
missing.push(warning);
|
|
|
|
}
|
2016-10-24 17:41:36 +08:00
|
|
|
});
|
|
|
|
return missing;
|
|
|
|
};
|
|
|
|
|
2016-09-16 00:35:09 +08:00
|
|
|
// Get keys with parameters
|
2016-09-15 00:08:52 +08:00
|
|
|
messages._getKey = function (key, argArray) {
|
|
|
|
if (!messages[key]) { return '?'; }
|
|
|
|
var text = messages[key];
|
|
|
|
return text.replace(/\{(\d+)\}/g, function (str, p1) {
|
|
|
|
return argArray[p1] || null;
|
|
|
|
});
|
|
|
|
};
|
2016-07-11 23:36:53 +08:00
|
|
|
|
2016-09-16 00:35:09 +08:00
|
|
|
messages._applyTranslation = function () {
|
|
|
|
$('[data-localization]').each(function (i, e) {
|
|
|
|
var $el = $(this);
|
|
|
|
var key = $el.data('localization');
|
|
|
|
$el.html(messages[key]);
|
|
|
|
});
|
|
|
|
$('[data-localization-title]').each(function (i, e) {
|
|
|
|
var $el = $(this);
|
|
|
|
var key = $el.data('localization-title');
|
|
|
|
$el.attr('title', messages[key]);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Non translatable keys
|
|
|
|
messages.initialState = [
|
|
|
|
'<p>',
|
|
|
|
'This is <strong>CryptPad</strong>, the zero knowledge realtime collaborative editor.',
|
|
|
|
'<br>',
|
|
|
|
'What you type here is encrypted so only people who have the link can access it.',
|
|
|
|
'<br>',
|
|
|
|
'Even the server cannot see what you type.',
|
|
|
|
'</p>',
|
|
|
|
'<p>',
|
|
|
|
'<small>',
|
|
|
|
'<i>What you see here, what you hear here, when you leave here, let it stay here</i>',
|
|
|
|
'</small>',
|
|
|
|
'</p>',
|
|
|
|
].join('');
|
|
|
|
|
|
|
|
messages.codeInitialState = [
|
|
|
|
'/*\n',
|
|
|
|
' This is CryptPad, the zero knowledge realtime collaborative editor.\n',
|
|
|
|
' What you type here is encrypted so only people who have the link can access it.\n',
|
|
|
|
' Even the server cannot see what you type.\n',
|
|
|
|
' What you see here, what you hear here, when you leave here, let it stay here.\n',
|
|
|
|
'*/'
|
|
|
|
].join('');
|
|
|
|
|
2016-09-30 23:39:16 +08:00
|
|
|
messages.slideInitialState = [
|
|
|
|
'# CryptSlide\n',
|
|
|
|
'* This is a zero knowledge realtime collaborative editor.\n',
|
|
|
|
'* What you type here is encrypted so only people who have the link can access it.\n',
|
|
|
|
'* Even the server cannot see what you type.\n',
|
|
|
|
'* What you see here, what you hear here, when you leave here, let it stay here.\n',
|
|
|
|
'\n',
|
|
|
|
'---',
|
|
|
|
'\n',
|
|
|
|
'# How to use\n',
|
2016-10-03 20:21:39 +08:00
|
|
|
'1. Write your slides content using markdown syntax\n',
|
2016-09-30 23:39:16 +08:00
|
|
|
'2. Separate your slides with ---\n',
|
|
|
|
'3. Click on the "Play" button to see the result'
|
|
|
|
].join('');
|
|
|
|
|
2016-09-15 00:08:52 +08:00
|
|
|
return messages;
|
2014-11-03 23:07:39 +08:00
|
|
|
});
|