From f81e9d847d4ad57d38edd7b511d9aca6a2de645c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Fri, 2 Aug 2013 14:35:27 +0200 Subject: [PATCH 1/2] Add test/localization.html. Fix isssue #529. --- test/localization.html | 335 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 test/localization.html diff --git a/test/localization.html b/test/localization.html new file mode 100644 index 000000000..fb2a32e95 --- /dev/null +++ b/test/localization.html @@ -0,0 +1,335 @@ + + + +Localization + + + + + + + + +

MathJax Localization

+ +
+

+ Language: + +

+
+ + + + + From f42ac43cd47e35e06f195c96d179701feaed02d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Thu, 8 Aug 2013 10:30:36 +0200 Subject: [PATCH 2/2] Fix more localization errors and update the test/localization.html accordingly ; Also force all menu items to display in the test. #529 --- test/localization.html | 73 +++++++++++++-------------- unpacked/extensions/TeX/newcommand.js | 4 +- unpacked/jax/input/TeX/jax.js | 5 +- 3 files changed, 39 insertions(+), 43 deletions(-) diff --git a/test/localization.html b/test/localization.html index fb2a32e95..1fc54c21c 100644 --- a/test/localization.html +++ b/test/localization.html @@ -48,16 +48,7 @@ /* set the currentLocale */ MathJax.Hub.Config({ - menuSettings: { locale: currentLocale }, - MathMenu: { - showRenderer: true, - showMathPlayer: true, - showFontMenu: true, - showContext: true, - showDiscoverable: true, - showLocale: true, - showLocaleURL: true - } + menuSettings: { locale: currentLocale } }); var menu = MathJax.HTML.Cookie.Get("menu"); menu.locale = currentLocale; @@ -102,14 +93,23 @@ message += MathJax.Localization._(["MathMenu","SwitchAnyway"], _M_); alert(message); } + function showAllItems(aMenu) + { + for (var i = 0, m = aMenu.items.length; i < m; i++) { + var item = aMenu.items[i]; + item.hidden = false; + item.disabled = false; + if (item.menu) showAllItems(item.menu); + } + } + MathJax.Hub.Register.StartupHook("MathMenu Ready", function () { + showAllItems(MathJax.Menu.menu); + }); - /* Simulate some error messages... */ + /* These MathML parsing errors happen only in rare cases, so we fake them... */ MathJax.Hub.Queue(function() { document.getElementById('ErrorParsingMathML').innerHTML = MathJax.Localization._(['MathML','ErrorParsingMathML'], _M_); document.getElementById('MathMLSingleElement').innerHTML = MathJax.Localization._(['MathML','MathMLSingleElement'], _M_); - document.getElementById('MissingOpenForSub').innerHTML = MathJax.Localization._(['TeX','MissingOpenForSub'], _M_); - document.getElementById('MissingBoxFor').innerHTML = MathJax.Localization._(['TeX','MissingBoxFor'], _M_, 'COMMANDNAME'); - document.getElementById('ExtraClose').innerHTML = MathJax.Localization._(['TeX','ExtraClose'], _M_); }); @@ -152,14 +152,10 @@
  • CantCreateXMLParser:
  • UnknownNodeType:
  • UnexpectedTextNode: UNEXPECTEDTEXT
  • -
  • ErrorParsingMathML: - - +
  • ErrorParsingMathML:
  • ParsingError:
  • -
  • MathMLSingleElement: - - +
  • MathMLSingleElement:
  • MathMLRootElement:
  • @@ -173,14 +169,25 @@
  • MathMenu: -
    • Right click on one these formulas to display the menu:
        -
      • TeX: \( x \)
      • -
      • AsciiMath: `x`
      • -
      • MathML: x
      • -
      • MathProcessingError:
      • +
      • TeX: \( x \)
      • +
      • AsciiMath: `x`
      • +
      • MathML: x
      • +
      • MathProcessingError:
      • +
      • Annotation: + + + x + x (TeX) + x (StarMath) + x (Maple) + x + + + +
    • About Box:
    • @@ -221,18 +228,12 @@
    • MissingScript: \( x^ \)
    • ExtraLeftMissingRight: \( \left( \)
    • Misplaced: \( & \)
    • -
    • MissingOpenForSub: - - -
    • +
    • MissingOpenForSub: \( x__ \)
    • MissingOpenForSup: \( x^^ \)
    • AmbiguousUseOf: \( x \over y \over z \)
    • EnvBadEnd: \( \begin{aligned} \end{eqarray} \)
    • EnvMissingEnd: \( \begin{aligned} \)
    • -
    • MissingBoxFor: - - -
    • +
    • MissingBoxFor: \( \raise 1pt \)
    • MissingCloseBrace: \( \array{ \)
    • UndefinedControlSequence: \( \UNDEFINED \)
    • DoubleExponent: \( x^3^2 \)
    • @@ -254,10 +255,6 @@
    • BracketMustBeDimension: \(\begin{array} x \\[INVALID] y \end{array}\)
    • InvalidEnv: \( \begin{_INVALID_} \end{_INVALID_} \)
    • UnknownEnv: \( \begin{UNKNOWN} \end{UNKNOWN} \)
    • -
    • ExtraClose: - - -
    • ExtraCloseLooking: \( \sqrt[}]x \)
    • MissingCloseBracket: \( \sqrt[ \)
    • MissingOrUnrecognizedDelim: \( \left \)
    • @@ -319,7 +316,7 @@
      • IllegalControlSequenceName: \( \newcommand{_INVALID_}{} \)
      • IllegalParamNumber: \( \newcommand{mycommand}[INVALID]{} \)
      • -
      • DoubleBackSlash: \( \let INVALID \)
      • +
      • MissingCS: \( \let INVALID \)
      • CantUseHash2: \( \def\mycommand#A \)
      • SequentialParam: \( \def\mycommand#2#1 \)
      • MissingReplacementString: \( \def\mycommand \)
      • diff --git a/unpacked/extensions/TeX/newcommand.js b/unpacked/extensions/TeX/newcommand.js index 8c25ca60c..7f25e0aa6 100644 --- a/unpacked/extensions/TeX/newcommand.js +++ b/unpacked/extensions/TeX/newcommand.js @@ -141,8 +141,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { GetCSname: function (cmd) { var c = this.GetNext(); if (c !== "\\") { - TEX.Error(["DoubleBackSlash", - "\\ must be followed by a control sequence"]) + TEX.Error(["MissingCS", + "%1 must be followed by a control sequence", cmd]) } var cs = this.trimSpaces(this.GetArgument(cmd)); return cs.substr(1); diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index 8d99241dd..cc75287b4 100644 --- a/unpacked/jax/input/TeX/jax.js +++ b/unpacked/jax/input/TeX/jax.js @@ -158,7 +158,7 @@ type: "subsup", stopError: /*_()*/ ["MissingScript","Missing superscript or subscript argument"], supError: /*_()*/ ["MissingOpenForSup","Missing open brace for superscript"], - subError: /*_()*/ ["MissingOpenForSup","Missing open brace for subscript"], + subError: /*_()*/ ["MissingOpenForSub","Missing open brace for subscript"], checkItem: function (item) { if (item.type === "open" || item.type === "left") {return true} if (item.type === "mml") { @@ -240,7 +240,7 @@ STACKITEM.position = STACKITEM.Subclass({ type: "position", checkItem: function (item) { - if (item.isClose) {TEX.Error(["MissingBoxFor","Missing box for %1",name])} + if (item.isClose) {TEX.Error(["MissingBoxFor","Missing box for %1",this.name])} if (item.isNotStack) { var mml = item.mmlData(); switch (this.move) { @@ -1848,7 +1848,6 @@ case '\\': this.i++; break; case '{': parens++; break; case '}': - if (parens == 0) {TEX.Error(["ExtraClose","Extra close brace"])} if (--parens == 0) {return this.string.slice(j,this.i-1)} break; }