Add localization submenu, and set locale via menu. Allow locale= configuration parameter on script to load MathJax.js. Load MathMenu domain automatically (so it is ready when needed).
This commit is contained in:
parent
9ee925dfbb
commit
c9578c7a0b
|
@ -1055,7 +1055,7 @@ MathJax.HTML = {
|
||||||
|
|
||||||
MathJax.Localization = {
|
MathJax.Localization = {
|
||||||
|
|
||||||
locale: "fr",
|
locale: "en",
|
||||||
directory: "[MathJax]/localization",
|
directory: "[MathJax]/localization",
|
||||||
strings: {
|
strings: {
|
||||||
en: {isLoaded: true}, // nothing needs to be loaded for this
|
en: {isLoaded: true}, // nothing needs to be loaded for this
|
||||||
|
@ -1283,6 +1283,7 @@ MathJax.Localization = {
|
||||||
setLocale: function(locale) {
|
setLocale: function(locale) {
|
||||||
// don't set it if there isn't a definition for it
|
// don't set it if there isn't a definition for it
|
||||||
if (this.strings[locale]) {this.locale = locale}
|
if (this.strings[locale]) {this.locale = locale}
|
||||||
|
if (MathJax.Menu) {this.loadDomain("MathMenu")}
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1634,6 +1635,7 @@ MathJax.Hub = {
|
||||||
renderer: "", // set when Jax are loaded
|
renderer: "", // set when Jax are loaded
|
||||||
font: "Auto", // what font HTML-CSS should use
|
font: "Auto", // what font HTML-CSS should use
|
||||||
context: "MathJax", // or "Browser" for pass-through to browser menu
|
context: "MathJax", // or "Browser" for pass-through to browser menu
|
||||||
|
locale: "en", // the language to use for messages
|
||||||
mpContext: false, // true means pass menu events to MathPlayer in IE
|
mpContext: false, // true means pass menu events to MathPlayer in IE
|
||||||
mpMouse: false, // true means pass mouse events to MathPlayer in IE
|
mpMouse: false, // true means pass mouse events to MathPlayer in IE
|
||||||
texHints: true // include class names for TeXAtom elements
|
texHints: true // include class names for TeXAtom elements
|
||||||
|
@ -2131,15 +2133,23 @@ MathJax.Hub.Startup = {
|
||||||
Config: function () {
|
Config: function () {
|
||||||
this.queue.Push(["Post",this.signal,"Begin Config"]);
|
this.queue.Push(["Post",this.signal,"Begin Config"]);
|
||||||
//
|
//
|
||||||
|
// If a locale is given as a parameter,
|
||||||
|
// set the locale and the default menu value for the locale
|
||||||
|
//
|
||||||
|
if (this.params.locale) {
|
||||||
|
MathJax.Localization.locale = this.params.locale;
|
||||||
|
MathJax.Hub.config.menuSettings.locale = this.params.locale;
|
||||||
|
}
|
||||||
|
//
|
||||||
// Check for user cookie configuration
|
// Check for user cookie configuration
|
||||||
//
|
//
|
||||||
var user = MathJax.HTML.Cookie.Get("user");
|
var user = MathJax.HTML.Cookie.Get("user");
|
||||||
if (user.URL || user.Config) {
|
if (user.URL || user.Config) {
|
||||||
if (confirm(
|
if (confirm(
|
||||||
MathJax.Localization._("CookieConfig",
|
MathJax.Localization._("CookieConfig",
|
||||||
"MathJax has found a user-configuration cookie that includes code to"+
|
"MathJax has found a user-configuration cookie that includes code to "+
|
||||||
"be run. Do you want to run it?\n\n"+
|
"be run. Do you want to run it?\n\n"+
|
||||||
"(You should press Cancel unless you set up the cookie yourself.)")
|
"(You should press Cancel unless you set up the cookie yourself.)")
|
||||||
)) {
|
)) {
|
||||||
if (user.URL) {this.queue.Push(["Require",MathJax.Ajax,user.URL])}
|
if (user.URL) {this.queue.Push(["Require",MathJax.Ajax,user.URL])}
|
||||||
if (user.Config) {this.queue.Push(new Function(user.Config))}
|
if (user.Config) {this.queue.Push(new Function(user.Config))}
|
||||||
|
@ -2207,6 +2217,7 @@ MathJax.Hub.Startup = {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read cookie and set up menu defaults
|
// Read cookie and set up menu defaults
|
||||||
|
// (set the locale according to the cookie)
|
||||||
// (adjust the jax to accommodate renderer preferences)
|
// (adjust the jax to accommodate renderer preferences)
|
||||||
//
|
//
|
||||||
Cookie: function () {
|
Cookie: function () {
|
||||||
|
@ -2214,6 +2225,8 @@ MathJax.Hub.Startup = {
|
||||||
["Post",this.signal,"Begin Cookie"],
|
["Post",this.signal,"Begin Cookie"],
|
||||||
["Get",MathJax.HTML.Cookie,"menu",MathJax.Hub.config.menuSettings],
|
["Get",MathJax.HTML.Cookie,"menu",MathJax.Hub.config.menuSettings],
|
||||||
[function (config) {
|
[function (config) {
|
||||||
|
if (config.menuSettings.locale)
|
||||||
|
{MathJax.Localization.locale = config.menuSettings.locale}
|
||||||
var renderer = config.menuSettings.renderer, jax = config.jax;
|
var renderer = config.menuSettings.renderer, jax = config.jax;
|
||||||
if (renderer) {
|
if (renderer) {
|
||||||
var name = "output/"+renderer; jax.sort();
|
var name = "output/"+renderer; jax.sort();
|
||||||
|
@ -2332,7 +2345,16 @@ MathJax.Hub.Startup = {
|
||||||
MenuZoom: function () {
|
MenuZoom: function () {
|
||||||
if (!MathJax.Extension.MathMenu) {
|
if (!MathJax.Extension.MathMenu) {
|
||||||
setTimeout(
|
setTimeout(
|
||||||
MathJax.Callback(["Require",MathJax.Ajax,"[MathJax]/extensions/MathMenu.js",{}]),
|
function () {
|
||||||
|
MathJax.Callback.Queue(
|
||||||
|
["Require",MathJax.Ajax,"[MathJax]/extensions/MathMenu.js",{}],
|
||||||
|
["loadDomain",MathJax.Localization,"MathMenu"]
|
||||||
|
)
|
||||||
|
},1000
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
setTimeout(
|
||||||
|
MathJax.Callback(["loadDomain",MathJax.Localization,"MathMenu"]),
|
||||||
1000
|
1000
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
showFontMenu: false, // show the "Font Preference" menu?
|
showFontMenu: false, // show the "Font Preference" menu?
|
||||||
showContext: false, // show the "Context Menu" menu?
|
showContext: false, // show the "Context Menu" menu?
|
||||||
showDiscoverable: false, // show the "Discoverable" menu?
|
showDiscoverable: false, // show the "Discoverable" menu?
|
||||||
|
showLocale: true, // show the "Locale" menu?
|
||||||
|
|
||||||
windowSettings: { // for source window
|
windowSettings: { // for source window
|
||||||
status: "no", toolbar: "no", locationbar: "no", menubar: "no",
|
status: "no", toolbar: "no", locationbar: "no", menubar: "no",
|
||||||
|
@ -881,6 +882,15 @@
|
||||||
document.location.reload();
|
document.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle selection of locale
|
||||||
|
*/
|
||||||
|
MENU.Locale = function () {
|
||||||
|
MathJax.Localization.setLocale(CONFIG.settings.locale);
|
||||||
|
// FIXME: Rerender the page? (To force error messages to change?)
|
||||||
|
// Just rerender error messages?
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle setting MathPlayer events
|
* Handle setting MathPlayer events
|
||||||
*/
|
*/
|
||||||
|
@ -1019,7 +1029,12 @@
|
||||||
),
|
),
|
||||||
ITEM.COMMAND(["Scale","Scale All Math ..."],MENU.Scale),
|
ITEM.COMMAND(["Scale","Scale All Math ..."],MENU.Scale),
|
||||||
ITEM.RULE().With({hidden:!CONFIG.showDiscoverable, name:["","discover_rule"]}),
|
ITEM.RULE().With({hidden:!CONFIG.showDiscoverable, name:["","discover_rule"]}),
|
||||||
ITEM.CHECKBOX(["Discoverable","Highlight on Hover"], "discoverable", {hidden:!CONFIG.showDiscoverable})
|
ITEM.CHECKBOX(["Discoverable","Highlight on Hover"], "discoverable", {hidden:!CONFIG.showDiscoverable}),
|
||||||
|
ITEM.RULE().With({hidden:!CONFIG.showLocale, name:["","locale_rule"]}),
|
||||||
|
ITEM.SUBMENU(["Locale","Locale"], {hidden:!CONFIG.showLocale},
|
||||||
|
ITEM.RADIO("en", "locale", {action: MENU.Locale}),
|
||||||
|
ITEM.RADIO("fr", "locale", {action: MENU.Locale})
|
||||||
|
)
|
||||||
),
|
),
|
||||||
ITEM.RULE(),
|
ITEM.RULE(),
|
||||||
ITEM.COMMAND(["About","About MathJax"],MENU.About),
|
ITEM.COMMAND(["About","About MathJax"],MENU.About),
|
||||||
|
@ -1059,10 +1074,15 @@
|
||||||
MENU.menu.Find("Math Settings","Contextual Menu").hidden = !show;
|
MENU.menu.Find("Math Settings","Contextual Menu").hidden = !show;
|
||||||
};
|
};
|
||||||
MENU.showDiscoverable = function (show) {
|
MENU.showDiscoverable = function (show) {
|
||||||
MENU.cookie.showContext = CONFIG.showContext = show; MENU.saveCookie();
|
MENU.cookie.showDiscoverable = CONFIG.showDiscoverable = show; MENU.saveCookie();
|
||||||
MENU.menu.Find("Math Settings","Highlight on Hover").hidden = !show;
|
MENU.menu.Find("Math Settings","Highlight on Hover").hidden = !show;
|
||||||
MENU.menu.Find("Math Settings","discover_rule").hidden = !show;
|
MENU.menu.Find("Math Settings","discover_rule").hidden = !show;
|
||||||
};
|
};
|
||||||
|
MENU.showLocale = function (show) {
|
||||||
|
MENU.cookie.showLocale = CONFIG.showLocale = show; MENU.saveCookie();
|
||||||
|
MENU.menu.Find("Math Settings","Locale").hidden = !show;
|
||||||
|
MENU.menu.Find("Math Settings","locale_rule").hidden = !show;
|
||||||
|
};
|
||||||
|
|
||||||
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
||||||
if (!MathJax.OutputJax["HTML-CSS"].config.imageFont)
|
if (!MathJax.OutputJax["HTML-CSS"].config.imageFont)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user