Skip to content

Commit 4692f33

Browse files
committed
localization and stuff
1 parent 45745c4 commit 4692f33

File tree

4 files changed

+102
-23
lines changed

4 files changed

+102
-23
lines changed

admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ function html() {
131131

132132
echo '<script src="' . DOKU_BASE . 'lib/plugins/sync/sync.js" type="text/javascript"></script>';
133133

134+
echo '<h1>'.$this->getLang('menu').'</h1>';
134135
echo '<div id="sync__progress"><div class="label"></div></div>';
135136
echo '<div id="sync__plugin"></div>';
136137

lang/en/lang.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,26 @@
4848
$lang['remotedelfail'] = 'remote delete failed:';
4949
$lang['skipped'] = 'skipped:';
5050

51-
$lang['file'] = 'Page or Media File';
52-
$lang['local'] = 'Local Wiki';
53-
$lang['remote'] = 'Remote Wiki';
54-
$lang['diff'] = 'Diff';
51+
$lang['js']['file'] = 'Page or Media File';
52+
$lang['js']['local'] = 'Local Wiki';
53+
$lang['js']['remote'] = 'Remote Wiki';
54+
$lang['js']['diff'] = 'Diff';
55+
$lang['js']['dir'] = 'Sync Direction';
5556

5657
$lang['js']['push'] = 'Push local revision to remote wiki.';
5758
$lang['js']['pushdel'] = 'Delete revision at the remote wiki.';
5859
$lang['js']['pull'] = 'Pull remote revision to local wiki.';
5960
$lang['js']['pulldel'] = 'Delete local revision.';
6061
$lang['js']['keep'] = 'Skip this file and keep both revisions as is.';
6162

62-
$lang['syncdone'] = 'Synchronization finished.';
63+
$lang['js']['insync'] = 'Both wiki namespaces are in sync. Nothing to do.';
64+
$lang['js']['tosync'] = 'Syncing %d files…';
65+
$lang['js']['btn_done'] = 'Done';
66+
$lang['js']['btn_start'] = 'Start';
67+
$lang['js']['syncdone'] = 'Synchronization finished.';
68+
$lang['js']['loading'] = 'Retrieving File List…';
69+
70+
6371
$lang['timeout'] = 'Timeout';
6472

6573

style.less

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323
}
2424
}
2525

26+
#sync__progress {
27+
position: relative;
28+
29+
div.label {
30+
position: absolute;
31+
padding: 4px;
32+
font-weight: bold;
33+
text-shadow: 1px 1px 0 #fff;
34+
text-align: center;
35+
overflow: hidden;
36+
}
37+
}
38+
2639
#sync__plugin {
2740
table {
2841
table-layout: fixed;
@@ -39,6 +52,7 @@
3952
td.local,
4053
td.remote {
4154
white-space: nowrap;
55+
width: 9em;
4256
}
4357
}
4458

