This file is indexed.

/usr/share/doc/libjs-mathjax-doc/html/api/localization.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
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
<!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>The MathJax.Localization Class &mdash; 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="up" title="The MathJax API" href="index.html"/>
        <link rel="next" title="The MathJax.InputJax Class" href="inputjax.html"/>
        <link rel="prev" title="The MathJax.Callback.Signal Class" href="signal.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 class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Details of the MathJax API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="variable.html">The MathJax variable</a></li>
<li class="toctree-l2"><a class="reference internal" href="hub.html">The MathJax.Hub object</a></li>
<li class="toctree-l2"><a class="reference internal" href="ajax.html">The MathJax.Ajax object</a></li>
<li class="toctree-l2"><a class="reference internal" href="message.html">The MathJax.Message object</a></li>
<li class="toctree-l2"><a class="reference internal" href="html.html">The MathJax.HTML object</a></li>
<li class="toctree-l2"><a class="reference internal" href="callback.html">The MathJax.CallBack class</a></li>
<li class="toctree-l2"><a class="reference internal" href="queue.html">The MathJax.CallBack.Queue class</a></li>
<li class="toctree-l2"><a class="reference internal" href="signal.html">The MathJax.CallBack.Signal class</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">The MathJax.Localization object</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#getting-a-translated-string">Getting a Translated String</a></li>
<li class="toctree-l3"><a class="reference internal" href="#parameter-substitution">Parameter Substitution</a></li>
<li class="toctree-l3"><a class="reference internal" href="#html-snippets">HTML Snippets</a></li>
<li class="toctree-l3"><a class="reference internal" href="#synchronization-issues">Synchronization Issues</a></li>
<li class="toctree-l3"><a class="reference internal" href="#the-localization-data">The Localization Data</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#methods">Methods</a></li>
<li class="toctree-l4"><a class="reference internal" href="#properties">Properties</a></li>
<li class="toctree-l4"><a class="reference internal" href="#translation-data">Translation Data</a></li>
<li class="toctree-l4"><a class="reference internal" href="#domain-data">Domain Data</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#registering-a-translation">Registering a Translation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#the-translation-files">The Translation Files</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="inputjax.html">The MathJax.InputJax class</a></li>
<li class="toctree-l2"><a class="reference internal" href="outputjax.html">The MathJax.OutputJax class</a></li>
<li class="toctree-l2"><a class="reference internal" href="elementjax.html">The MathJax.ElementJax class</a></li>
<li class="toctree-l2"><a class="reference internal" href="jax.html">The base Jax class</a></li>
<li class="toctree-l2"><a class="reference internal" href="object.html">The MathJax Object-Oriented Programming Model</a></li>
</ul>
</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>
<li class="toctree-l1"><a class="reference internal" href="../reference/HTML-snippets.html">HTML snippets</a></li>
<li class="toctree-l1"><a class="reference internal" href="../reference/CSS-styles.html">CSS style objects</a></li>
<li class="toctree-l1"><a class="reference internal" href="../reference/localization-strings.html">Localization strings</a></li>
<li class="toctree-l1"><a class="reference internal" href="../reference/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> &raquo;</li>
        
          <li><a href="index.html">The MathJax API</a> &raquo;</li>
        
      <li>The MathJax.Localization Class</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/api/localization.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="the-mathjax-localization-class">
