better effort for translation

pull/1/head
ansuz 9 years ago
parent cde68170d4
commit 3eccec7054

@ -1,10 +1,11 @@
define([
'/common/messages.js',
'/customize/DecorateToolbar.js',
'/common/cryptpad-common.js',
'/bower_components/lil-uri/uri.min.js',
'/customize/email.js',
'/bower_components/jquery/dist/jquery.min.js',
], function (DecorateToolbar, Cryptpad, LilUri, Email) {
], function (Messages, DecorateToolbar, Cryptpad, LilUri, Email) {
var $ = window.$;
var email = Email.makeScrambler(1);
@ -88,14 +89,14 @@ define([
'class': 'remove',
title: "forget '"+shortTitle + "'"
}).text('✖').click(function () {
Cryptpad.confirm(fixHTML("Are you sure you'd like to forget this pad (" + shortTitle + ")?"), function (yes) {
Cryptpad.confirm(Messages.forgetPrompt + ' (' + fixHTML(shortTitle) + ')', function (yes) {
if (!yes) { return; }
forgetPad(pad.href);
$row.fadeOut(750, function () {
$row.remove();
if (!$table.find('tr').find('td').length) {
$table.remove();
$tryit.text("Try it out!");
$tryit.text(Messages.tryIt);
}
});
});
@ -120,7 +121,7 @@ define([
}
if (hasRecent) {
$('table').attr('style', '');
$tryit.text('Your Recent pads (stored only in browser)');
$tryit.text(Messages.recentPads);
}
});

@ -66,6 +66,7 @@ define([
if ($select && $select.val) { $select.val(mode); }
};
editor.setValue(Messages.codeInitialState); // HERE
var setTheme = module.setTheme = (function () {
var path = './theme/';
@ -103,7 +104,7 @@ define([
var exportText = module.exportText = function () {
var text = editor.getValue();
Cryptpad.prompt('What would you like to name your file?',
Cryptpad.prompt(Messages.exportPrompt,
document.title, function (filename) {
if (filename === null) { return; }
var blob = new Blob([text], {
@ -169,7 +170,7 @@ define([
var createChangeName = function(id, $container) {
var buttonElmt = $container.find('#'+id)[0];
buttonElmt.addEventListener("click", function() {
Cryptpad.prompt("Change your name:", '', function (newName) {
Cryptpad.prompt(Messages.changeNamePrompt, '', function (newName) {
if (!(typeof(newName) === 'string' && newName.trim())) { return; }
var myUserNameTemp = newName.trim();
if(newName.trim().length > 32) {
@ -200,14 +201,14 @@ define([
/* add an export button */
var $export = $('<button>')
.text('EXPORT')
.text(Messages.exportButton)
.addClass('rightside-button')
.click(exportText);
$rightside.append($export);
/* add an import button */
var $import = $('<button>')
.text('IMPORT')
.text(Messages.importButton)
.addClass('rightside-button')
.click(Cryptpad.importContent('text/plain', function (content, file) {
var mime = CodeMirror.findModeByMIME(file.type);
@ -233,13 +234,13 @@ define([
id: 'name-pad'
})
.addClass('rightside-button')
.text('RENAME')
.text(Messages.renameButton)
.click(function () {
Cryptpad.prompt("How would you like this pad to be titled?",
Cryptpad.prompt(Messages.renamePrompt,
Cryptpad.getPadTitle(), function (title, ev) {
if (title === null) { return; }
if (Cryptpad.causesNamingConflict(title)) {
Cryptpad.alert("Another pad already has that title");
Cryptpad.alert(Messages.renameConflict);
return;
}
Cryptpad.setPadTitle(title);
@ -252,12 +253,11 @@ define([
var $forgetPad = $('<button>', {
id: 'cryptpad-forget',
})
.text('FORGET')
.text(Messages.forgetButton)
.addClass('cryptpad-forget rightside-button')
.click(function () {
var href = window.location.href;
var question = "Clicking OK will remove the URL for this pad from localStorage, are you sure?";
Cryptpad.confirm(question, function (yes) {
Cryptpad.confirm(Messages.forgetPrompt, function (yes) {
if (!yes) { return; }
Cryptpad.forgetPad(href);
document.title = window.location.hash.slice(1,9);
@ -354,7 +354,7 @@ define([
// Update the user list (metadata) from the hyperjson
//updateUserList(shjson);
editor.setValue(newDoc);
editor.setValue(newDoc || Messages.codeInitialState);
if (Visible.isSupported()) {
Visible.onChange(function (yes) {
@ -442,7 +442,7 @@ define([
var onAbort = config.onAbort = function (info) {
// inform of network disconnect
setEditable(false);
Cryptpad.alert("Network Connection Lost!");
Cryptpad.alert(Messages.disconnectAlert);
};
Cryptpad.styleAlerts();

@ -168,6 +168,10 @@ define([
return title;
};
var fixFileName = common.fixFileName = function (filename) {
return filename.replace(/ /g, '-').replace(/\//g, '_');
};
var causesNamingConflict = common.causesNamingConflict = function (title) {
var href = window.location.href;
return getRecentPads().some(function (pad) {

@ -16,6 +16,28 @@ define(function () {
out.reconnecting = 'Reconnecting...';
out.lag = 'Lag';
out.importButton = 'IMPORT';
out.exportButton = 'EXPORT';
out.exportPrompt = 'What would you like to name your file?';
out.back = '&#8656; Back';
out.changeNameButton = 'Change name';
out.changeNamePrompt = 'Change your name: ';
out.renameButton = 'RENAME';
out.renamePrompt = 'How would you like to title this pad?';
out.renameConflict = 'Another pad already has that title';
out.forgetButton = 'FORGET';
out.forgetPrompt = 'Clicking OK will remove the URL for this pad from localStorage, are you sure?';
out.disconnectAlert = 'Network connection lost!';
out.tryIt = 'Try it out!';
out.recentPads = 'Your recent pads (stored only in your browser)';
out.initialState = [
'<p>',
'This is <strong>CryptPad</strong>, the zero knowledge realtime collaborative editor.',
@ -33,10 +55,10 @@ define(function () {
out.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',
' 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('');

@ -69,7 +69,7 @@ define([
var $back = $('<div>', {
'class': BACK_CLS,
id: uid(),
}).html('&#8656; Back').click(function () {
}).html(Messages.back).click(function () {
window.location.href = '/';
});
$container.append($back);
@ -128,7 +128,7 @@ define([
var $button = $('<button>', {
id: buttonID,
'class': USERNAME_BUTTON_GROUP,
}).text('Change name');
}).text(Messages.changeNameButton);
$(userList).append($button);
$button.after($span);

@ -237,7 +237,7 @@ define([
var createChangeName = function(id, $container) {
var buttonElmt = $container.find('#'+id)[0];
buttonElmt.addEventListener("click", function() {
Cryptpad.prompt("Change your name:", '', function (newName) {
Cryptpad.prompt(Messages.changeNamePrompt, '', function (newName) {
if (!(typeof(newName) === 'string' && newName.trim())) { return; }
var myUserNameTemp = newName.trim();
if(myUserNameTemp.length > 32) {
@ -414,8 +414,8 @@ define([
var exportFile = function () {
var html = getHTML();
var suggestion = suggestName();
Cryptpad.prompt("What would you like to name your file?",
suggestion.replace(/ /g, '-') + '.html', function (filename) {
Cryptpad.prompt(Messages.exportPrompt,
Cryptpad.fixFileName(suggestion) + '.html', function (filename) {
if (!(typeof(filename) === 'string' && filename)) { return; }
var blob = new Blob([html], {type: "text/html;charset=utf-8"});
saveAs(blob, filename);
@ -436,13 +436,13 @@ define([
/* add an export button */
var $export = $('<button>')
.text('EXPORT')
.text(Messages.exportButton)
.addClass('rightside-button')
.click(exportFile);
/* add an import button */
var $import = $('<button>')
.text('IMPORT')
.text(Messages.importButton)
.addClass('rightside-button')
.click(Cryptpad.importContent('text/plain', function (content) {
var shjson = stringify(Hyperjson.fromDOM(domFromHTML(content).body));
@ -456,14 +456,14 @@ define([
id: 'name-pad',
})
.addClass('cryptpad-rename rightside-button')
.text('RENAME')
.text(Messages.renameButton)
.click(function () {
var suggestion = suggestName();
Cryptpad.prompt("How would you like to title this pad?", suggestion, function (title) {
Cryptpad.prompt(Messages.renamePrompt, suggestion, function (title) {
if (title === null) { return; }
if (Cryptpad.causesNamingConflict(title)) {
Cryptpad.alert("Another pad already has that title");
Cryptpad.alert(Messages.renameConflict);
return;
}
@ -477,12 +477,11 @@ define([
var $forgetPad = $('<button>', {
id: 'cryptpad-forget',
})
.text("FORGET")
.text(Messages.forgetButton)
.addClass('cryptpad-forget rightside-button')
.click(function () {
var href = window.location.href;
var question = "Clicking OK will remove the URL for this pad from localStorage, are you sure?";
Cryptpad.confirm(question, function (yes) {
Cryptpad.confirm(Messages.forgetPrompt, function (yes) {
if (!yes) { return; }
Cryptpad.forgetPad(href);
document.title = window.location.hash.slice(1,9);
@ -527,7 +526,7 @@ define([
setEditable(false);
// TODO inform them that the session was torn down
toolbar.failed();
Cryptpad.alert("Network connection lost!");
Cryptpad.alert(Messages.disconnectAlert);
};
var onLocal = realtimeOptions.onLocal = function () {

Loading…
Cancel
Save