sync.js

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,58 @@ jQuery(function () {
66
var $progress = jQuery('#sync__progress').progressbar({value: false});
77
var $progress_label = $progress.find('.label');
88

9-
9+
/**
10+
* Show the table of items to sync
11+
*
12+
* @param {object} data
13+
*/
1014
function displayTable(data) {
1115
console.log(data);
1216

1317
SYNC_DATA.times = data.times;
1418

15-
if(data.count === 0) {
16-
$output.append('<p>No data to sync</p>');
17-
$output.append(finishbutton());
19+
if (data.count === 0) {
20+
log(LANG.plugins.sync.insync);
21+
finishbutton();
1822
return;
1923
}
2024

2125
var $table = jQuery('<table>');
26+
$table.append(headers());
2227
jQuery.each(data.list, function (type, items) {
2328
jQuery.each(items, function (id, item) {
2429
$table.append(tr(type, id, item));
2530
});
2631
});
2732
$output.append($table);
2833

29-
var $button = jQuery('<button>sync</button>');
34+
var $button = jQuery('<button>');
3035
$button.click(beginsync);
36+
$button.text(LANG.plugins.sync.btn_start);
3137
$output.append($button);
3238

3339
$progress.hide();
3440
}
3541

42+
function headers() {
43+
var $tr = jQuery('<tr>');
44+
45+
['file', 'local', 'dir', 'remote', 'diff'].map(function (l) {
46+
var $th = jQuery('<th>');
47+
$th.addClass(l);
48+
$th.text(LANG.plugins.sync[l]);
49+
$tr.append($th);
50+
});
51+
return $tr;
52+
}
53+
54+
/**
55+
* Get one table row for the given item
56+
*
57+
* @param {int} type
58+
* @param {string} id
59+
* @param {object} item
60+
*/
3661
function tr(type, id, item) {
3762
var $tr = jQuery('<tr>');
3863
$tr.html(
@@ -63,6 +88,11 @@ jQuery(function () {
6388
return $tr;
6489
}
6590

91+
/**
92+
* Get the direction buttons for the given Item
93+
*
94+
* @param {object} item
95+
*/
6696
function dir(item) {
6797
row++;
6898

@@ -111,6 +141,9 @@ jQuery(function () {
111141
return $html;
112142
}
113143

144+
/**
145+
* Start the sync process
146+
*/
114147
function beginsync() {
115148
SYNC_DATA.items = [];
116149

@@ -130,20 +163,25 @@ jQuery(function () {
130163
$progress.progressbar('option', 'max', SYNC_DATA.items.length);
131164
$progress.show();
132165

133-
$output.append('<p>Syncing ' + SYNC_DATA.items.length + ' files</p>'); // FIXME localize
134-
166+
log(LANG.plugins.sync.tosync.replace(/%d/, SYNC_DATA.items.length));
135167
sync();
136168
}
137169

170+
/**
171+
* Hide the progressbar and output a button for ending the sync
172+
*/
138173
function finishbutton() {
139174
$progress.hide();
140175
var link = document.createElement('a');
141176
link.href = DOKU_BASE + '?do=admin&page=sync';
142-
link.text = 'Okay'; // FIXME localize
177+
link.text = LANG.plugins.sync.btn_done;
143178
link.className = 'button';
144-
return link;
179+
$output.append(link);
145180
}
146181

182+
/**
183+
* Finalize the sync process
184+
*/
147185
function endsync() {
148186
jQuery.ajax(
149187
DOKU_BASE + 'lib/exe/ajax.php',
@@ -155,26 +193,28 @@ jQuery(function () {
155193
ltime: SYNC_DATA.times.ltime,
156194
rtime: SYNC_DATA.times.rtime
157195
},
158-
complete: function () {
159-
$output.append(finishbutton());
160-
},
196+
complete: finishbutton(),
161197
error: error
162198
}
163199
);
164200
}
165201

202+
/**
203+
* Sync the next file from the sync list
204+
*/
166205
function sync() {
167206
var cur = $progress.progressbar('option', 'max') - SYNC_DATA.items.length;
168207
$progress.progressbar('option', 'value', cur);
169-
$progress_label.text = '';
208+
$progress_label.text('');
170209

171210
var item = SYNC_DATA.items.pop();
172211
if (!item) {
212+
log(LANG.plugins.sync.syncdone);
173213
endsync();
174214
return;
175215
}
176216

177-
$progress_label.text = item[0];
217+
$progress_label.text(item[0]);
178218
jQuery.ajax(
179219
DOKU_BASE + 'lib/exe/ajax.php',
180220
{
@@ -192,14 +232,30 @@ jQuery(function () {
192232
);
193233
}
194234

195-
196-
function error(data) {
235+
/**
236+
* Add the given error to the output
237+
*
238+
* @param {string} error
239+
*/
240+
function error(error) {
197241
var $err = jQuery('<div class="error">');
198-
$err.text(data);
242+
$err.text(error);
199243
$output.append($err);
200244
}
201245

246+
/**
247+
* Output a given log message
248+
*
249+
* @param {string} log
250+
*/
251+
function log(log) {
252+
var $p = jQuery('<p>');
253+
$p.text = log;
254+
$output.append($p);
255+
}
256+
202257
// main
258+
$progress_label.text(LANG.plugins.sync.loading);
203259
jQuery.ajax(
204260
DOKU_BASE + 'lib/exe/ajax.php',
205261
{
@@ -211,6 +267,6 @@ jQuery(function () {
211267
success: displayTable,
212268
error: error
213269
}
214-
)
270+
);
215271

216272
});

0 commit comments

Comments
 (0)