<span id="api-localization"></span><h1>The MathJax.Localization Class<a class="headerlink" href="#the-mathjax-localization-class" title="Permalink to this headline"></a></h1>
<p>Beginning in version 2.2 of MathJax, all of MathJax’s messages, menus,
dialog boxes, and so are are localizable (meaning they can be
presented in languages other than English).  This is accomplished
through the <cite>MathJax.Localization</cite> object.  This object stores the
data about the available languages, and the selected language,
together with the routines needed to obtain the translated strings for
the messages used by MathJax, and the ones used to register
translations with the system.</p>
<p>Localizable strings in MathJax are identified by a unique ID (a
character string used to obtain the translation), and MathJax has
functions that obtain the translated message associated with the ID.
Some messages need values inserted into them (like file names, or TeX
macro names), and MathJax can insert those values into the translated
string automatically.  The localization system has support for plural
and number forms, which differ from language to language.  These
issues are described in more detail in the <a class="reference internal" href="../reference/localization-strings.html#localization-strings"><span class="std std-ref">Localization Strings</span></a> documentation.</p>
<p>A number of MathJax’s messaging functions handle localization of their
messages automatically.  For example, the <code class="xref py py-meth docutils literal"><span class="pre">MathJax.Message.Set()</span></code>
function and the TeX input jax’s <code class="xref py py-meth docutils literal"><span class="pre">Error()</span></code> function both will look
up localization strings automatically.</p>
<p>Because the localization data needs to be downloaded over the network,
MathJax only loads this data when it is actually needed (many users
will only see mathematical expressions and will never need an actual
translated message string, so there is no need to waste time
downloading the localization data for them).  Since MathJax loads
files asynchonously, there is a synchronization issue that you need to
be aware of when using localized message strings.  There are support
routines to help make this easier (these are described in more detail
below).</p>
<p>Finally, MathJax consists of a number of relatively separate
components, and can be extended by third-party plug-ins, it is
possible that there would be name collisions with the ID’s used to
identify localizable strings. To make it easier to manage the string
ID’s, and to break up the localization data into smaller chunks that
can be loaded quickly when needed, MathJax breaks up the messages into
<cite>domains</cite>, each with its own set of ID’s for the messages in that
domain.  Typically, a component (like the math menu, or the TeX input
jax) has its own domain, so it can keep its message ID’s separate from
other components.</p>
<div class="section" id="getting-a-translated-string">
<h2>Getting a Translated String<a class="headerlink" href="#getting-a-translated-string" title="Permalink to this headline"></a></h2>
<p>The basic means of obtaining the string to use for a message to
display to the user is to call the <cite>_()</cite> method of the
<cite>MathJax.Localization</cite> object, passing the string id and the English
phrase. 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">Localization</span><span class="p">.</span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;TC&quot;</span><span class="p">,</span><span class="s2">&quot;Typsetting Complete&quot;</span><span class="p">);</span>
</pre></div>
</div>
<p>would return the string for “Typesettings Complete” in the currently
selected language.  This can be facilitated by defining the function</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">_</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span><span class="k">return</span> <span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">_</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">,</span><span class="nx">arguments</span><span class="p">)}</span>
</pre></div>
</div>
<p>so that you only need to use</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;TC&quot;</span><span class="p">,</span><span class="s2">&quot;Typesetting Complete&quot;</span><span class="p">);</span>
</pre></div>
</div>
<p>to obtain the translated string.</p>
<p>Both these examples take the translation from the default domain (the
<code class="docutils literal"><span class="pre">_</span></code> domain), but most components will want to use their own
domain.  For example, the TeX input jax uses the <code class="docutils literal"><span class="pre">TeX</span></code> domain.  To
request a translation from a specific domain, replace the ID with an
array consisting of the domain and ID.  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">Localization</span><span class="p">.</span><span class="nx">_</span><span class="p">([</span><span class="s2">&quot;TeX&quot;</span><span class="p">,</span><span class="s2">&quot;MissingBrace&quot;</span><span class="p">],</span><span class="s2">&quot;Missing Close Brace&quot;</span><span class="p">);</span>
</pre></div>
</div>
<p>would get the string associated with the ID <code class="docutils literal"><span class="pre">MissingBrace</span></code> from the
<code class="docutils literal"><span class="pre">TeX</span></code> domain in the current language.  To make this easier, the TeX
input jax could define</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">_</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">id</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">return</span>  <span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">_</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">,</span>
                  <span class="p">[[</span><span class="s2">&quot;TeX&quot;</span><span class="p">,</span><span class="nx">id</span><span class="p">]].</span><span class="nx">concat</span><span class="p">([].</span><span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">,</span><span class="mi">1</span><span class="p">)));</span>
<span class="p">};</span>
</pre></div>
</div>
<p>which appends the <code class="docutils literal"><span class="pre">TeX</span></code> domain automatically.  With this definition,
you could use the simpler form</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;MissingBrace&quot;</span><span class="p">,</span><span class="s2">&quot;Missing Close Brace&quot;</span><span class="p">);</span>
</pre></div>
</div>
<p>to get the <code class="docutils literal"><span class="pre">MissingBrace</span></code> message from the <code class="docutils literal"><span class="pre">TeX</span></code> domain.</p>
</div>
<div class="section" id="parameter-substitution">
<h2>Parameter Substitution<a class="headerlink" href="#parameter-substitution" title="Permalink to this headline"></a></h2>
<p>Some messages may want to include values (like file names, or TeX
macro names) as part of their strings.  The MathJax localization
system provides a means of including such values in the translated
strings.  In addition to the ID and message strings, you pass the
values that need to be substituted into the message, 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 indicate where they go
within 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">Localization</span><span class="p">.</span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;NotFound&quot;</span><span class="p">,</span><span class="s2">&quot;File %1 not found&quot;</span><span class="p">,</span><span class="nx">filename</span><span class="p">)</span>
</pre></div>
</div>
<p>would obtain the translation for “File %1 not found” and insert the
filename at the location of <cite>%1</cite> in the translated string.</p>
<p>There are also mechanisms of handling plural forms (which differ from
language to language) and number forms.  See the <a class="reference internal" href="../reference/localization-strings.html#localization-strings"><span class="std std-ref">Localization
Strings</span></a> documentation for complete details.</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 allows you to encode HTML snippets using javascript data (see
the <a class="reference internal" href="../reference/HTML-snippets.html#html-snippets"><span class="std std-ref">HTML snippets</span></a> documentation for details),
and these often contain textual data that needs to be localized.  You
can pass HTML snippets to the <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> function and a domain in which
the strings are to be looked up.  You then use a localization string
(an array consisting of the ID and string, plus optional parameters to
be substituted into the string) in place of a normal string in the
HTML snippet.  For example,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="p">[</span>
  <span class="s2">&quot;Follow this link: &quot;</span><span class="p">,</span>
  <span class="p">[</span><span class="s2">&quot;a&quot;</span><span class="p">,{</span><span class="nx">href</span><span class="o">:</span><span class="s2">&quot;http://www.mathjax.org&quot;</span><span class="p">},[</span>
    <span class="p">[</span><span class="s2">&quot;img&quot;</span><span class="p">,{</span><span class="nx">src</span><span class="o">:</span><span class="s2">&quot;external.gif&quot;</span><span class="p">}]</span>
  <span class="p">]]</span>
<span class="p">]</span>
</pre></div>
</div>
<p>could be localized as</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;myDomain&quot;</span><span class="p">,[</span>
  <span class="p">[</span><span class="s2">&quot;FollowLink&quot;</span><span class="p">,</span><span class="s2">&quot;Follow this link&quot;</span><span class="p">],</span><span class="s2">&quot;: &quot;</span><span class="p">,</span>
  <span class="p">[</span><span class="s2">&quot;a&quot;</span><span class="p">,{</span><span class="nx">href</span><span class="o">:</span><span class="s2">&quot;http://www.mathjax.org&quot;</span><span class="p">},[</span>
    <span class="p">[</span><span class="s2">&quot;img&quot;</span><span class="p">,{</span><span class="nx">src</span><span class="o">:</span><span class="s2">&quot;external.gif&quot;</span><span class="p">}]</span>
  <span class="p">]]</span>
<span class="p">])</span>
</pre></div>
</div>
<p>where the <code class="docutils literal"><span class="pre">FollowLink</span></code> ID is looked up in the <code class="docutils literal"><span class="pre">myDomain</span></code> domain of
the current language.</p>
<p>See the HTML snippets section of the <a class="reference internal" href="../reference/localization-strings.html#localization-strings"><span class="std std-ref">Localization Strings</span></a> documentation for complete details.</p>
</div>
<div class="section" id="synchronization-issues">
<h2>Synchronization Issues<a class="headerlink" href="#synchronization-issues" title="Permalink to this headline"></a></h2>
<p>Because the translation data are stored in files that are loaded only
when they are needed, and since file loading in MathJax is
asynchronous, you need to take this loading process into account when
you use <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> to obtain a localized string.  If this is the first
string obtained from the language, or the first one from the requested
domain, MathJax may have to load the data file or that language or
domain (or both).  In that case, you need to be prepared to wait for
that file to load and retry obtaining the translation string.
The localization system provides you with two functions to make this
easier, but you do have to keep in mind that obtaining translation
strings may be an asynchronous action.</p>
<p>The first method is <code class="xref py py-meth docutils literal"><span class="pre">MathJax.Localization.loadDomain()</span></code>, which takes a
domain name and an optional callback, and forces MathJax to load the
language data for that domain (and the main language data file, if
needed), then calls the callback.  In this way, the callback function
knows that the localization data that it needs will be available, and
it doesn’t have to worry about the possibility that <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> will start
a file loading operation.  The <a class="reference internal" href="#loadDomain" title="loadDomain"><code class="xref py py-meth docutils literal"><span class="pre">loadDomain()</span></code></a> function returns the
callback object, which can be used in callback queues, for example, to
coordinate further actions.</p>
<p>For example, suppose you want to perform the check</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">url</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/^https?:/</span><span class="p">))</span> <span class="p">{</span>
  <span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;Your url must use the http protocol&quot;</span><span class="p">);</span>
  <span class="nx">url</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>and want to localize the error message.  The naive approach would be</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">url</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/^https?:/</span><span class="p">))</span> <span class="p">{</span>
  <span class="nx">alert</span><span class="p">(</span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;BadProtocol&quot;</span><span class="p">,</span><span class="s2">&quot;Your url must use the http protocol&quot;</span><span class="p">));</span>
  <span class="nx">url</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>(provided you have defined <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> for your domain as described
above).  The problem is that <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> might need to load the language
data for your message, and that causes <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> to throw a restart
error.  That would cause an error message to appear on the javascript
console, and your alert would never occur.  Instead, you want to make
sure that the localization data are available before calling <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a>.</p>
<p>Suppose the domain for your message ID is <code class="docutils literal"><span class="pre">myDomain</span></code>, then one way
to do this would be</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">url</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/^https?:/</span><span class="p">))</span> <span class="p">{</span>
  <span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">loadDomain</span><span class="p">(</span><span class="s2">&quot;myDomain&quot;</span><span class="p">,</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
    <span class="nx">alert</span><span class="p">(</span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;BadProtocol&quot;</span><span class="p">,</span><span class="s2">&quot;Your url must use the http or https protocol&quot;</span><span class="p">));</span>
  <span class="p">});</span>
  <span class="nx">url</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>This uses <code class="docutils literal"><span class="pre">loadDomain</span></code> to force the <code class="docutils literal"><span class="pre">myDomain</span></code> data to be loaded
