Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4003bbb

Browse files
committedFeb 26, 2017
Fix toolbar presets,enablement problems,greatly improve translations
1 parent 00bfe48 commit 4003bbb

File tree

8 files changed

+731
-526
lines changed

8 files changed

+731
-526
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ src
3333
Read the Docs
3434
config.rst
3535

36+
/.project
37+
/.pydevproject
38+

‎notebook/i18n/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,5 @@ of languages in the UI ( never a good thing ).
120120

121121
2. We will need to decide if console messages should be translatable, and enable them if desired.
122122

123-
3. Cell Toolbar presets aren't showing up as translated. I'm looking into this.
124-
125123
Any questions or comments please let me know @JCEmmons on github (emmo@us.ibm.com)
126124

‎notebook/i18n/babel_nbjs.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[javascript: notebook/static/base/js/*.js]
2+
extract_messages = $._
3+
14
[javascript: notebook/static/notebook/js/*.js]
25
extract_messages = $._
36

‎notebook/i18n/de/LC_MESSAGES/nbjs.po

+337-231
Large diffs are not rendered by default.

‎notebook/i18n/de/LC_MESSAGES/nbui.po

+238-244
Large diffs are not rendered by default.

‎notebook/i18n/nbjs.pot

+103-30
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: Jupyter VERSION\n"
1010
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
11-
"POT-Creation-Date: 2017-02-04 15:32-0600\n"
11+
"POT-Creation-Date: 2017-02-26 00:05-0600\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,6 +17,103 @@ msgstr ""
1717
"Content-Transfer-Encoding: 8bit\n"
1818
"Generated-By: Babel 2.3.4\n"
1919

20+
#: notebook/static/base/js/dialog.js:158
21+
msgid "Manually edit the JSON below to manipulate the metadata for this cell."
22+
msgstr ""
23+
24+
#: notebook/static/base/js/dialog.js:160
25+
msgid "Manually edit the JSON below to manipulate the metadata for this notebook."
26+
msgstr ""
27+
28+
#: notebook/static/base/js/dialog.js:162
29+
msgid " We recommend putting custom metadata attributes in an appropriately named substructure, so they don't conflict with those of others."
30+
msgstr ""
31+
32+
#: notebook/static/base/js/dialog.js:177
33+
msgid "Edit the metadata"
34+
msgstr ""
35+
36+
#: notebook/static/base/js/dialog.js:199
37+
msgid "Edit Notebook Metadata"
38+
msgstr ""
39+
40+
#: notebook/static/base/js/dialog.js:201
41+
msgid "Edit Cell Metadata"
42+
msgstr ""
43+
44+
#: notebook/static/base/js/dialog.js:205
45+
#: notebook/static/notebook/js/notebook.js:443
46+
#: notebook/static/notebook/js/savewidget.js:74
47+
#: notebook/static/tree/js/notebooklist.js:784
48+
#: notebook/static/tree/js/notebooklist.js:1134
49+
msgid "Cancel"
50+
msgstr ""
51+
52+
#: notebook/static/base/js/dialog.js:205
53+
msgid "Edit"
54+
msgstr ""
55+
56+
#: notebook/static/base/js/dialog.js:205
57+
#: notebook/static/notebook/js/kernelselector.js:281
58+
#: notebook/static/notebook/js/mathjaxutils.js:45
59+
#: notebook/static/notebook/js/notebook.js:437
60+
#: notebook/static/notebook/js/notificationarea.js:171
61+
#: notebook/static/notebook/js/savewidget.js:74
62+
#: notebook/static/tree/js/newnotebook.js:100
63+
#: notebook/static/tree/js/notebooklist.js:784
64+
msgid "OK"
65+
msgstr ""
66+
67+
#: notebook/static/base/js/dialog.js:205
68+
msgid "Apply"
69+
msgstr ""
70+
71+
#: notebook/static/base/js/dialog.js:222
72+
msgid "WARNING: Could not save invalid JSON."
73+
msgstr ""
74+
75+
#: notebook/static/base/js/dialog.js:244
76+
msgid "There are no attachments for this cell."
77+
msgstr ""
78+
79+
#: notebook/static/base/js/dialog.js:247
80+
msgid "Current cell attachments"
81+
msgstr ""
82+
83+
#: notebook/static/base/js/dialog.js:256
84+
#: notebook/static/notebook/js/celltoolbarpresets/attachments.js:50
85+
msgid "Attachments"
86+
msgstr ""
87+
88+
#: notebook/static/base/js/dialog.js:280
89+
msgid "Restore"
90+
msgstr ""
91+
92+
#: notebook/static/base/js/dialog.js:290
93+
#: notebook/static/tree/js/notebooklist.js:936
94+
msgid "Delete"
95+
msgstr ""
96+
97+
#: notebook/static/base/js/dialog.js:339 notebook/static/base/js/dialog.js:383
98+
msgid "Edit attachments"
99+
msgstr ""
100+
101+
#: notebook/static/base/js/dialog.js:345
102+
msgid "Edit Notebook Attachments"
103+
msgstr ""
104+
105+
#: notebook/static/base/js/dialog.js:347
106+
msgid "Edit Cell Attachments"
107+
msgstr ""
108+
109+
#: notebook/static/base/js/dialog.js:370
110+
msgid "Select a file to insert."
111+
msgstr ""
112+
113+
#: notebook/static/base/js/dialog.js:396
114+
msgid "Select a file"
115+
msgstr ""
116+
20117
#: notebook/static/notebook/js/about.js:17
21118
msgid "You are using Jupyter notebook."
22119
msgstr ""
@@ -641,16 +738,6 @@ msgstr ""
641738
msgid "Set Kernel"
642739
msgstr ""
643740

644-
#: notebook/static/notebook/js/kernelselector.js:281
645-
#: notebook/static/notebook/js/mathjaxutils.js:45
646-
#: notebook/static/notebook/js/notebook.js:437
647-
#: notebook/static/notebook/js/notificationarea.js:171
648-
#: notebook/static/notebook/js/savewidget.js:74
649-
#: notebook/static/tree/js/newnotebook.js:100
650-
#: notebook/static/tree/js/notebooklist.js:784
651-
msgid "OK"
652-
msgstr ""
653-
654741
#: notebook/static/notebook/js/kernelselector.js:284
655742
msgid "Kernel not found"
656743
msgstr ""
@@ -712,6 +799,11 @@ msgstr ""
712799
msgid "Trust Notebook"
713800
msgstr ""
714801

802+
#: notebook/static/notebook/js/celltoolbarpresets/rawcell.js:20
803+
#: notebook/static/notebook/js/menubar.js:380
804+
msgid "None"
805+
msgstr ""
806+
715807
#: notebook/static/notebook/js/menubar.js:403
716808
msgid "No checkpoints"
717809
msgstr ""
@@ -760,13 +852,6 @@ msgstr ""
760852
msgid "Reload"
761853
msgstr ""
762854

763-
#: notebook/static/notebook/js/notebook.js:443
764-
#: notebook/static/notebook/js/savewidget.js:74
765-
#: notebook/static/tree/js/notebooklist.js:784
766-
#: notebook/static/tree/js/notebooklist.js:1134
767-
msgid "Cancel"
768-
msgstr ""
769-
770855
#: notebook/static/notebook/js/notebook.js:444
771856
msgid "Overwrite"
772857
msgstr ""
@@ -1610,10 +1695,6 @@ msgstr ""
16101695
msgid "Edit Attachments"
16111696
msgstr ""
16121697

1613-
#: notebook/static/notebook/js/celltoolbarpresets/attachments.js:50
1614-
msgid "Attachments"
1615-
msgstr ""
1616-
16171698
#: notebook/static/notebook/js/celltoolbarpresets/default.js:23
16181699
msgid "Cell"
16191700
msgstr ""
@@ -1623,10 +1704,6 @@ msgstr ""
16231704
msgid "Edit Metadata"
16241705
msgstr ""
16251706

1626-
#: notebook/static/notebook/js/celltoolbarpresets/rawcell.js:20
1627-
msgid "None"
1628-
msgstr ""
1629-
16301707
#: notebook/static/notebook/js/celltoolbarpresets/rawcell.js:21
16311708
msgid "LaTeX"
16321709
msgstr ""
@@ -1818,10 +1895,6 @@ msgid_plural "Are you sure you want to permanently delete the %d files or folder
18181895
msgstr[0] ""
18191896
msgstr[1] ""
18201897

1821-
#: notebook/static/tree/js/notebooklist.js:936
1822-
msgid "Delete"
1823-
msgstr ""
1824-
18251898
#: notebook/static/tree/js/notebooklist.js:953
18261899
#, python-format
18271900
msgid "An error occurred while deleting \"%s\"."

‎notebook/static/base/js/dialog.js

+46-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
define(['base/js/utils'], function(utils) {
55
"use strict";
66

7+
var _ = function(text) {
8+
return utils.i18n.gettext(text);
9+
}
10+
711
var CodeMirror = require('codemirror/lib/codemirror');
812

913
/**
@@ -150,18 +154,27 @@ define(['base/js/utils'], function(utils) {
150154
var edit_metadata = function (options) {
151155
options.name = options.name || "Cell";
152156
var error_div = $('<div/>').css('color', 'red');
153-
var message =
154-
"Manually edit the JSON below to manipulate the metadata for this " + options.name + "." +
155-
" We recommend putting custom metadata attributes in an appropriately named substructure," +
156-
" so they don't conflict with those of others.";
157+
var message_cell =
158+
_("Manually edit the JSON below to manipulate the metadata for this cell.");
159+
var message_notebook =
160+
_("Manually edit the JSON below to manipulate the metadata for this notebook.");
161+
var message_end =
162+
_(" We recommend putting custom metadata attributes in an appropriately named substructure," +
163+
" so they don't conflict with those of others.");
157164

165+
var message;
166+
if (options.name === 'Notebook') {
167+
message = message_notebook + message_end;
168+
} else {
169+
message = message_cell + message_end;
170+
}
158171
var textarea = $('<textarea/>')
159172
.attr('rows', '13')
160173
.attr('cols', '80')
161174
.attr('name', 'metadata')
162175
.text(JSON.stringify(options.md || {}, null, 2));
163176

164-
var dialogform = $('<div/>').attr('title', 'Edit the metadata')
177+
var dialogform = $('<div/>').attr('title', _('Edit the metadata'))
165178
.append(
166179
$('<form/>').append(
167180
$('<fieldset/>').append(
@@ -181,8 +194,17 @@ define(['base/js/utils'], function(utils) {
181194
autoIndent: true,
182195
mode: 'application/json',
183196
});
197+
var title_msg;
198+
if (options.name === "Notebook") {
199+
title_msg = _("Edit Notebook Metadata");
200+
} else {
201+
title_msg = _("Edit Cell Metadata");
202+
}
203+
// This statement is used simply so that message extraction
204+
// will pick up the strings.
205+
var button_labels = [ _("Cancel"), _("Edit"), _("OK"), _("Apply")];
184206
var modal_obj = modal({
185-
title: "Edit " + options.name + " Metadata",
207+
title: title_msg,
186208
body: dialogform,
187209
default_button: "Cancel",
188210
buttons: {
@@ -197,7 +219,7 @@ define(['base/js/utils'], function(utils) {
197219
new_md = JSON.parse(editor.getValue());
198220
} catch(e) {
199221
console.log(e);
200-
error_div.text('WARNING: Could not save invalid JSON.');
222+
error_div.text(_('WARNING: Could not save invalid JSON.'));
201223
return false;
202224
}
203225
options.callback(new_md);
@@ -219,10 +241,10 @@ define(['base/js/utils'], function(utils) {
219241
var message;
220242
var attachments_list;
221243
if (Object.keys(options.attachments).length == 0) {
222-
message = "There are no attachments for this cell.";
244+
message = _("There are no attachments for this cell.");
223245
attachments_list = $('<div>');
224246
} else {
225-
message = "Current cell attachments";
247+
message = _("Current cell attachments");
226248

227249
attachments_list = $('<div>')
228250
.addClass('list_container')
@@ -231,7 +253,7 @@ define(['base/js/utils'], function(utils) {
231253
.addClass('row list_header')
232254
.append(
233255
$('<div>')
234-
.text('Attachments')
256+
.text(_('Attachments'))
235257
)
236258
);
237259

@@ -255,7 +277,7 @@ define(['base/js/utils'], function(utils) {
255277
.addClass('btn btn-default btn-xs')
256278
.css('display', 'inline-block');
257279
if (deleted) {
258-
btn.attr('title', 'Restore')
280+
btn.attr('title', _('Restore'))
259281
.append(
260282
$('<i>')
261283
.addClass('fa fa-plus')
@@ -265,7 +287,7 @@ define(['base/js/utils'], function(utils) {
265287
refresh_attachments_list();
266288
});
267289
} else {
268-
btn.attr('title', 'Delete')
290+
btn.attr('title', _('Delete'))
269291
.addClass('btn-danger')
270292
.append(
271293
$('<i>')
@@ -314,12 +336,18 @@ define(['base/js/utils'], function(utils) {
314336
}
315337

316338
var dialogform = $('<div/>')
317-
.attr('title', 'Edit attachments')
339+
.attr('title', _('Edit attachments'))
318340
.append(message)
319341
.append('<br />')
320-
.append(attachments_list)
342+
.append(attachments_list);
343+
var title_msg;
344+
if ( options.name === "Notebook" ) {
345+
title_msg = _("Edit Notebook Attachments");
346+
} else {
347+
title_msg = _("Edit Cell Attachments");
348+
}
321349
var modal_obj = modal({
322-
title: "Edit " + options.name + " Attachments",
350+
title: title_msg,
323351
body: dialogform,
324352
buttons: {
325353
Apply: { class : "btn-primary",
@@ -339,7 +367,7 @@ define(['base/js/utils'], function(utils) {
339367

340368
var insert_image = function (options) {
341369
var message =
342-
"Select a file to insert.";
370+
_("Select a file to insert.");
343371
var file_input = $('<input/>')
344372
.attr('type', 'file')
345373
.attr('accept', 'image/*')
@@ -352,7 +380,7 @@ define(['base/js/utils'], function(utils) {
352380
$btn.addClass('disabled');
353381
}
354382
});
355-
var dialogform = $('<div/>').attr('title', 'Edit attachments')
383+
var dialogform = $('<div/>').attr('title', _('Edit attachments'))
356384
.append(
357385
$('<form id="insert-image-form" />').append(
358386
$('<fieldset/>').append(
@@ -365,7 +393,7 @@ define(['base/js/utils'], function(utils) {
365393
)
366394
);
367395
var modal_obj = modal({
368-
title: "Pick a file",
396+
title: _("Select a file"),
369397
body: dialogform,
370398
buttons: {
371399
OK: {

‎notebook/static/notebook/js/menubar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ define([
377377

378378
// Setup the existing presets
379379
var presets = celltoolbar.CellToolbar.list_presets();
380-
preset_added(null, {name: "None"});
380+
preset_added(null, {name: _("None")});
381381
presets.map(function (name) {
382382
preset_added(null, {name: name});
383383
});

0 commit comments

Comments
 (0)
Please sign in to comment.