@@ -83,6 +83,7 @@ var dom = new function() {
83
83
settingsParseOutput: null,
84
84
themeCSS: null,
85
85
themesContainer: null,
86
+ languagesContainer: null,
86
87
body: null,
87
88
startupScript: null,
88
89
@@ -96,13 +97,17 @@ var dom = new function() {
96
97
dul.moveToElementText(object);
97
98
sel.text = c;
98
99
var len = dul.text.indexOf(c);
99
- sel.moveStart(' character', -1);
100
+ sel.moveStart(" character", -1);
100
101
sel.text = "";
101
102
return len;
102
103
},
103
104
104
105
getThemeSelectorObject: function(themeName) {
105
106
return dom.element("terminal-color-theme-" + themeName);
107
+ },
108
+
109
+ getLanguageSelectorObject: function(langName) {
110
+ return dom.element("terminal-language-unit-" + langName);
106
111
}
107
112
};
108
113
@@ -204,6 +209,7 @@ var dom = new function() {
204
209
objects.settingsCleanStartup = dom.element("settings-cleanStartup");
205
210
objects.themesContainer = dom.element("terminal-themes-container");
206
211
objects.settingsParseOutput = dom.element("settings-parse-output");
212
+ objects.languagesContainer = dom.element("terminal-languages-container");
207
213
objects.startupScript = dom.element("startup");
208
214
objects.body = document.body;
209
215
};
@@ -238,7 +244,13 @@ var dom = new function() {
238
244
if (!application.themes.hasOwnProperty(theme) || !theme) continue;
239
245
this.objects.themesContainer.innerHTML += "<input id=\"terminal-color-theme-" + theme + "\" " +
240
246
"type=\"radio\" name=\"terminal-color-scheme\" value=\"" + theme + "\">" + theme[0].toUpperCase() +
241
- theme.substr(1)
247
+ theme.substr(1);
248
+ }
249
+
250
+ for (var l in lang.availableLanguages) {
251
+ if (!lang.availableLanguages.hasOwnProperty(l) || !l) continue;
252
+ this.objects.languagesContainer.innerHTML += "<input id=\"terminal-language-unit-" + l + "\" " +
253
+ "type=\"radio\" name=\"terminal-language-unit\" value=\"" + l + "\">" + l.toUpperCase();
242
254
}
243
255
244
256
return this.objectsReady();
@@ -268,16 +280,15 @@ var settings = new function() {
268
280
colorTheme = "default",
269
281
restoreSession = 0,
270
282
parseOutput = 0,
271
- cleanStartup = 0;
283
+ cleanStartup = 0,
284
+ language = "en";
272
285
273
286
this.get_restoreSession = function() { return restoreSession == 1 };
274
287
this.get_cleanStartup = function() { return cleanStartup == 1 && !terminal.ready };
275
288
this.get_parseOutput = function() { return parseOutput };
276
289
this.get_animations = function() { return animations };
277
-
278
- this.get_theme = function() {
279
- return colorTheme;
280
- };
290
+ this.get_language = function() { return language };
291
+ this.get_theme = function() { return colorTheme };
281
292
282
293
this.export = function() {
283
294
return {
@@ -287,15 +298,17 @@ var settings = new function() {
287
298
colorTheme: colorTheme,
288
299
restoreSession: restoreSession,
289
300
cleanStartup: cleanStartup,
290
- parseOutput: parseOutput
301
+ parseOutput: parseOutput,
302
+ language: language
291
303
};
292
304
};
293
305
294
306
this.import = function(settingImportObject) {
295
307
if (!(typeof settingImportObject === "object" && settingImportObject.hasOwnProperty("!export:settings") &&
296
308
settingImportObject.hasOwnProperty("animations") && settingImportObject.hasOwnProperty("highlighting") &&
297
309
settingImportObject.hasOwnProperty("colorTheme") && settingImportObject.hasOwnProperty("restoreSession") &&
298
- settingImportObject.hasOwnProperty("cleanStartup") && settingImportObject.hasOwnProperty("cleanStartup"))) {
310
+ settingImportObject.hasOwnProperty("cleanStartup") && settingImportObject.hasOwnProperty("parseOutput") &&
311
+ settingImportObject.hasOwnProperty("language"))) {
299
312
log.write("Wrong settings object to import. Use /reset to restore settings.");
300
313
return;
301
314
}
@@ -305,6 +318,7 @@ var settings = new function() {
305
318
parseOutput = settingImportObject["parseOutput"];
306
319
restoreSession = (settingImportObject["restoreSession"] == 1)?1:0;
307
320
cleanStartup = settingImportObject["cleanStartup"];
321
+ language = settingImportObject["language"];
308
322
this.update();
309
323
};
310
324
@@ -315,6 +329,7 @@ var settings = new function() {
315
329
restoreSession = 0;
316
330
parseOutput = 0;
317
331
cleanStartup = 0;
332
+ language = "en";
318
333
this.update();
319
334
};
320
335
@@ -337,6 +352,14 @@ var settings = new function() {
337
352
if (obj.checked) colorTheme = theme;
338
353
}
339
354
355
+ language = "en";
356
+ for (var l in lang.availableLanguages) {
357
+ if (!lang.availableLanguages.hasOwnProperty(l)) continue;
358
+ var obj2 = dom.objects.getLanguageSelectorObject(l);
359
+ if (!obj2) continue;
360
+ if (obj2.checked) language = l;
361
+ }
362
+
340
363
dom.objects.themeCSS.href = "css/theme-" + colorTheme + ".css";
341
364
if (!animations) {
342
365
dom.removeClass(dom.objects.body,"noAnimations");
@@ -385,6 +408,12 @@ var settings = new function() {
385
408
if (!obj) continue;
386
409
obj.checked = colorTheme === theme;
387
410
}
411
+ for (var l in lang.availableLanguages) {
412
+ if (!lang.availableLanguages.hasOwnProperty(l)) continue;
413
+ var obj2 = dom.objects.getLanguageSelectorObject(l);
414
+ if (!obj2) continue;
415
+ obj2.checked = language === l;
416
+ }
388
417
};
389
418
390
419
this.update = function() {
0 commit comments