Create list of locales from the localization data, and allow data to specify menu title. Update menu when new translations are added. Allow loading of third-party translation data by URL. Fix transaltion files to use addTranslation().
This commit is contained in:
parent
c4d47bb10d
commit
f23cb8a6b2
|
@ -1058,8 +1058,8 @@ MathJax.Localization = {
|
||||||
locale: "en",
|
locale: "en",
|
||||||
directory: "[MathJax]/localization",
|
directory: "[MathJax]/localization",
|
||||||
strings: {
|
strings: {
|
||||||
en: {isLoaded: true}, // nothing needs to be loaded for this
|
en: {isLoaded: true, menuTitle: "English"}, // nothing needs to be loaded for this
|
||||||
fr: {}
|
fr: {menuTitle: "French"}
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1302,6 +1302,7 @@ MathJax.Localization = {
|
||||||
data = data.domains[domain];
|
data = data.domains[domain];
|
||||||
}
|
}
|
||||||
MathJax.Hub.Insert(data,definition);
|
MathJax.Hub.Insert(data,definition);
|
||||||
|
if (!domain && MathJax.Menu) {MathJax.Menu.CreateLocaleMenu()}
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -889,7 +889,21 @@
|
||||||
MathJax.Localization.setLocale(CONFIG.settings.locale);
|
MathJax.Localization.setLocale(CONFIG.settings.locale);
|
||||||
// FIXME: Rerender the page? (To force error messages to change?)
|
// FIXME: Rerender the page? (To force error messages to change?)
|
||||||
// Just rerender error messages?
|
// Just rerender error messages?
|
||||||
|
};
|
||||||
|
MENU.LoadLocale = function () {
|
||||||
|
var url = prompt(_("LoadURL","Load translation data from this URL:"));
|
||||||
|
if (url) {
|
||||||
|
if (!url.match(/\.js$/)) {
|
||||||
|
alert(_("BadURL",
|
||||||
|
"The URL should be for a javascript file that defines MathJax translation data. " +
|
||||||
|
"Javascript file names should end with '.js'"
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
AJAX.Require(url,function (status) {
|
||||||
|
if (status != AJAX.STATUS.OK) {alert(_("BadData","Failed to load translation data from %1",url))}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle setting MathPlayer events
|
* Handle setting MathPlayer events
|
||||||
|
@ -1033,7 +1047,8 @@
|
||||||
ITEM.RULE().With({hidden:!CONFIG.showLocale, name:["","locale_rule"]}),
|
ITEM.RULE().With({hidden:!CONFIG.showLocale, name:["","locale_rule"]}),
|
||||||
ITEM.SUBMENU(["Locale","Locale"], {hidden:!CONFIG.showLocale},
|
ITEM.SUBMENU(["Locale","Locale"], {hidden:!CONFIG.showLocale},
|
||||||
ITEM.RADIO("en", "locale", {action: MENU.Locale}),
|
ITEM.RADIO("en", "locale", {action: MENU.Locale}),
|
||||||
ITEM.RADIO("fr", "locale", {action: MENU.Locale})
|
ITEM.RULE(),
|
||||||
|
ITEM.COMMAND(["LoadLocale","Load from URL ..."], MENU.LoadLocale)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
ITEM.RULE(),
|
ITEM.RULE(),
|
||||||
|
@ -1057,6 +1072,32 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// Creates the locale menu from the list of locales in MathJax.Localization.strings
|
||||||
|
//
|
||||||
|
MENU.CreateLocaleMenu = function () {
|
||||||
|
var menu = MENU.menu.Find("Math Settings","Locale").menu, items = menu.items;
|
||||||
|
//
|
||||||
|
// Get the names of the languages and sort them
|
||||||
|
//
|
||||||
|
var locales = [], LOCALE = MathJax.Localization.strings;
|
||||||
|
for (var id in LOCALE) {if (LOCALE.hasOwnProperty(id)) {locales.push(id)}}
|
||||||
|
locales = locales.sort(); menu.items = [];
|
||||||
|
//
|
||||||
|
// Add a menu item for each
|
||||||
|
//
|
||||||
|
for (var i = 0, m = locales.length; i < m; i++) {
|
||||||
|
var title = LOCALE[locales[i]].menuTitle;
|
||||||
|
if (title) {title += " ("+locales[i]+")"} else {title = locales[i]}
|
||||||
|
menu.items.push(ITEM.RADIO([locales[i],title],"locale",{action:MENU.Locale}));
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Add the rule and "Load from URL" items
|
||||||
|
//
|
||||||
|
menu.items.push(items[items.length-2],items[items.length-1]);
|
||||||
|
};
|
||||||
|
MENU.CreateLocaleMenu();
|
||||||
|
|
||||||
MENU.showRenderer = function (show) {
|
MENU.showRenderer = function (show) {
|
||||||
MENU.cookie.showRenderer = CONFIG.showRenderer = show; MENU.saveCookie();
|
MENU.cookie.showRenderer = CONFIG.showRenderer = show; MENU.saveCookie();
|
||||||
MENU.menu.Find("Math Settings","Math Renderer").hidden = !show;
|
MENU.menu.Find("Math Settings","Math Renderer").hidden = !show;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
MathJax.Localization.addTranslation("fr","FontWarnings",{
|
||||||
FontWarnings: {
|
|
||||||
isLoaded: true,
|
isLoaded: true,
|
||||||
strings: {
|
strings: {
|
||||||
|
|
||||||
|
@ -47,7 +46,6 @@ MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
||||||
TeXfonts:
|
TeXfonts:
|
||||||
"Polices TeX de MathJax"
|
"Polices TeX de MathJax"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
MathJax.Ajax.loadComplete("[MathJax]/localization/fr/FontWarnings.js");
|
MathJax.Ajax.loadComplete("[MathJax]/localization/fr/FontWarnings.js");
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
MathJax.Localization.addTranslation("fr","HTML-CSS",{
|
||||||
"HTML-CSS": {
|
|
||||||
isLoaded: true,
|
isLoaded: true,
|
||||||
strings: {
|
strings: {
|
||||||
|
|
||||||
LoadWebFont: "Téléchargement la police Web %1",
|
LoadWebFont:
|
||||||
|
"Téléchargement la police Web %1",
|
||||||
|
|
||||||
CantLoadWebFont: "Impossible de télécharcharger la police Web %1",
|
CantLoadWebFont:
|
||||||
|
"Impossible de télécharcharger la police Web %1",
|
||||||
|
|
||||||
FirefoxCantLoadWebFont:
|
FirefoxCantLoadWebFont:
|
||||||
"Firefox ne peut télécharger les polices Web à partir d'un hôte "+
|
"Firefox ne peut télécharger les polices Web à partir d'un hôte "+
|
||||||
|
@ -19,8 +20,6 @@ MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
||||||
"utilisées à la place"
|
"utilisées à la place"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
MathJax.Ajax.loadComplete("[MathJax]/localization/fr/HTML-CSS.js");
|
MathJax.Ajax.loadComplete("[MathJax]/localization/fr/HTML-CSS.js");
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
MathJax.Localization.addTranslation("fr","MathML",{
|
||||||
MathML: {
|
|
||||||
isLoaded: true,
|
isLoaded: true,
|
||||||
strings: {
|
strings: {
|
||||||
|
|
||||||
|
@ -43,7 +42,6 @@ MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
||||||
"Le code MathML doit être formé d'un élément <math> et non un élément %1"
|
"Le code MathML doit être formé d'un élément <math> et non un élément %1"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
MathJax.Ajax.loadComplete("[MathJax]/localization/fr/MathML.js");
|
MathJax.Ajax.loadComplete("[MathJax]/localization/fr/MathML.js");
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
MathJax.Localization.addTranslation("fr","MathMenu",{
|
||||||
MathMenu: {
|
|
||||||
isLoaded: true,
|
isLoaded: true,
|
||||||
strings: {
|
strings: {
|
||||||
|
|
||||||
|
@ -111,7 +110,7 @@ MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
||||||
|
|
||||||
EqSource:
|
EqSource:
|
||||||
"Source de l'équation MathJax"
|
"Source de l'équation MathJax"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
MathJax.Localization.addTranslation("fr","TeX",{
|
||||||
TeX: {
|
|
||||||
isLoaded: true,
|
isLoaded: true,
|
||||||
strings: {
|
strings: {
|
||||||
|
|
||||||
ExtraOpenMissingClose:
|
ExtraOpenMissingClose:
|
||||||
"Accolade ouvrant manquante ou accolade fermante non attendue",
|
"Accolade ouvrant manquante ou accolade fermante non attendue",
|
||||||
|
|
||||||
|
@ -106,12 +106,10 @@ MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
||||||
"Argument manquant pour la commande %1",
|
"Argument manquant pour la commande %1",
|
||||||
|
|
||||||
ExtraAlignTab:
|
ExtraAlignTab:
|
||||||
"Tabulation d'alignement non attendu pour le texte de la commande "+
|
"Tabulation d'alignement non attendu pour le texte de la commande \\cases",
|
||||||
"\\cases",
|
|
||||||
|
|
||||||
BracketMustBeDimension:
|
BracketMustBeDimension:
|
||||||
"L'argument entre crochets de la commande %1 doit être une "+
|
"L'argument entre crochets de la commande %1 doit être une dimension",
|
||||||
"dimension",
|
|
||||||
|
|
||||||
InvalidEnv:
|
InvalidEnv:
|
||||||
"Nom d'environnement '%1' non valide",
|
"Nom d'environnement '%1' non valide",
|
||||||
|
@ -126,8 +124,7 @@ MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
||||||
"Accolade fermante non attendue avant le crochet fermant.",
|
"Accolade fermante non attendue avant le crochet fermant.",
|
||||||
|
|
||||||
MissingCloseBracket:
|
MissingCloseBracket:
|
||||||
"Impossible de trouver le crochet fermant pour l'argument de la "+
|
"Impossible de trouver le crochet fermant pour l'argument de la commande %1",
|
||||||
"commande %1",
|
|
||||||
|
|
||||||
MissingOrUnrecognizedDelim:
|
MissingOrUnrecognizedDelim:
|
||||||
"Délimiteur manquant ou non reconnu pour la commande %1",
|
"Délimiteur manquant ou non reconnu pour la commande %1",
|
||||||
|
@ -247,7 +244,7 @@ MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
||||||
|
|
||||||
RunawayArgument:
|
RunawayArgument:
|
||||||
"Argument manquant pour la commande %1?"
|
"Argument manquant pour la commande %1?"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
MathJax.Hub.Insert(MathJax.Localization.strings.fr,{
|
MathJax.Localization.addTranslation("fr",null,{
|
||||||
isLoaded: true,
|
isLoaded: true,
|
||||||
domains: {
|
domains: {
|
||||||
"_": {
|
"_": {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
MathJax.Hub.Insert(MathJax.Localization.strings.fr.domains,{
|
MathJax.Localization.addTranslation("fr","v1.0-warning",{
|
||||||
"v1.0-warning": {
|
|
||||||
isLoaded: true,
|
isLoaded: true,
|
||||||
strings: {
|
strings: {
|
||||||
|
|
||||||
MissingConfig:
|
MissingConfig:
|
||||||
"MathJax ne charge plus de fichier de configuration par défaut; "+
|
"MathJax ne charge plus de fichier de configuration par défaut; "+
|
||||||
"vous devez spécifier ces fichiers de façons explicites. Cette "+
|
"vous devez spécifier ces fichiers de façons explicites. Cette "+
|
||||||
"page semble utiliser l'ancien fichier de configuration par "+
|
"page semble utiliser l'ancien fichier de configuration par "+
|
||||||
"défaut %1 and doit donc être mise à jour. Ceci est expliqué "+
|
"défaut %1 and doit donc être mise à jour. Ceci est expliqué "+
|
||||||
"en détails à l'addresse suivante: %2"
|
"en détails à l'addresse suivante: %2"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user