/usr/share/doc/libjs-mathjax-doc/html/reference/localization-strings.html is in libjs-mathjax-doc 2.7+20171212-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | <!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Localization Strings — MathJax 2.7 documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="MathJax 2.7 documentation" href="../index.html"/>
<link rel="next" title="Glossary" href="glossary.html"/>
<link rel="prev" title="CSS Style Objects" href="CSS-styles.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> MathJax
</a>
<div class="version">
2.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Basic Usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../mathjax.html">What is MathJax?</a></li>
<li class="toctree-l1"><a class="reference internal" href="../start.html">Getting Started with MathJax</a></li>
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installing and Testing MathJax</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration.html">Loading and Configuring MathJax</a></li>
<li class="toctree-l1"><a class="reference internal" href="../config-files.html">Combined MathJax Configurations</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../tex.html">MathJax TeX and LaTeX Support</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mathml.html">MathJax MathML Support</a></li>
<li class="toctree-l1"><a class="reference internal" href="../asciimath.html">MathJax AsciiMath Support</a></li>
<li class="toctree-l1"><a class="reference internal" href="../output.html">MathJax Output Formats</a></li>
<li class="toctree-l1"><a class="reference internal" href="../font-support.html">MathJax Font Support</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../localization.html">MathJax Localization</a></li>
<li class="toctree-l1"><a class="reference internal" href="../safe-mode.html">MathJax Safe-mode</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../community.html">The MathJax Community</a></li>
</ul>
<p class="caption"><span class="caption-text">Configuration options</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../options/index.html">Configuration options</a></li>
</ul>
<p class="caption"><span class="caption-text">Advanced topics</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../advanced/model.html">The MathJax Processing Model</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/startup.html">The MathJax Startup Sequence</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/synchronize.html">Synchronizing Your Code with MathJax</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/dynamic.html">Loading MathJax Dynamically</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/typeset.html">Modifying Math on the Page</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/toMathML.html">Obtaining the MathML for an Expression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/extension-writing.html">Writing MathJax Extensions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/debugging-tips.html">Debugging Tips</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/mathjax-node.html">MathJax on NodeJS</a></li>
</ul>
<p class="caption"><span class="caption-text">The MathJax API</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../api/index.html">Details of the MathJax API</a></li>
</ul>
<p class="caption"><span class="caption-text">Miscellanea</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../misc/accessibility-features.html">Accessibility features</a></li>
<li class="toctree-l1"><a class="reference internal" href="../misc/browser-compatibility.html">Browser Compatibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="../misc/epub.html">EPUB3 Reading Systems</a></li>
<li class="toctree-l1"><a class="reference internal" href="../misc/badges.html">MathJax Badges and Logo</a></li>
<li class="toctree-l1"><a class="reference internal" href="../misc/articles.html">Articles and Presentations</a></li>
<li class="toctree-l1"><a class="reference internal" href="../misc/platforms.html">Using MathJax in Web Platforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../misc/faq.html">MathJax FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../misc/mathjax-in-use.html">MathJax in Use</a></li>
</ul>
<p class="caption"><span class="caption-text">Upgrading MathJax</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../upgrading/index.html">Upgrading MathJax</a></li>
</ul>
<p class="caption"><span class="caption-text">Reference Pages</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="HTML-snippets.html">HTML snippets</a></li>
<li class="toctree-l1"><a class="reference internal" href="CSS-styles.html">CSS style objects</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Localization strings</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#parameter-substitution">Parameter Substitution</a></li>
<li class="toctree-l2"><a class="reference internal" href="#plural-forms">Plural forms</a></li>
<li class="toctree-l2"><a class="reference internal" href="#number-forms">Number forms</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id-s-and-domains">ID’s and Domains</a></li>
<li class="toctree-l2"><a class="reference internal" href="#html-snippets">HTML Snippets</a></li>
<li class="toctree-l2"><a class="reference internal" href="#markdown-notation">Markdown Notation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">MathJax</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> »</li>
<li>Localization Strings</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/reference/localization-strings.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="localization-strings">
<span id="id1"></span><h1>Localization Strings<a class="headerlink" href="#localization-strings" title="Permalink to this headline">¶</a></h1>
<p>In MathJax v2.2 and later, the user interface can be localized to use
languages other than English. This includes all information strings,
menu items, warning messages, and so on. To make this possible, each
string is given an ID that is used to obtain the localized version of
the string. So the “File not found” message might have the ID
<code class="docutils literal"><span class="pre">NotFound</span></code>. The localization data for each language associates the ID
<code class="docutils literal"><span class="pre">NotFound</span></code> with the proper translation of the English phrase “File not
found”.</p>
<p>Some of MathJax’s functions, like <code class="xref py py-meth docutils literal"><span class="pre">MathJax.Message.Set()</span></code>, can accept
localized strings as their parameters. To use a localized string in
this case, use an array consisting of the ID followed by the English
string (followed by any substitution arguments for the string, see
below). For example,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Message</span><span class="p">.</span><span class="nx">Set</span><span class="p">([</span><span class="s2">"NotFound"</span><span class="p">,</span><span class="s2">"File not found"</span><span class="p">]);</span>
</pre></div>
</div>
<p>would cause the “File not found” message to be displayed (in the
currently selected language) in the MathJax message area at the bottom
of left of the browser window. Note that <code class="xref py py-meth docutils literal"><span class="pre">MathJax.Message.Set()</span></code> can
still accept unlocalized strings, as it has traditionally:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Message</span><span class="p">.</span><span class="nx">Set</span><span class="p">(</span><span class="s2">"File not found"</span><span class="p">);</span>
</pre></div>
</div>
<p>Here the message will always be in English, regardless of the selected
language.</p>
<p>The reason that the English string is also given (in addition to the
ID), is because MathJax needs to have a fallback string to use in case
the localization data doesn’t translate that ID, or if the localization
data has failed to load. Providing the English string in addition to
the ID guarantees that a fallback is available.</p>
<p>MathJax’s localization system is documented more fully in
the <a class="reference internal" href="../api/localization.html#api-localization"><span class="std std-ref">Localization API</span></a> documentation.</p>
<div class="section" id="parameter-substitution">
<h2>Parameter Substitution<a class="headerlink" href="#parameter-substitution" title="Permalink to this headline">¶</a></h2>
<p>Localized messages may need to include information, like file names,
that are not known until the message is needed. In this case, the
message string acts as a template and MathJax will insert the needed
values into it at the appropriate places. To use such substitutions,
you include the values in the localization string array following the
English phrase, and use the special sequences <code class="docutils literal"><span class="pre">%1</span></code>, <code class="docutils literal"><span class="pre">%2</span></code>, etc., to
refer to the parameters at the locations where they should appear in
the message. For example,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Message</span><span class="p">.</span><span class="nx">Set</span><span class="p">([</span><span class="s2">"NotFound"</span><span class="p">,</span><span class="s2">"File %1 not found"</span><span class="p">,</span><span class="nx">filename</span><span class="p">]);</span>
</pre></div>
</div>
<p>would cause the name stored in the variable <code class="docutils literal"><span class="pre">filename</span></code> to be
inserted into the localized string at the location of the <code class="docutils literal"><span class="pre">%1</span></code>.
Note that the localized string could use the parameters in a different
order from how they appear in English, so MathJax can handle languages
where the word order is different.</p>
<p>Although it would be rare to need more than 9 substitution parameters,
you can use <code class="docutils literal"><span class="pre">%10</span></code>, <code class="docutils literal"><span class="pre">%11</span></code>, etc., to get the 10-th, 11-th, and so
on. If you need a parameter to be followed directly by a number, use
<code class="docutils literal"><span class="pre">%{1}0</span></code> (rather than <code class="docutils literal"><span class="pre">%10</span></code>) to get the first parameter followed
directly by a zero.</p>
<p>A <code class="docutils literal"><span class="pre">%</span></code> followed by anything other than a number or a <code class="docutils literal"><span class="pre">{</span></code> generates
just the character following the percent sign, so <code class="docutils literal"><span class="pre">%%</span></code> would produce
a single <code class="docutils literal"><span class="pre">%</span></code>, and <code class="docutils literal"><span class="pre">%:</span></code> would produce just <code class="docutils literal"><span class="pre">:</span></code>.</p>
</div>
<div class="section" id="plural-forms">
<h2>Plural forms<a class="headerlink" href="#plural-forms" title="Permalink to this headline">¶</a></h2>
<p>Some languages handle plural forms differently from how English does.
In English, there are two forms: the one used for a single item, and
the one used for everything else. For example, you would say “You
have one new message” for a single message, but “You have three new
messages” of there were three messages (or two, or zero, or anything
other than one).</p>
<p>To handle plurals, you use a special “plural” directive within your
message string. The format is</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="o">%</span><span class="p">{</span><span class="nx">plural</span><span class="o">:%</span><span class="nx">n</span><span class="o">|</span><span class="nx">text1</span><span class="o">|</span><span class="nx">text2</span><span class="p">}</span>
</pre></div>
</div>
<p>where <code class="docutils literal"><span class="pre">%n</span></code> is the reference to the parameter (which should be a
number) that controls which text to use. For English, there would be
two texts, one (<code class="docutils literal"><span class="pre">text1</span></code>) for when the number is 1, and one
(<code class="docutils literal"><span class="pre">text2</span></code>) for when it is anything else. Other languages may have
more forms (e.g., Welsh has six different plural forms, a different
one for 0 (zero), 1 (one), 2 (two), 3 (few), 6 (many), and anything
else, so Welsh translation plural forms would have six different
texts). The details of how to map the numeric value to the text
strings is handled by the translation data for the selected language.</p>
<p>As an example, you might use</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Message</span><span class="p">.</span><span class="nx">Set</span><span class="p">([</span><span class="s2">"NewMessages"</span><span class="p">,</span><span class="s2">"You have %1 new %{plural:%1|message|messages}"</span><span class="p">,</span><span class="nx">n</span><span class="p">]);</span>
</pre></div>
</div>
<p>where <code class="docutils literal"><span class="pre">n</span></code> is a variable holding the number of new messages.</p>
<p>Alternatively,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Message</span><span class="p">.</span><span class="nx">Set</span><span class="p">([</span><span class="s2">"NewMessages"</span><span class="p">,</span><span class="s2">"You have %{plural:%1|a new message|%1 new messages}"</span><span class="p">,</span><span class="nx">n</span><span class="p">]);</span>
</pre></div>
</div>
<p>shows how you can do substitution within the plural texts themselves.</p>
<p>Note that the translation string may contain such constructs even if
the original English one doesn’t. For example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Message</span><span class="p">.</span><span class="nx">Set</span><span class="p">([</span><span class="s2">"alone"</span><span class="p">,</span><span class="s2">"We are %1 in this family but alone in this World."</span><span class="p">,</span><span class="nx">n</span><span class="p">]);</span>
</pre></div>
</div>
<p>could be translated into French by</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="s2">"Nous sommes %1 dans cette famille mais %{plural:%1|seul|seuls} en ce monde."</span>
</pre></div>
</div>
<p>Note that if one of the options for the plural forms requires a
literal close brace, it can be quoted with a percent. For instance,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="o">%</span><span class="p">{</span><span class="nx">plural</span><span class="o">:%</span><span class="mi">1</span><span class="o">|</span><span class="nx">One</span> <span class="p">{</span><span class="nx">only</span><span class="o">%</span><span class="p">}</span><span class="o">|</span><span class="nx">Two</span> <span class="p">{</span><span class="nx">or</span> <span class="nx">more</span><span class="o">%</span><span class="p">}}</span>
</pre></div>
</div>
<p>would produce <code class="docutils literal"><span class="pre">One</span> <span class="pre">{only}</span></code> when the first argument is 1, and <code class="docutils literal"><span class="pre">Two</span> <span class="pre">{or</span>
<span class="pre">more}</span></code> otherwise.</p>
<p>If a message needs to include a literal string that looks like one of
these selectors, the original <code class="docutils literal"><span class="pre">%</span></code> can be quoted. So <code class="docutils literal"><span class="pre">%%{plural:%%1|A|B}</span></code>
would be the literal string <code class="docutils literal"><span class="pre">%{plural:%1|A|B}</span></code>.</p>
</div>
<div class="section" id="number-forms">
<h2>Number forms<a class="headerlink" href="#number-forms" title="Permalink to this headline">¶</a></h2>
<p>Decimal numbers are represented differently in different languages.
For example, 3.14159 is an English representation of an approximation
to the mathematical constant pi, while in European countries, it would
be written 3,14159. MathJax will convert a number to the proper
format before inserting it into a localized string. For example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Message</span><span class="p">.</span><span class="nx">Set</span><span class="p">([</span><span class="s2">"pi"</span><span class="p">,</span><span class="s2">"The value of pi is approximately %1"</span><span class="p">,</span><span class="mf">3.14159</span><span class="p">]);</span>
</pre></div>
</div>
<p>would show the value as <code class="docutils literal"><span class="pre">3.14159</span></code> in English, but <code class="docutils literal"><span class="pre">3,14159</span></code> if
French is the selected language.</p>
</div>
<div class="section" id="id-s-and-domains">
<h2>ID’s and Domains<a class="headerlink" href="#id-s-and-domains" title="Permalink to this headline">¶</a></h2>
<p>Because MathJax consists of a number of separate components and can
be extended by third party code, it is possible for two different
components to want to use the same ID value for a string, leading to
an ID name collision. To help avoid this, MathJax allows identifier
<em>domains</em> that are used to isolate collections of identifiers for one
component from those for another component. For example,
each input jax has its own domain, as do many of the MathJax
extensions. This means you only have to worry about collisions within
your own domain, and so can more easily manage the uniqueness if the
ID’s in use.</p>
<p>To use a domain with your ID, replace the ID with an array consisting of the
domain and the ID. For example, the TeX input jax uses the domain
<code class="docutils literal"><span class="pre">TeX</span></code>, so</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Message</span><span class="p">.</span><span class="nx">Set</span><span class="p">([[</span><span class="s2">"TeX"</span><span class="p">,</span><span class="s2">"MissingBrace"</span><span class="p">],</span><span class="s2">"Missing Close Brace"</span><span class="p">]);</span>
</pre></div>
</div>
<p>would set the message to the translation associated with the ID
<code class="docutils literal"><span class="pre">MissingBrace</span></code> in the <code class="docutils literal"><span class="pre">TeX</span></code> domain.</p>
<p>Some functions that take localization strings automatically prepend the
domain to the ID (if one isn’t already given). For example, the
<code class="xref py py-meth docutils literal"><span class="pre">Error()</span></code> function of the TeX input jax uses the <code class="docutils literal"><span class="pre">TeX</span></code> domain if
one isn’t supplied, so</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">TEX</span><span class="p">.</span><span class="nb">Error</span><span class="p">([</span><span class="s2">"MissingBrace"</span><span class="p">,</span><span class="s2">"Missing Close Brace"</span><span class="p">]);</span>
</pre></div>
</div>
<p>will generate the <code class="docutils literal"><span class="pre">MissingBrace</span></code> error from the <code class="docutils literal"><span class="pre">TeX</span></code> domain
without having to specify the <code class="docutils literal"><span class="pre">TeX</span></code> domain explicitly.</p>
</div>
<div class="section" id="html-snippets">
<h2>HTML Snippets<a class="headerlink" href="#html-snippets" title="Permalink to this headline">¶</a></h2>
<p>MathJax provides a means of specifiying HTML code in javascript called
<a class="reference internal" href="HTML-snippets.html#html-snippets"><span class="std std-ref">HTML snippets</span></a>. These frequently include text
that needs to be localized, so you can include localization strings
(like those described above) within an HTML snippet in any location
where you would normally have a regular text string. For example, the
snippet</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="p">[</span>
<span class="s2">"Follow this link: "</span><span class="p">,</span>
<span class="p">[</span><span class="s2">"a"</span><span class="p">,{</span><span class="nx">href</span><span class="o">:</span><span class="s2">"http://www.mathjax.org"</span><span class="p">},[</span>
<span class="p">[</span><span class="s2">"img"</span><span class="p">,{</span><span class="nx">src</span><span class="o">:</span><span class="s2">"external.gif"</span><span class="p">}]</span>
<span class="p">]]</span>
<span class="p">]</span>
</pre></div>
</div>
<p>includes the text “Follow this link:” which should be localized. You
can change it to a localization string to cause it to be translated to
the selected langauge:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="p">[</span>
<span class="p">[</span><span class="s2">"FollowLink"</span><span class="p">,</span><span class="s2">"Follow this link"</span><span class="p">],</span><span class="s2">": "</span><span class="p">,</span>
<span class="p">[</span><span class="s2">"a"</span><span class="p">,{</span><span class="nx">href</span><span class="o">:</span><span class="s2">"http://www.mathjax.org"</span><span class="p">},[</span>
<span class="p">[</span><span class="s2">"img"</span><span class="p">,{</span><span class="nx">src</span><span class="o">:</span><span class="s2">"external.gif"</span><span class="p">}]</span>
<span class="p">]]</span>
<span class="p">]</span>
</pre></div>
</div>
<p>(Here we use the ID <code class="docutils literal"><span class="pre">FollowLink</span></code> to obtain the translation). Note
that you can include substitution parameters as usual:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="p">[</span>
<span class="p">[</span><span class="s2">"ClickMessages"</span><span class="p">,</span><span class="s2">"Click for %1 new %{plural:%1|messsage|messages}"</span><span class="p">,</span><span class="nx">n</span><span class="p">],</span><span class="s2">": "</span><span class="p">,</span>
<span class="p">[</span><span class="s2">"a"</span><span class="p">,{</span><span class="nx">href</span><span class="o">:</span><span class="s2">"messages.html"</span><span class="p">},[</span>
<span class="p">[</span><span class="s2">"img"</span><span class="p">,{</span><span class="nx">src</span><span class="o">:</span><span class="s2">"external.gif"</span><span class="p">}]</span>
<span class="p">]]</span>
<span class="p">]</span>
</pre></div>
</div>
<p>It is even possible to substitute HTML snippets into a localized
string (when it is within an HTML snippet):</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span>[
["MathJaxLink","This is documented at the %1 website",[
["a",{href:"http://docs.mathjax.org"},["MathJax]]
]]
]
</pre></div>
</div>
<p>Note, however, that a better approach to this exampe is given in the
next section.</p>
<p>Since an HTML snippet might contain several strings that need to be
localized, you may want to be able to specify the domain to use for
<em>all</em> the strings within the snippet. Within a snippet, you can use
an entry of the form <code class="docutils literal"><span class="pre">[domain,snippet]</span></code> to force the snippet to be
processed with default domain <code class="docutils literal"><span class="pre">domain</span></code>. E.g.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="p">[</span>
<span class="p">[</span><span class="s2">"TeX"</span><span class="p">,[</span>
<span class="p">[</span><span class="s2">"ul"</span><span class="p">,{},[</span>
<span class="p">[</span><span class="s2">"li"</span><span class="p">,{},[[</span><span class="s2">"MissingBrace"</span><span class="p">,</span><span class="s2">"Missing close brace"</span><span class="p">]]],</span>
<span class="p">[</span><span class="s2">"li"</span><span class="p">,{},[[</span><span class="s2">"ExtraBrace"</span><span class="p">,</span><span class="s2">"Extra close brace"</span><span class="p">]]],</span>
<span class="p">]]</span>
<span class="p">]],</span>
<span class="p">[</span><span class="s2">"MathML"</span><span class="p">,[</span>
<span class="p">[</span><span class="s2">"ul"</span><span class="p">,{},[</span>
<span class="p">[</span><span class="s2">"li"</span><span class="p">,{},[[</span><span class="s2">"UnknownNode"</span><span class="p">,</span><span class="s2">"Unknown node type: %1"</span><span class="p">,</span><span class="nx">type</span><span class="p">]]],</span>
<span class="p">[</span><span class="s2">"li"</span><span class="p">,{},[[</span><span class="s2">"BadAttribute"</span><span class="p">,</span><span class="s2">"Illegal attribute: %1"</span><span class="p">,</span><span class="nx">attr</span><span class="p">]]],</span>
<span class="p">]]</span>
<span class="p">]</span>
<span class="p">]</span>
</pre></div>
</div>
<p>would create two undordered lists, one with translations from the
<code class="docutils literal"><span class="pre">TeX</span></code> domain, and one from the <code class="docutils literal"><span class="pre">MathML</span></code> domain.</p>
<p>To summarize the format of an HTML snippet, it is an array
with each entry being one of the following:</p>
<ul class="simple">
<li>A text string, which becomes text in the resulting HTML; this is
untranslated.</li>
<li>An array of the form <code class="docutils literal"><span class="pre">["tag"]</span></code>, <code class="docutils literal"><span class="pre">["tag",{properties}]</span></code>, or
<code class="docutils literal"><span class="pre">["tag",{properties},HTML-snippet]</span></code>, which becomes the given HTML
tag, with the given properties, containing the given HTML-snippet
as its children.</li>
<li>An array of the form <code class="docutils literal"><span class="pre">[id,message]</span></code> or
<code class="docutils literal"><span class="pre">[id,message,parameters]</span></code>, which is first translated, then
parameter substitution performed, and the result added to the
HTML (either as text or as HTML tags if the message included
Markdown syntax). Note that the <code class="docutils literal"><span class="pre">id</span></code> can be either an id or an
array <code class="docutils literal"><span class="pre">[domain,id]</span></code>, and that the parameters could be HTML
snippets themselves.</li>
<li>An array of the form <code class="docutils literal"><span class="pre">[domain,HTML-snippet]</span></code>, which becomes
the HTML-snippet with its localizations done from the given domain.</li>
</ul>
</div>
<div class="section" id="markdown-notation">
<h2>Markdown Notation<a class="headerlink" href="#markdown-notation" title="Permalink to this headline">¶</a></h2>
<p>HTML snippets allow you to create styled markup, like bold or italics,
but this requires breaking the text up into smaller strings that fall
in between HTML tags. That makes it hard to translate, since the
strings are not full phrases. To make the creation of strings with
bold, italics, and hyperlinks easier to localize, MathJax allows the
strings within HTML snippets to be written in a limited Markdown
syntax (<em>very</em> limited). You can use <code class="docutils literal"><span class="pre">*bold*</span></code>, <code class="docutils literal"><span class="pre">**italics**</span></code>,
<code class="docutils literal"><span class="pre">***bold-italics***</span></code>, <code class="docutils literal"><span class="pre">[link-text](url)</span></code>, and <code class="docutils literal"><span class="pre">`code`</span></code> to
obtain bold, italics, bold-italics, hyperlinks, and code blocks. For
instance, the link example above could be more easily handled via</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="p">[</span>
<span class="p">[</span><span class="s2">"MathJaxLink"</span><span class="p">,</span><span class="s2">"This is documented at the [MathJax](%1) website"</span><span class="p">,</span>
<span class="s2">"http://docs.mathjax.org"</span><span class="p">]</span>
<span class="p">]</span>
</pre></div>
</div>
<p>while</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="p">[</span>
<span class="p">[</span><span class="s2">"Renderer"</span><span class="p">,</span><span class="s2">"*Renderer*: lets you select the output renderer"</span><span class="p">]</span>
<span class="p">]</span>
</pre></div>
</div>
<p>will produce the equivalent of <code class="docutils literal"><span class="pre"><b>Renderer</b>:</span> <span class="pre">lets</span> <span class="pre">you</span> <span class="pre">select</span> <span class="pre">the</span>
<span class="pre">output</span> <span class="pre">render</span></code> in the appropriate language.</p>
</div>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="glossary.html" class="btn btn-neutral float-right" title="Glossary" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="CSS-styles.html" class="btn btn-neutral" title="CSS Style Objects" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2017 The MathJax Consortium.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'2.7',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
|