before attemptin the <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> call, so you are sure the call will
succeed.  If several localized string are needed, you may want to use
<code class="docutils literal"><span class="pre">loadDomain</span></code> around the entire function:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">loadDomain</span><span class="p">(</span><span class="s2">&quot;myDomain&quot;</span><span class="p">,</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
  <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">url</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/^https?:/</span><span class="p">))</span> <span class="p">{</span>
    <span class="nx">alert</span><span class="p">(</span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;BadProtocol&quot;</span><span class="p">,</span><span class="s2">&quot;Your url must use the http or https protocol&quot;</span><span class="p">));</span>
    <span class="nx">url</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">if</span> <span class="p">(</span><span class="nx">url</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">url</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/\.js$/</span><span class="p">))</span> <span class="p">{</span>
    <span class="nx">alert</span><span class="p">(</span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;BadType&quot;</span><span class="p">,</span><span class="s2">&quot;Your url should refer to a javascript file&quot;</span><span class="p">));</span>
  <span class="p">}</span>
<span class="p">});</span>
</pre></div>
</div>
<p>It is also possible to use <a class="reference internal" href="#loadDomain" title="loadDomain"><code class="xref py py-meth docutils literal"><span class="pre">loadDomain()</span></code></a> as part of a callback
queue:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Callback</span><span class="p">.</span><span class="nx">Queue</span><span class="p">(</span>
  <span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">loadDomain</span><span class="p">(</span><span class="s2">&quot;myDomain&quot;</span><span class="p">),</span>
  <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
    <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">url</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/^https?:/</span><span class="p">))</span> <span class="p">{</span>
      <span class="nx">alert</span><span class="p">(</span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;BadProtocol&quot;</span><span class="p">,</span><span class="s2">&quot;Your url must use the http or https protocol&quot;</span><span class="p">));</span>
      <span class="nx">url</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">);</span>
