diff --git a/src/ext/keybinding_menu.js b/src/ext/keybinding_menu.js
index 26ebbefa601..9ff554321e5 100644
--- a/src/ext/keybinding_menu.js
+++ b/src/ext/keybinding_menu.js
@@ -12,6 +12,7 @@
"use strict";
+var nls = require("../config").nls;
var Editor = require("../editor").Editor;
/**
@@ -35,7 +36,8 @@ function showKeyboardShortcuts(editor) {
}, '');
el.id = 'kbshortcutmenu';
- el.innerHTML = '
Keyboard Shortcuts
' + commands + '';
+ el.innerHTML = '' + nls('keybinding-menu.head', 'Keyboard Shortcuts') + '
'
+ + commands + '';
overlayPage(editor, el);
}
}
diff --git a/src/ext/options.js b/src/ext/options.js
index f30f83f2af9..09c332df897 100644
--- a/src/ext/options.js
+++ b/src/ext/options.js
@@ -8,15 +8,16 @@ require("./menu_tools/overlay_page");
var dom = require("../lib/dom");
var oop = require("../lib/oop");
var config = require("../config");
+var nls = config.nls;
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var buildDom = dom.buildDom;
var modelist = require("./modelist");
var themelist = require("./themelist");
-var themes = { Bright: [], Dark: [] };
+var themes = { bright: [], dark: [] };
themelist.themes.forEach(function(x) {
- themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme });
+ themes[x.isDark ? "dark" : "bright"].push({ caption: x.caption, value: x.theme });
});
var modes = modelist.modes.map(function(x){
@@ -25,193 +26,323 @@ var modes = modelist.modes.map(function(x){
var optionGroups = {
- Main: {
- Mode: {
+ main: [
+ {
path: "mode",
+ label: nls("options.mode", "Mode"),
type: "select",
items: modes
},
- Theme: {
+ {
path: "theme",
+ label: nls("options.theme", "Theme"),
type: "select",
- items: themes
+ items: [
+ {
+ label: nls("options.theme.bright", "Bright"),
+ items: themes.bright
+ },
+ {
+ label: nls("options.theme.dark", "Dark"),
+ items: themes.dark
+ }
+ ]
},
- "Keybinding": {
- type: "buttonBar",
+ {
path: "keyboardHandler",
+ label: nls("options.keyboard-handler", "Keybinding"),
+ type: "buttonBar",
items: [
- { caption : "Ace", value : null },
- { caption : "Vim", value : "ace/keyboard/vim" },
- { caption : "Emacs", value : "ace/keyboard/emacs" },
- { caption : "Sublime", value : "ace/keyboard/sublime" },
- { caption : "VSCode", value : "ace/keyboard/vscode" }
+ {
+ caption: "Ace",
+ value: null
+ },
+ {
+ caption: "Vim",
+ value: "ace/keyboard/vim"
+ },
+ {
+ caption: "Emacs",
+ value: "ace/keyboard/emacs"
+ },
+ {
+ caption: "Sublime",
+ value: "ace/keyboard/sublime"
+ },
+ {
+ caption: "VSCode",
+ value: "ace/keyboard/vscode"
+ }
]
},
- "Font Size": {
+ {
path: "fontSize",
+ label: nls("options.font-size", "Font Size"),
type: "number",
defaultValue: 12,
defaults: [
- {caption: "12px", value: 12},
- {caption: "24px", value: 24}
+ {
+ caption: nls("options.font-size.px", "$0px", ["12"]),
+ value: 12
+ },
+ {
+ caption: nls("options.font-size.px", "$0px", ["24"]),
+ value: 24
+ }
]
},
- "Soft Wrap": {
- type: "buttonBar",
+ {
path: "wrap",
+ label: nls("options.wrap", "Soft Wrap"),
+ type: "buttonBar",
items: [
- { caption : "Off", value : "off" },
- { caption : "View", value : "free" },
- { caption : "margin", value : "printMargin" },
- { caption : "40", value : "40" }
+ {
+ caption: nls("options.wrap.off", "Off"),
+ value: "off"
+ },
+ {
+ caption: nls("options.wrap.view", "View"),
+ value: "free"
+ },
+ {
+ caption: nls("options.wrap.margin", "margin"),
+ value: "printMargin" },
+ {
+ caption: "40",
+ value: "40"
+ }
]
},
- "Cursor Style": {
+ {
path: "cursorStyle",
+ label: nls("options.cursor-style", "Cursor Style"),
items: [
- { caption : "Ace", value : "ace" },
- { caption : "Slim", value : "slim" },
- { caption : "Smooth", value : "smooth" },
- { caption : "Smooth And Slim", value : "smooth slim" },
- { caption : "Wide", value : "wide" }
+ {
+ caption: "Ace",
+ value: "ace"
+ },
+ {
+ caption: nls("options.cursor-style.slim", "Slim"),
+ value: "slim"
+ },
+ {
+ caption: nls("options.cursor-style.smooth", "Smooth"),
+ value: "smooth"
+ },
+ {
+ caption: nls("options.cursor-style.smooth-slim", "Smooth And Slim"),
+ value: "smooth slim"
+ },
+ {
+ caption: nls("options.cursor-style.wide", "Wide"),
+ value: "wide"
+ }
]
},
- "Folding": {
+ {
path: "foldStyle",
+ label: nls("options.fold-style", "Folding"),
items: [
- { caption : "Manual", value : "manual" },
- { caption : "Mark begin", value : "markbegin" },
- { caption : "Mark begin and end", value : "markbeginend" }
+ {
+ caption: nls("options.fold-style.manual", "Manual"),
+ value: "manual"
+ },
+ {
+ caption: nls("options.fold-style.mark-begin", "Mark begin"),
+ value: "markbegin"
+ },
+ {
+ caption: nls("options.fold-style.mark-begin-end", "Mark begin and end"),
+ value: "markbeginend"
+ }
]
},
- "Soft Tabs": [{
- path: "useSoftTabs"
- }, {
- ariaLabel: "Tab Size",
- path: "tabSize",
- type: "number",
- values: [2, 3, 4, 8, 16]
- }],
- "Overscroll": {
- type: "buttonBar",
+ [
+ {
+ path: "useSoftTabs",
+ label: nls("options.use-soft-tabs", "Soft Tabs")
+ },
+ {
+ ariaLabel: nls("options.tab-size", "Tab Size"),
+ path: "tabSize",
+ type: "number",
+ values: [2, 3, 4, 8, 16]
+ }
+ ],
+ {
path: "scrollPastEnd",
+ label: nls("options.scroll-past-end", "Overscroll"),
+ type: "buttonBar",
items: [
- { caption : "None", value : 0 },
- { caption : "Half", value : 0.5 },
- { caption : "Full", value : 1 }
+ {
+ caption: nls("options.scroll-past-end.none", "None"),
+ value: 0
+ },
+ {
+ caption: nls("options.scroll-past-end.half", "Half"),
+ value: 0.5
+ },
+ {
+ caption: nls("options.scroll-past-end.full", "Full"),
+ value: 1
+ }
]
}
- },
- More: {
- "Atomic soft tabs": {
- path: "navigateWithinSoftTabs"
- },
- "Enable Behaviours": {
- path: "behavioursEnabled"
- },
- "Wrap with quotes": {
- path: "wrapBehavioursEnabled"
- },
- "Enable Auto Indent": {
- path: "enableAutoIndent"
- },
- "Full Line Selection": {
+ ],
+ more: [
+ {
+ path: "navigateWithinSoftTabs",
+ label: nls("options.navigate-within-soft-tabs", "Atomic soft tabs")
+ },
+ {
+ path: "behavioursEnabled",
+ label: nls("options.behaviours-enabled", "Enable Behaviours")
+ },
+ {
+ path: "wrapBehavioursEnabled",
+ label: nls("options.wrap-behaviours-enabled", "Wrap with quotes")
+ },
+ {
+ path: "enableAutoIndent",
+ label: nls("options.enable-auto-indent", "Enable Auto Indent")
+ },
+ {
+ path: "selectionStyle",
+ label: nls("options.selection-style", "Full Line Selection"),
type: "checkbox",
- values: "text|line",
- path: "selectionStyle"
- },
- "Highlight Active Line": {
- path: "highlightActiveLine"
- },
- "Show Invisibles": {
- path: "showInvisibles"
- },
- "Show Indent Guides": {
- path: "displayIndentGuides"
- },
- "Highlight Indent Guides": {
- path: "highlightIndentGuides"
- },
- "Persistent HScrollbar": {
- path: "hScrollBarAlwaysVisible"
- },
- "Persistent VScrollbar": {
- path: "vScrollBarAlwaysVisible"
- },
- "Animate scrolling": {
- path: "animatedScroll"
- },
- "Show Gutter": {
- path: "showGutter"
- },
- "Show Line Numbers": {
- path: "showLineNumbers"
- },
- "Relative Line Numbers": {
- path: "relativeLineNumbers"
- },
- "Fixed Gutter Width": {
- path: "fixedWidthGutter"
- },
- "Show Print Margin": [{
- path: "showPrintMargin"
- }, {
- ariaLabel: "Print Margin",
- type: "number",
- path: "printMarginColumn"
- }],
- "Indented Soft Wrap": {
- path: "indentedSoftWrap"
+ values: "text|line"
+ },
+ {
+ path: "highlightActiveLine",
+ label: nls("options.highlight-active-line", "Highlight Active Line")
+ },
+ {
+ path: "showInvisibles",
+ label: nls("options.show-invisibles", "Show Invisibles")
+ },
+ {
+ path: "displayIndentGuides",
+ label: nls("options.display-indent-guides", "Show Indent Guides")
+ },
+ {
+ path: "highlightIndentGuides",
+ label: nls("options.highlight-indent-guides", "Highlight Indent Guides")
+ },
+ {
+ path: "hScrollBarAlwaysVisible",
+ label: nls("options.h-scroll-bar-always-visible", "Persistent HScrollbar")
+ },
+ {
+ path: "vScrollBarAlwaysVisible",
+ label: nls("options.v-scroll-bar-always-visible", "Persistent VScrollbar")
+ },
+ {
+ path: "animatedScroll",
+ label: nls("options.animated-scroll", "Animate scrolling")
+ },
+ {
+ path: "showGutter",
+ label: nls("options.show-gutter", "Show Gutter")
+ },
+ {
+ path: "showLineNumbers",
+ label: nls("options.show-line-numbers", "Show Line Numbers")
+ },
+ {
+ path: "relativeLineNumbers",
+ label: nls("options.relative-line-numbers", "Relative Line Numbers")
+ },
+ {
+ path: "fixedWidthGutter",
+ label: nls("options.fixed-width-gutter", "Fixed Gutter Width")
+ },
+ [
+ {
+ path: "showPrintMargin",
+ label: nls("options.show-print-margin", "Show Print Margin")
+ },
+ {
+ ariaLabel: nls("options.show-print-margin.print-margin-column", "Print Margin"),
+ type: "number",
+ path: "printMarginColumn"
+ }
+ ],
+ {
+ path: "indentedSoftWrap",
+ label: nls("options.indented-soft-wrap", "Indented Soft Wrap")
},
- "Highlight selected word": {
- path: "highlightSelectedWord"
+ {
+ path: "highlightSelectedWord",
+ label: nls("options.highlight-selected-word", "Highlight selected word")
},
- "Fade Fold Widgets": {
- path: "fadeFoldWidgets"
+ {
+ path: "fadeFoldWidgets",
+ label: nls("options.fade-fold-widgets", "Fade Fold Widgets")
},
- "Use textarea for IME": {
- path: "useTextareaForIME"
+ {
+ path: "useTextareaForIME",
+ label: nls("options.use-textarea-for-ime", "Use textarea for IME")
},
- "Merge Undo Deltas": {
+ {
path: "mergeUndoDeltas",
+ label: nls("options.merge-undo-deltas", "Merge Undo Deltas"),
items: [
- { caption : "Always", value : "always" },
- { caption : "Never", value : "false" },
- { caption : "Timed", value : "true" }
+ {
+ caption: nls("options.merge-undo-deltas.always", "Always"),
+ value: "always"
+ },
+ {
+ caption: nls("options.merge-undo-deltas.never", "Never"),
+ value: "false"
+ },
+ {
+ caption: nls("options.merge-undo-deltas.timed", "Timed"),
+ value: "true"
+ }
]
},
- "Elastic Tabstops": {
- path: "useElasticTabstops"
+ {
+ path: "useElasticTabstops",
+ label: nls("options.use-elastic-tabstops", "Elastic Tabstops")
},
- "Incremental Search": {
- path: "useIncrementalSearch"
+ {
+ path: "useIncrementalSearch",
+ label: nls("options.use-incremental-search", "Incremental Search")
},
- "Read-only": {
- path: "readOnly"
+ {
+ path: "readOnly",
+ label: nls("options.read-only", "Read-only")
},
- "Copy without selection": {
- path: "copyWithEmptySelection"
+ {
+ path: "copyWithEmptySelection",
+ label: nls("options.copy-with-empty-selection", "Copy without selection")
},
- "Live Autocompletion": {
- path: "enableLiveAutocompletion"
+ {
+ path: "enableLiveAutocompletion",
+ label: nls("options.enable-live-autocompletion", "Live Autocompletion")
},
- "Custom scrollbar": {
- path: "customScrollbar"
+ {
+ path: "customScrollbar",
+ label: nls("options.custom-scrollbar", "Custom scrollbar")
},
- "Use SVG gutter icons": {
- path: "useSvgGutterIcons"
+ {
+ path: "useSvgGutterIcons",
+ label: nls("options.use-svg-gutter-icons", "Use SVG gutter icons")
},
- "Annotations for folded lines": {
- path: "showFoldedAnnotations"
+ {
+ path: "showFoldedAnnotations",
+ label: nls("options.show-folded-annotations", "Annotations for folded lines")
},
- "Keyboard Accessibility Mode": {
- path: "enableKeyboardAccessibility"
+ {
+ path: "enableKeyboardAccessibility",
+ label: nls("options.enable-keyboard-accessibility", "Keyboard Accessibility Mode")
},
- "Gutter tooltip follows mouse": {
+ {
path: "tooltipFollowsMouse",
+ label: nls("options.tooltip-follows-mouse", "Gutter tooltip follows mouse"),
defaultValue: true
}
- }
+ ]
};
class OptionPanel {
@@ -228,20 +359,20 @@ class OptionPanel {
}
add(config) {
- if (config.Main)
- oop.mixin(optionGroups.Main, config.Main);
- if (config.More)
- oop.mixin(optionGroups.More, config.More);
+ if (config.main)
+ oop.mixin(optionGroups.main, config.main);
+ if (config.more)
+ oop.mixin(optionGroups.more, config.more);
}
render() {
this.container.innerHTML = "";
buildDom(["table", {role: "presentation", id: "controls"},
- this.renderOptionGroup(optionGroups.Main),
+ this.renderOptionGroup(optionGroups.main),
["tr", null, ["td", {colspan: 2},
["table", {role: "presentation", id: "more-controls"},
- this.renderOptionGroup(optionGroups.More)
+ this.renderOptionGroup(optionGroups.more)
]
]],
["tr", null, ["td", {colspan: 2}, "version " + config.version]]
@@ -249,17 +380,8 @@ class OptionPanel {
}
renderOptionGroup(group) {
- return Object.keys(group).map(function(key, i) {
- var item = group[key];
- if (!item.position)
- item.position = i / 10000;
- if (!item.label)
- item.label = key;
- return item;
- }).sort(function(a, b) {
- return a.position - b.position;
- }).map(function(item) {
- return this.renderOption(item.label, item);
+ return group.map(function(item) {
+ return this.renderOption(item);
}, this);
}
@@ -330,11 +452,11 @@ class OptionPanel {
});
};
- var items = Array.isArray(option.items)
- ? buildItems(option.items)
- : Object.keys(option.items).map(function(key) {
- return ["optgroup", {"label": key}, buildItems(option.items[key])];
- });
+ var items = option.items[0].label
+ ? option.items.map(function(group) {
+ return ["optgroup", {label: group.label}, buildItems(group.items)];
+ })
+ : buildItems(option.items);
control = ["select", { id: key, value: value, onchange: function() {
self.setOption(option, this.value);
} }, items];
@@ -359,16 +481,17 @@ class OptionPanel {
* @param key
* @param option
*/
- renderOption(key, option) {
+ renderOption(option) {
if (option.path && !option.onchange && !this.editor.$options[option.path])
return;
var path = Array.isArray(option) ? option[0].path : option.path;
+ var label = Array.isArray(option) ? option[0].label : option.label;
this.options[path] = option;
var safeKey = "-" + path;
var safeId = path + "-label";
var control = this.renderOptionControl(safeKey, option);
return ["tr", {class: "ace_optionsMenuEntry"}, ["td",
- ["label", {for: safeKey, id: safeId}, key]
+ ["label", {for: safeKey, id: safeId}, label]
], ["td", control]];
}
diff --git a/src/lib/default_english_messages.js b/src/lib/default_english_messages.js
index c112868f8b5..aea8ea214ff 100644
--- a/src/lib/default_english_messages.js
+++ b/src/lib/default_english_messages.js
@@ -38,7 +38,70 @@ var defaultEnglishMessages = {
"gutter-tooltip.aria-label.warning.singular": "warning",
"gutter-tooltip.aria-label.warning.plural": "warnings",
"gutter-tooltip.aria-label.info.singular": "information message",
- "gutter-tooltip.aria-label.info.plural": "information messages"
+ "gutter-tooltip.aria-label.info.plural": "information messages",
+ "options.mode": "Mode",
+ "options.theme": "Theme",
+ "options.theme.bright": "Bright",
+ "options.theme.dark": "Dark",
+ "options.keyboard-handler": "Keybinding",
+ "options.font-size": "Font Size",
+ "options.font-size.px": "$0px",
+ "options.wrap": "Soft Wrap",
+ "options.wrap.off": "Off",
+ "options.wrap.view": "View",
+ "options.wrap.margin": "margin",
+ "options.cursor-style": "Cursor Style",
+ "options.cursor-style.slim": "Slim",
+ "options.cursor-style.smooth": "Smooth",
+ "options.cursor-style.smooth-slim": "Smooth And Slim",
+ "options.cursor-style.wide": "Wide",
+ "options.fold-style": "Folding",
+ "options.fold-style.manual": "Manual",
+ "options.fold-style.mark-begin": "Mark begin",
+ "options.fold-style.mark-begin-end": "Mark begin and end",
+ "options.use-soft-tabs": "Soft Tabs",
+ "options.tab-size": "Tab Size",
+ "options.scroll-past-end": "Overscroll",
+ "options.scroll-past-end.none": "None",
+ "options.scroll-past-end.half": "Half",
+ "options.scroll-past-end.full": "Full",
+ "options.navigate-within-soft-tabs": "Atomic soft tabs",
+ "options.behaviours-enabled": "Enable Behaviours",
+ "options.wrap-behaviours-enabled": "Wrap with quotes",
+ "options.enable-auto-indent": "Enable Auto Indent",
+ "options.selection-style": "Full Line Selection",
+ "options.highlight-active-line": "Highlight Active Line",
+ "options.show-invisibles": "Show Invisibles",
+ "options.display-indent-guides": "Show Indent Guides",
+ "options.highlight-indent-guides": "Highlight Indent Guides",
+ "options.h-scroll-bar-always-visible": "Persistent HScrollbar",
+ "options.v-scroll-bar-always-visible": "Persistent VScrollbar",
+ "options.animated-scroll": "Animate scrolling",
+ "options.show-gutter": "Show Gutter",
+ "options.show-line-numbers": "Show Line Numbers",
+ "options.relative-line-numbers": "Relative Line Numbers",
+ "options.fixed-width-gutter": "Fixed Gutter Width",
+ "options.show-print-margin": "Show Print Margin",
+ "options.show-print-margin.print-margin-column": "Print Margin",
+ "options.indented-soft-wrap": "Indented Soft Wrap",
+ "options.highlight-selected-word": "Highlight selected word",
+ "options.fade-fold-widgets": "Fade Fold Widgets",
+ "options.use-textarea-for-ime": "Use textarea for IME",
+ "options.merge-undo-deltas": "Merge Undo Deltas",
+ "options.merge-undo-deltas.always": "Always",
+ "options.merge-undo-deltas.never": "Never",
+ "options.merge-undo-deltas.timed": "Timed",
+ "options.use-elastic-tabstops": "Elastic Tabstops",
+ "options.use-incremental-search": "Incremental Search",
+ "options.read-only": "Read-only",
+ "options.copy-with-empty-selection": "Copy without selection",
+ "options.enable-live-autocompletion": "Live Autocompletion",
+ "options.custom-scrollbar": "Custom scrollbar",
+ "options.use-svg-gutter-icons": "Use SVG gutter icons",
+ "options.show-folded-annotations": "Annotations for folded lines",
+ "options.enable-keyboard-accessibility": "Keyboard Accessibility Mode",
+ "options.tooltip-follows-mouse": "Gutter tooltip follows mouse",
+ "keybinding-menu.head": "Keyboard Shortcuts"
}
-exports.defaultEnglishMessages = defaultEnglishMessages;
\ No newline at end of file
+exports.defaultEnglishMessages = defaultEnglishMessages;