</pre></div>
</div>
<p>Here the function will not be performed until after the <code class="docutils literal"><span class="pre">myDomain</span></code>
domain is loaded.</p>
<p>The second tool for synchronizing with the localization system is the
<code class="xref py py-meth docutils literal"><span class="pre">MathJax.Localization.Try()</span></code> function.  This method takes a callback
specification (for example, a function, though it could be any valid
callback data) and runs the callback with error trapping.  If the
callback throws a restart error (due to loading a localization data
file), <a class="reference internal" href="#Try" title="Try"><code class="xref py py-meth docutils literal"><span class="pre">Try()</span></code></a> will wait for that file to load, then rerun the
callback (and will continue to do so if there are additional file
loads).</p>
<p>Using this approach, you don’t have to worry about loading the domains
explicitly, as <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> will throw a restart error when one is needed,
and <a class="reference internal" href="#Try" title="Try"><code class="xref py py-meth docutils literal"><span class="pre">Try()</span></code></a> will catch it and restart after the load.  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">Localization</span><span class="p">.</span><span class="nx">Try</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
  <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">url</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/^https?:/</span><span class="p">))</span> <span class="p">{</span>
    <span class="nx">alert</span><span class="p">(</span><span class="nx">_</span><span class="p">(</span><span class="s2">&quot;BadProtocol&quot;</span><span class="p">,</span><span class="s2">&quot;Your url must use the http or https protocol&quot;</span><span class="p">));</span>
    <span class="nx">url</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
  <span class="p">}</span>
<span class="p">});</span>
</pre></div>
</div>
<p>Note that, as with <a class="reference internal" href="#loadDomain" title="loadDomain"><code class="xref py py-meth docutils literal"><span class="pre">loadDomain()</span></code></a>, <a class="reference internal" href="#Try" title="Try"><code class="xref py py-meth docutils literal"><span class="pre">Try()</span></code></a> may return before the
callback has been run successfully, so you should consider this to be
an asynchronous function.  You can use callbacks to synchronize with
other actions, if needed.</p>
<p>Also note that your function may be called multiple times before it
succeeds (if localization data needs to be loaded).  So you need to
write the function in such a way that it doesn’t matter if it gets
partway through and fails.  For example, you might not want to create
structures or modify values that affect what happens if the function
has to be rerun from the beginning when one of its <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> causes a
file load.</p>
<p>A number of functions in MathJax are able to accept localization
strings as their inputs, and these already take care of the
synchronization issues for you.  For example,
<code class="xref py py-meth docutils literal"><span class="pre">MathJax.Message.Set()</span></code> can accept either a plain (untranslated)
string, or a localization string (array with ID, string, and
substitution parameters).  It uses <a class="reference internal" href="#Try" title="Try"><code class="xref py py-meth docutils literal"><span class="pre">Try()</span></code></a> internally to make sure
your message is properly translated before posting it to the screen.
That means you don’t have to worry about that yourself when you use
<code class="xref py py-meth docutils literal"><span class="pre">MathJax.Message.Set()</span></code>, though you shoud be aware that the posting
of the message may be asynchronous, so the message might not be
visible when <a class="reference internal" href="message.html#Set" title="Set"><code class="xref py py-meth docutils literal"><span class="pre">Set()</span></code></a> returns.  Fortunately,
<code class="xref py py-meth docutils literal"><span class="pre">MathJax.Message.Clear()</span></code> coordinates with <a class="reference internal" href="message.html#Set" title="Set"><code class="xref py py-meth docutils literal"><span class="pre">Set()</span></code></a> so that even if
you call <a class="reference internal" href="message.html#Clear" title="Clear"><code class="xref py py-meth docutils literal"><span class="pre">Clear()</span></code></a> before the original message posts, MathJax won’t
get confused).  Similarly, the TeX input jax’s <code class="xref py py-meth docutils literal"><span class="pre">Error()</span></code> function
handles the calling of <a class="reference internal" href="#_" title="_"><code class="xref py py-meth docutils literal"><span class="pre">_()</span></code></a> and its synchronization for you.</p>
</div>
<div class="section" id="the-localization-data">
<h2>The Localization Data<a class="headerlink" href="#the-localization-data" title="Permalink to this headline"></a></h2>
<p>The <code class="docutils literal"><span class="pre">MathJax.Localization</span></code> object holds the data for the various
translations, as well as the service routines for adding to the
translations and retrieving translations.</p>
<div class="section" id="methods">
<h3>Methods<a class="headerlink" href="#methods" title="Permalink to this headline"></a></h3>
<p>The methods in <code class="docutils literal"><span class="pre">MathJax.Localization</span></code> include:</p>
<dl class="method">
<dt id="_">
<code class="descname">_</code><span class="sig-paren">(</span><em>id</em>, <em>message</em><span class="optional">[</span>, <em>arguments</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#_" title="Permalink to this definition"></a></dt>
<dd><p>The function (described in detail above) that returns the translated
string for a given <cite>id</cite>, substituting the given <cite>arguments</cite> as needed.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>id</strong> — the ID of the message to translate, or an array <code class="docutils literal"><span class="pre">[domain,ID]</span></code></li>
<li><strong>message</strong> — the English phrase to use as fallback if
there is no translation, or an HTML snippet to be localized</li>
<li><strong>arguments</strong> — values to be inserted into the translated string</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the translated string or HTML snippet</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="setLocale">
<code class="descname">setLocale</code><span class="sig-paren">(</span><em>locale</em><span class="sig-paren">)</span><a class="headerlink" href="#setLocale" title="Permalink to this definition"></a></dt>
<dd><p>Sets the selected locale to the given one, e.g.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">setLocale</span><span class="p">(</span><span class="s2">&quot;fr&quot;</span><span class="p">);</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>locale</strong> — the two-character identifier for the desired locale</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><code class="docutils literal"><span class="pre">null</span></code></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="addTranslation">
<code class="descname">addTranslation</code><span class="sig-paren">(</span><em>locale</em>, <em>domain</em>, <em>def</em><span class="sig-paren">)</span><a class="headerlink" href="#addTranslation" title="Permalink to this definition"></a></dt>
<dd><p>Defines (or adds to) the translation data for the given <cite>locale</cite> and
<cite>domain</cite>. The <cite>def</cite> is the definition to be merged with the current
translation data (if it exists) or to be used as the complete
definition (if not). The data format is described below.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>locale</strong> — the two-letter identifier for the locale to update or create</li>
<li><strong>domain</strong> — the name of the domain to add or modify</li>
<li><strong>def</strong> — the definition of the domain (see below)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><code class="docutils literal"><span class="pre">null</span></code></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="setCSS">
<code class="descname">setCSS</code><span class="sig-paren">(</span><em>div</em><span class="sig-paren">)</span><a class="headerlink" href="#setCSS" title="Permalink to this definition"></a></dt>
<dd><p>Sets the CSS for the given <cite>div</cite> to reflect the needs of the
locale.  In particular, it sets the font-family, if needed, and
the direction (for right-to-left languages).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>div</strong> — the DOM element whose CSS is to be modified</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the <cite>div</cite></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="fontFamily">
<code class="descname">fontFamily</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#fontFamily" title="Permalink to this definition"></a></dt>
<dd><p>Get the <code class="docutils literal"><span class="pre">font-family</span></code> needed to display text in the selected
language. Returns <code class="docutils literal"><span class="pre">null</span></code> if no special font is required.</p>
</dd></dl>

<dl class="method">
<dt id="fontDirection">
<code class="descname">fontDirection</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#fontDirection" title="Permalink to this definition"></a></dt>
<dd><p>Get the <code class="docutils literal"><span class="pre">direction</span></code> needed to display text in the selected
language. Returns <code class="docutils literal"><span class="pre">null</span></code> if no special font is required.</p>
</dd></dl>

<dl class="method">
<dt id="plural">
<code class="descname">plural</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span><a class="headerlink" href="#plural" title="Permalink to this definition"></a></dt>
<dd><p>The method that returns the index into the list of plural texts
for the value <cite>n</cite>.  See the [CLDR
rules](<a class="reference external" href="http://unicode.org/cldr/charts/supplemental/language_plural_rules.html">http://unicode.org/cldr/charts/supplemental/language_plural_rules.html</a>)
for more information.  This calls the locale’s <a class="reference internal" href="#plural" title="plural"><code class="xref py py-meth docutils literal"><span class="pre">plural()</span></code></a>
method, if there is one, otherwise it defaults to the English version.</p>
</dd></dl>

<dl class="method">
<dt id="number">
<code class="descname">number</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span><a class="headerlink" href="#number" title="Permalink to this definition"></a></dt>
<dd><p>The method that returns the localized version of the number <cite>n</cite>.
This calls the locale’s <a class="reference internal" href="#number" title="number"><code class="xref py py-meth docutils literal"><span class="pre">number()</span></code></a> method, if there is one,
otherwise it defaults to the English version.</p>
</dd></dl>

<dl class="method">
<dt id="loadDomain">
<code class="descname">loadDomain</code><span class="sig-paren">(</span><em>domain</em><span class="optional">[</span>, <em>callback</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#loadDomain" title="Permalink to this definition"></a></dt>
<dd><p>This causes MathJax to load the data file for the given <cite>domain</cite>
in the current language, and calls the <cite>callback</cite> when that is
complete.  If the domain is already loaded, the <cite>callback</cite> is
called immediately.  This lets you synchronize actions that
require localization with the loading of the needed data so that
you are sure that the needed translations are available.  See the
section on synchonization above for details.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>domain</strong> — the name of the domain to load</li>
<li><strong>callback</strong> — the callback object to be run after loading</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the callback object (or a blank one if none specified)</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="Try">
<code class="descname">Try</code><span class="sig-paren">(</span><em>fn</em><span class="sig-paren">)</span><a class="headerlink" href="#Try" title="Permalink to this definition"></a></dt>
<dd><p>This method runs the function <cite>fn</cite> with error trapping and if an
asynchronous file load is performed (for loading localizaton
data), reruns the function again after the file loads.  This lets
you synchronize actions that require localization with the loading
of the needed data (see the section on synchronization above for
details).  Note that the function should be one that can be run
multiple times, if needed.  Also note that <a class="reference internal" href="#Try" title="Try"><code class="xref py py-meth docutils literal"><span class="pre">Try()</span></code></a> can return
<em>before</em> the <cite>fn</cite> has been completed, so you should consider <cite>fn</cite>
to be running asynchronously (you can use callbacks to synchronize
with other actions, if needed).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>fn</strong> — a callback specification for a function that
uses localization data</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><code class="docutils literal"><span class="pre">null</span></code></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="properties">
<h3>Properties<a class="headerlink" href="#properties" title="Permalink to this headline"></a></h3>
<dl class="describe">
<dt>
<code class="descname">locale</code></dt>
<dd><p>The currently selected locale, e.g., <code class="docutils literal"><span class="pre">&quot;fr&quot;</span></code>. This is set by the
<a class="reference internal" href="#setLocale" title="setLocale"><code class="xref py py-meth docutils literal"><span class="pre">setLocale()</span></code></a> method, and should not be modified by hand.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">directory</code></dt>
<dd><p>The URL for the localization data files. This can be overridden for
individual languages or domains (see below). The default is
<code class="docutils literal"><span class="pre">[MathJax]/localization</span></code>.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">strings</code></dt>
<dd><p>This is the main data structure that holds the translation
strings. It consists of an entry for each language that MathJax
knows about, e.g., there would be an entry with key <code class="docutils literal"><span class="pre">fr</span></code> whose
value is the data for the French translation. Initially, these
simply reference the files that define the translation data, which
MathJax will load when needed. After the file is loaded, they will
contain the translation data as well. This is described in more
detail below.</p>
</dd></dl>

</div>
<div class="section" id="translation-data">
<h3>Translation Data<a class="headerlink" href="#translation-data" title="Permalink to this headline"></a></h3>
<p>Each language has its own data in the <cite>MathJax.Localization.strings</cite>
structure. This structure holds data about the translation, plus the
translated strings for each domain.</p>
<p>A typical example might be</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">fr</span><span class="o">:</span> <span class="p">{</span>
  <span class="nx">menuTitle</span><span class="o">:</span> <span class="s2">&quot;Fran\u00E7ais&quot;</span><span class="p">,</span>                <span class="c1">// title used in language menu</span>
  <span class="nx">version</span><span class="o">:</span> <span class="s2">&quot;1.0&quot;</span><span class="p">,</span>
  <span class="nx">directory</span><span class="o">:</span> <span class="s2">&quot;[MathJax]/localization/fr&quot;</span><span class="p">,</span>    <span class="c1">// optional</span>
  <span class="nx">file</span><span class="o">:</span> <span class="s2">&quot;fr.js&quot;</span><span class="p">,</span>                             <span class="c1">// optional (file contains the data below)</span>
  <span class="nx">isLoaded</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>                            <span class="c1">// set when loaded</span>
  <span class="nx">fontFamily</span><span class="o">:</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span>                         <span class="c1">// optional</span>
  <span class="nx">plural</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">n</span><span class="p">)</span> <span class="p">{...},</span>                <span class="c1">// optional implementation of plural forms</span>
  <span class="nx">number</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">n</span><span class="p">)</span> <span class="p">{...},</span>                <span class="c1">// optional implementation of number forms</span>

  <span class="nx">domains</span><span class="o">:</span> <span class="p">{</span>
    <span class="s2">&quot;_&quot;</span><span class="o">:</span> <span class="p">{</span>
      <span class="nx">version</span><span class="o">:</span> <span class="s2">&quot;1.0&quot;</span><span class="p">,</span>
      <span class="nx">file</span><span class="o">:</span> <span class="s2">&quot;http://somecompany.com/MathJax/localization/fr/hub.js&quot;</span><span class="p">,</span>  <span class="c1">//  optional (contains the rest of the data)</span>
      <span class="nx">isLoaded</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
      <span class="nx">strings</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">fnf</span><span class="o">:</span> <span class="s2">&quot;File &#39;%1&#39; not found&quot;</span><span class="p">,</span>
        <span class="nx">fl</span><span class="o">:</span> <span class="s2">&quot;%1 %{plural:%1|file|files|} loaded&quot;</span><span class="p">,</span>
        <span class="p">...</span>
      <span class="p">}</span>
    <span class="p">},</span>
    <span class="nx">TeX</span><span class="o">:</span> <span class="p">{</span>
      <span class="p">...</span>
    <span class="p">},</span>
    <span class="nx">MathMenu</span><span class="o">:</span> <span class="p">{</span>
      <span class="p">...</span>
    <span class="p">}</span>
    <span class="p">...</span>
  <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>The fields have the following meanings:</p>
<dl class="describe">
<dt>
<code class="descname">menuTitle</code></dt>
<dd><p>The string used for the menu item in the language submenu (it
should be in the language itself, not English).</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">version</code></dt>
<dd><p>The version of the translation data.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">directory</code></dt>
<dd><p>An optional value that can be used to override the directory where
the translation files for this language are stored. The default is
to add the locale identifier to the end of
<code class="docutils literal"><span class="pre">MathJax.Localization.directory</span></code>, so the value given in the
example above is the default value, and could be omitted.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">file</code></dt>
<dd><p>The name of the file containing the translation data for this
language. The default is the locale identifier with <code class="docutils literal"><span class="pre">.js</span></code> appended,
so the value given in the example above is the default value, and
could be omitted.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">isLoaded</code></dt>
<dd><p>This is set to <code class="docutils literal"><span class="pre">true</span></code> when MathJax has loaded the data for this
language. Typically, when a language is registered with MathJax,
the data file isn’t loaded at that point. It will be loaded when
it is first needed, and when that happens, this value is set.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">fontFamily</code></dt>
<dd><p>This is a CSS font-family (or list of font-families) that should
be used when text in this language is displayed.  If not present,
then no special font is needed.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">fontDirection</code></dt>
<dd><p>This is a string <code class="docutils literal"><span class="pre">ltr</span></code> or <code class="docutils literal"><span class="pre">rtl</span></code> that specifies if the language
is left-to-right or right-to-left.  If not present, <code class="docutils literal"><span class="pre">ltr</span></code> will
be assumed.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">plural(n)</code></dt>
<dd><p>This is an optional function that returns the index into the list
of plural values apropriate for the given integer n.  If not
provided, the English <a class="reference internal" href="#plural" title="plural"><code class="xref py py-meth docutils literal"><span class="pre">plural()</span></code></a> function is used.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">plural(n)</code></dt>
<dd><p>This is an optional function that returns the index into the list
of plural values apropriate for the given integer <cite>n</cite>.  If not
provided, the English <a class="reference internal" href="#plural" title="plural"><code class="xref py py-meth docutils literal"><span class="pre">plural()</span></code></a> function is used.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">number(n)</code></dt>
<dd><p>This is an optional function that returns the a string
representing the decimal number <cite>n</cite> in the format used by the
given locale.  If not provided, the English <a class="reference internal" href="#number" title="number"><code class="xref py py-meth docutils literal"><span class="pre">number()</span></code></a> function
is used.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">domains</code></dt>
<dd><p>This is an object that contains the translation strings for this
language, grouped by domain. Each domain has an entry, and its
value is an object that contains the translation strings for that
domain. The format is described in more detail below.</p>
</dd></dl>

</div>
<div class="section" id="domain-data">
<h3>Domain Data<a class="headerlink" href="#domain-data" title="Permalink to this headline"></a></h3>
<p>Each domain for which there are translations has an entry in the
locale’s domains object. These store the following information:</p>
<dl class="describe">
<dt>
<code class="descname">version</code></dt>
<dd><p>The version of the data for this domain.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">file</code></dt>
<dd><p>If the domain data is stored in a separate file from the rest of
the language’s data (e.g., a third-party extension that is not
stored on the CDN may have translation data that is provied by the
thrid-party), this property tells where to obtain the translation
data. In the example above, the data is provided by another
company via a complete URL. The default value is the locale’s
directory with the domain name appended and <cite>.js</cite> appended to
that.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">isLoaded</code></dt>
<dd><p>This is set to <code class="docutils literal"><span class="pre">true</span></code> when the data file has been loaded.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">strings</code></dt>
<dd><p>This is an object that contains that actual translated
strings. The keys are the message identifiers described in the
overview section above, and the values are the translations</p>
</dd></dl>

</div>
</div>
<div class="section" id="registering-a-translation">
<h2>Registering a Translation<a class="headerlink" href="#registering-a-translation" title="Permalink to this headline"></a></h2>
<p>Typically, for languages stored on the CDN, MathJax will register the
language with a call like</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">addTranslation</span><span class="p">(</span><span class="s2">&quot;fr&quot;</span><span class="p">,</span><span class="kc">null</span><span class="p">,{});</span>
</pre></div>
</div>
<p>which will create an <code class="docutils literal"><span class="pre">fr</span></code> entry in the localization data that will
be tied to the <code class="docutils literal"><span class="pre">[MathJax]/localization/fr</span></code> directory, and the
<code class="docutils literal"><span class="pre">[MathJax]/localization/fr/fr.js</span></code> file. That directory could contain
individual files for the various domains, or the <code class="docutils literal"><span class="pre">fr.js</span></code> file itself
could contain combined data that includes the most common domains,
leaving only the lesser-used domains in separate files.</p>
<p>An example <code class="docutils literal"><span class="pre">fr.js</span></code> file could be</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">addTranslation</span><span class="p">(</span><span class="s2">&quot;fr&quot;</span><span class="p">,</span><span class="kc">null</span><span class="p">,{</span>
  <span class="nx">menuTitle</span><span class="o">:</span> <span class="s2">&quot;Fran\u00E7ais&quot;</span><span class="p">,</span>
  <span class="nx">version</span><span class="o">:</span> <span class="s2">&quot;1.0&quot;</span><span class="p">,</span>
  <span class="nx">domains</span><span class="o">:</span> <span class="p">{</span>
    <span class="s2">&quot;_&quot;</span><span class="o">:</span> <span class="p">{},</span>
    <span class="nx">TeX</span><span class="o">:</span> <span class="p">{},</span>
    <span class="nx">MathMenu</span><span class="o">:</span> <span class="p">{}</span>
  <span class="p">}</span>
<span class="p">});</span>
</pre></div>
</div>
<p>This would declare that there are translation files for the <code class="docutils literal"><span class="pre">_</span></code>,
<code class="docutils literal"><span class="pre">TeX</span></code>, and <code class="docutils literal"><span class="pre">MathMenu</span></code> domains, and that these will be loaded
individually from their default file names in the default directory of
<code class="docutils literal"><span class="pre">[MathJax]/localization/fr</span></code>.  Other domains will not be translated
unless they register themselves via a command like</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">addTranslation</span><span class="p">(</span><span class="s2">&quot;fr&quot;</span><span class="p">,</span><span class="s2">&quot;HelpDialog&quot;</span><span class="p">,{});</span>
</pre></div>
</div>
<p>in which case the domain’s data file will be loaded automatically when
needed.</p>
<p>One could preload translation strings by including them in the <code class="docutils literal"><span class="pre">fr.js</span></code>
file:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">addTranslation</span><span class="p">(</span><span class="s2">&quot;fr&quot;</span><span class="p">,</span><span class="kc">null</span><span class="p">,{</span>
  <span class="nx">menuTitle</span><span class="o">:</span> <span class="s2">&quot;Fran\u00E7ais&quot;</span><span class="p">,</span>
  <span class="nx">version</span><span class="o">:</span> <span class="s2">&quot;1.0&quot;</span><span class="p">,</span>
  <span class="nx">domains</span><span class="o">:</span> <span class="p">{</span>
    <span class="s2">&quot;_&quot;</span><span class="o">:</span> <span class="p">{</span>
      <span class="nx">isLoaded</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
      <span class="nx">strings</span><span class="o">:</span> <span class="p">{</span>
        <span class="s1">&#39;NotFound&#39;</span><span class="o">:</span> <span class="s2">&quot;Fichier `%1` non trouvé&quot;</span><span class="p">,</span>
        <span class="p">...</span>
      <span class="p">}</span>
    <span class="p">},</span>
    <span class="nx">TeX</span><span class="o">:</span> <span class="p">{</span>
      <span class="nx">isLoaded</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
      <span class="nx">strings</span><span class="o">:</span> <span class="p">{</span>
        <span class="s1">&#39;MissingBrace&#39;</span><span class="o">:</span> <span class="s2">&quot;Accolade de fermeture manquante&quot;</span><span class="p">,</span>
        <span class="p">...</span>
      <span class="p">}</span>
    <span class="p">},</span>
    <span class="nx">MathMenu</span><span class="o">:</span> <span class="p">{}</span>
  <span class="p">}</span>
<span class="p">});</span>
</pre></div>
</div>
<p>Here the <code class="docutils literal"><span class="pre">_</span></code> and <code class="docutils literal"><span class="pre">TeX</span></code> strings are preloaded, while the <code class="docutils literal"><span class="pre">MathMenu</span></code> strings will
be loaded on demand.</p>
<p>A third party extension could include</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">addTranslation</span><span class="p">(</span><span class="s2">&quot;fr&quot;</span><span class="p">,</span><span class="s2">&quot;myExtension&quot;</span><span class="p">,{</span>
  <span class="nx">file</span><span class="o">:</span> <span class="s2">&quot;http://myserver.com/MathJax/localization/myExtension/fr.js&quot;</span>
<span class="p">});</span>
</pre></div>
</div>
<p>to add French translations for the <code class="docutils literal"><span class="pre">myExtension</span></code> domain (used by the
extension) so that they would be obtained from the third-party server
when needed.</p>
<p>A third party could provide a translation for a language not covered
by the MathJax CDN by using</p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Localization</span><span class="p">.</span><span class="nx">addTranslation</span><span class="p">(</span><span class="s2">&quot;kr&quot;</span><span class="p">,</span><span class="kc">null</span><span class="p">,{</span>
  <span class="nx">menuTitle</span><span class="o">:</span> <span class="s2">&quot;\uD55C\uAD6D\uB9D0&quot;</span><span class="p">,</span>
  <span class="nx">fontFamily</span><span class="o">:</span> <span class="s2">&quot;Butang, &#39;Arial unicode MS&#39;, AppleMayungjo&quot;</span><span class="p">,</span>
  <span class="nx">directory</span><span class="o">:</span> <span class="s2">&quot;http://mycompany.com/MathJax/localization/kr&quot;</span>
<span class="p">});</span>
</pre></div>
</div>
<p>and providing a <code class="docutils literal"><span class="pre">kr.js</span></code> file in their <code class="docutils literal"><span class="pre">MathJax/localization/kr</span></code>
directory that defines the details of their translation.  If the
Korean (kr) locale is selected, MathJax will load
<code class="docutils literal"><span class="pre">http://mycompany.com/MathJax/localization/kr/kr.js</span></code> and any other
domain files when they are needed.</p>
<p>See the subdirectories in the <code class="docutils literal"><span class="pre">MathJax/localization</span></code> directory for
examples of language files.  The English directory (en) is not
actually used by MathJax (because the English strings a built in), but
it can serve as an example and starting point for producing your own
translations.</p>
</div>
<div class="section" id="the-translation-files">
<h2>The Translation Files<a class="headerlink" href="#the-translation-files" title="Permalink to this headline"></a></h2>
<p>Version 2.2 of MathJax comes with translations for French and German.
Additional languages will be made available as they are developed.  We
hope to use community-based websites like Transifex to help produce
these translations.  Currently, however, the language data files are
not in a form that can be used by these sites, so the only way to
generate new translations is to copy the English data files and
modify them for the new language.</p>
<p>In the future, MathJax will provide conversion programs that create
the files needed for such sites in the formats they require (e.g.,
YAML), and that convert the translated versions back into the data
files needed by MathJax, but these programs are not yet ready.</p>
<p>In addition, there will be a program that scans the MathJax files to
obtain the ID’s and English strings that are needed for the
translation files.  This will make maintenance of language files
easier in the future, but these are not available yet.</p>
</div>
</div>


           </div>
           <div class="articleComments">
            
           </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="inputjax.html" class="btn btn-neutral float-right" title="The MathJax.InputJax Class" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="signal.html" class="btn btn-neutral" title="The MathJax.Callback.Signal Class" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; 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>