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
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
|
%\iffalse
% Copyright 1997 Javier Bezos-L\'opez. All rights reserved.
%
% This file is part of the polyglot system release 1.1.
% ------------------------------------------------------
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
%\fi
\def\fileversion{1.1}
\def\filedate{September 1, 1997}
\def\docdate{September 1, 1997}
%
% \title{The \textsf{Polyglot} Package\footnote{This
% package is currently at version 1.1.}}
%
% \author{Javier Bezos-L\'opez\footnote{Please, send your
% comments and suggestions to \texttt{jbezos@mx3.redestb.es}, or
% to my postal address: Apartado 116.035, E-28080 Madrid, Spain.
% English is not my strong point, so contact me when you
% find mistakes in the manual.}}
%
% \date{\docdate}
%
% \maketitle
%
% \def\abstractname{Notice to Users of Version 1.0}
%
% \begin{abstract}
% I'm afraid some user commands have been changed,
% specially |\selectlanguage| and |\uselanguage|,
% and some other supressed---|\enablegroup|
% and |\disablegroup|, which have been merged into
% |\selectlanguage|. These changes will be definitive, and I
% had to do them in order to implement a right communication
% to files and marks, and avoid mixing up definitions which sometimes
% made \LaTeX\ enter in an endless loop.
% Furthermore, the new syntax is far more robust,
% flexible and readable.
%
% Most of commands for description
% files haven't changed at all, though some of them has been
% reimplemented. Yet, handling of dialects has been
% much improved; there is a new |\SetLanguage| (the old one
% has been renamed to |\SetDialect|) and you can create
% a dialect at any time with |\DeclareDialect| without the restrictions
% of the now obsolete |\GenerateDialects|.
% \end{abstract}
%
%
% \section{Introduction}
%
% The package \textsf{polyglot} provides a new language selection
% system taking advantage of the features of \LaTeXe. It provides some
% utilities which make writing a language style quite easy and
% straightforward.
%
% Some of the features implemeted by polyglot are:
%
% \begin{itemize}
% \item You can switch between languages freely. You have not
% to take care of neither head lines nor toc and bib
% entries---the right language is always used.\footnote{Index
% entries follow a special syntax and
% the current version of \textsf{polyglot} cannot handle that. For this
% reason the index entries remain untouched and you may
% use language commands only to some extent.}
% You can even get just a few commands from a language, not all.
%
% \item ``Ligatures,'' which are shortcuts for diacritical
% marks; for instance, in French |^e| is a synonymous
% to |\^{e}|. Some other ligatures perform special actions,
% as Spanish |'r| which allows divide ``extrarradio'' as
% ``extra-radio''. A very cool feature: in most of cases,
% ligatures does not interfere with other definitions;
% for instance, with the \textsf{index} package
% |^{<entry>}| still works, provided the <entry> has
% two or more tokens.\footnote{And provided
% \textsf{index} is loaded before \textsf{polyglot}.
% \textsf{index} is a package by David Jones.}
%
% \item Dialects---small language variants---are supported. For
% instance American is a variant of English with another date
% format. Hyphenations patterns are attached to dialects and
% different rules for US and British English can be used.
%
% \item New glyphs are created if necessary. For instance, if
% you are using |OT1| the German umlauts are lowered, but if you
% switch to |T1| the actual font glyphs are used. Some other font
% encoding may have their own glyphs which will be used only
% with that encoding.
%
% \item Customization is quite easy---just redefine a command
% of a language with |\renewcommand| when the language
% is in force. The new definition will be remembered,
% even if you switch back and forth between languages.
%
% \item An unique layout can be used through the document,
% even with lots of languages. If you use a class with
% a certain layout you don't want to modify, you or the
% class can tell \textsf{polyglot} not to touch
% it at all.
% \end{itemize}
%
% \section{Quick start}
%
% \subsection{Installation}
%
% To install the package follow these steps:
% \begin{enumerate}
% \item First, run |polyglot.ins|. The files |polyglot.sty|,
% |polyglot.ltx|, |polyglot.def| and |polyglot.cfg| are generated.
%
% \item Remove |polyglot.ltx| and
% |polyglot.def| as they are not needed in the basic installation.
%
% \item Move |polyglot.sty| and |polyglot.cfg| as well as the files
% with extensions |.ld| and |.ot1| to a place where \LaTeX{}
% can find them.
% \end{enumerate}
%
% The files are:
%
% \begin{itemize}
% \item |polyglot.sty| is the file to be read with |\usepackage|.
%
% \item |polyglot.cfg| gives your system configuration.
%
% \item Languages are stored in files with
% extension |.ld|, as, for instance, |spanish.ld|, |english.ld|
% and so on.
%
% \item |polyglot.ltx| has some definitions for instalation of hyphenation
% patterns as well as preloading of languages and the \textsf{polyglot} style
% (actually |polyglot.def|).
%
% \item Finally, there are some files named like languages, but with extensions
% like font encodings.
% \end{itemize}
%
% Once installed, you can use polyglot.
% To write a, say, German document simply state the
% |german| option in the |\documentclass| and load
% the package with |\usepackage{polyglot}|.
% That's all. A new layout, with new commands,
% ligatures and, if the |OT1| encoding is in force,
% new glyphs will be available to you, as described
% at the end of this manual. If you are happy with
% that you need not go further; but if you are
% interested in advanced features (how to insert a
% Spanish date or how to create your own ligatures,
% for instance) just continue.
%
% \section{User Interface}
%
% \subsection{Groups}
%
% A language has a series of commands and variables (counters and lengths)
% stored in several groups. These groups are:
% \begin{description}
% \item[names] Translation of commands for titles, etc., following
% the international \LaTeX{} conventions.
% \item[layout] Commands and variables for the general layout of the
% document (|enumerate|, |itemize|, etc.)
% \item[date] Logically, commands concerning dates.
% \item[ligatures] A way to provide ligatures, i.e., shorthands for accented
% letters, and other special symbols.
% \item[text] Modifications of some typografical conventions: spacing
% before o after characters (French `:' or `;', Spanish `\%'), etc.
% \item[tools] Supplemetary command definitions.
% \end{description}
% These groups belong to two categories: names, layout, and date are
% considered \emph{document} groups, since they are intended for
% formatting the document; ligatures, tools and text, are considered
% \emph{text} groups, since you will want to use them temporarily
% for a short text in some language.
%
% \subsection{Selecting a Language}
%
% You must load languages with |\usepackage|:
% \begin{sample}
% |\usepackage[english,spanish]{polyglot}|
% \end{sample}
%
% Global options (those of |\documentclass|) will be recognized as usual.
% The very first language will be automatically
% selected (with the starred version, see below).
% For this purpose, class options are taken in consideration \emph{before} package
% options. (Perhaps this is not the usual convention in \LaTeXe, but it is
% more logical; in general, you will state the main language as class option
% and the secondary ones as package options.) You can cancel this automatic
% selection with the package option |loadonly|:
% \begin{sample}
% |\usepackage[german,spanish,loadonly]{polyglot}|
% \end{sample}
%
% \begin{cmd}
% |\selectlanguage*[<no-groups>]{<language>}|
% \end{cmd}
%
% Selects all groups from <language>, except if there is the optional
% argument. <no-groups> is a list of groups \emph{not} to be selected, in the
% form |no<group>,no<group>,...|. For instance, if you dislike
% using ligatures:
% \begin{sample}
% |\selectlanguage*[noligatures]{french}|
% \end{sample}
% This command also sets defaults to be used by the
% unstarred version (see below).
%
% \begin{cmd}
% |\selectlanguage[<groups>]{<language>}|
% \end{cmd}
%
% Where <groups> is a list of <group>s and/or |no<group>|s.
%
% There are three posibilities:
% \begin{itemize}
% \item When a group is cited in the form <group>
% (e.g., |date| or |names|), this group is selected
% for the current language, i.e., that of the current
% |\selectlanguage|.
%
% \item When a group is cited in the form |no<group>|
% (e.g., |nodate| or |nonames|), this group is cancelled.
%
% \item When a group is not cited, then the default, i.e., that
% set by the |\selectlanguage*| in force, is used; it can be
% a |no|-form, and then the group will be disabled if
% necessary. If there is
% no a previous starred selection, the |no|-form will be
% presumed in all of groups.
% \end{itemize}
% If no optional argument is given, then |text,ligatures,tools| are
% presumed. Thus, at most two languages are selected at time.
%
% Here is an example:
% \begin{sample}
% |\selectlanguage*[noligatures]{spanish}|\\
% Now we have Spanish |names|, |date|, |layout|, |text| and |tools|,\\
% but no |ligatures| at all.\\
% |\selectlanguage[date,notools]{french}|\\
% Now we have Spanish |names|, |layout| and |text|, French |date|,\\
% but neither |ligatures| nor |tools|.\\
% |\selectlanguage[ligatures]{german}|\\
% Now we have Spanish |names|, |date|, |layout|, |text| and |tools|,\\
% and German |ligatures|.\\
% \end{sample}
%
% Selection is always local. There is also the possibility
% to use |selectlanguage| as environment.
% \begin{sample}
% |\begin{selectlanguage}*[<no-groups>]{<language>} <text> \end{selectlanguage}|\\
% |\begin{selectlanguage}[<groups>]{<language>} <text> \end{selectlanguage}|
% \end{sample}
%
% In general, you will use these commands without the optional
% argument---the starred version as command at the very
% beginning of documents and the starless version as environment
% in a temporary change of language.
%
% For the sake of clarity, spaces are ignored in the optional
% argument, so that you can write
% \begin{sample}
% |\selectlanguage[date, tools, no ligatures]{spanish}|
% \end{sample}
%
% \begin{cmd}
% |\uselanguage[<groups>]{<language>}{<text>}|
% \end{cmd}
%
% A command version of the |selectlanguage| environment, although only
% the unstarred version is allowed.
%
% \begin{cmd}
% |\unselectlanguage|
% \end{cmd}
%
% You can switch all of groups off
% with |\unselectlanguage|. Thus, you return to the
% original \LaTeX{} as far as \textsf{polyglot}
% is concerned.\footnote{Well, not exactly. But you
% should not notice it at all.}
%
% A typical file will look like this
% \begin{sample}
% |\documentclass[german]{...}|\\
% |\usepackage[spanish]{polyglot}|\\
% |\newenvironment{spanish}%|\\
% | {\begin{quote}\begin{selectlanguage}{spanish}}%|\\
% | {\end{selectlanguage}\end{quote}}|\\
% |\begin{document}|\\
% |Deutsche text|\\
% |\begin{spanish}|\\
% | Texto en espa'nol|\\
% |\end{spanish}|\\
% |Deutsche text|\\
% |\end{document}|\\
% \end{sample}
%
% Note that |\selectlanguage*{german}| is not necessary, since
% it is selected by the package. (Because there is no |loadonly|
% package option.)
%
% \subsection{Tools}
%
% \begin{cmd}
% |\thelanguage|
% \end{cmd}
%
% The name of the current language. You \emph{cannot} redefine this command
% in a document.
%
% \begin{cmd}
% |\languagelist|
% \end{cmd}
%
% A list of languages requested.
%
% \begin{cmd}
% |\allowhyphens|
% \end{cmd}
%
% Allows further hyphenation in words with the primitive |\accent|.
%
% \begin{cmd}
% |\hexnumber \octalnumber \charnumber|
% \end{cmd}
%
% Synonymous to |"|, |'| and |`| for numbers (|\hexnumber F3| $=$ |"F3|)
% provided for convenience.
%
% \begin{cmd}
% |\nofiles|
% \end{cmd}
%
% Not a new command really, but it has been reimplemented to optimize
% some internal macros related with file writing.
%
% \begin{cmd}
% |\ensurelanguage|
% \end{cmd}
%
% The \textsf{polyglot} package modifies internally some
% \LaTeX{} commands in order to do its best for making
% sure the current language is used
% in a head/foot line, even if the page is shipped out when another
% language is in force.
% Take for instance
% \begin{sample}
% (With |\selectlanguage*{spanish}|)\\
% |\section{Sobre la confecci'on de t'itulos}|
% \end{sample}
% In this case, if the page is broken inside, say, a German text
% |\ensurelanguage| restores |spanish| and hence the accents.
%
% Yet, some non-standard classes or packages can modify the marks.
% Most of times (but not always) |\ensurelanguage| solves
% the problem:\,\footnote{For instance, it will not work when the line is
% automatically capitalized.}
%
% \begin{sample}
% (With |\selectlanguage*{spanish}|)\\
% |\section{\ensurelanguage Sobre la confecci'on de t'itulos}|
% \end{sample}
% In typeset, writing and other modes it's ignored.
%
% \begin{cmd}
% |\ensuredcommand{<cmd>}{<text>}|
% \end{cmd}
%
% Saves the <text> in <cmd> so that you can
% use it in a ``ensured'' form later. Neither |\selectlanguage| nor |\uselanguage|
% can be passed in an argument---you must save the text with this command and then
% release it. The language is the
% current one. No arguments are allowed, and <text> is fragile, but
% a construction like |\uselanguage{...}{\ensuredcommand...}| is valid.
%
% Spanish |\chaptername| uses a |\'i| which is not
% set by standard |OT1| and hence is provided by |spanish.ot1|.
% If you use |\chaptername| in a text with, say, the German |text|
% group you will get an accented dotted i. In this
% case, you can use |\ensuredcommand|.
%
% \subsection{Extensions}
%
% The \textsf{polyglot} package provides \emph{extensions}
% so that its functionality will be extended to and from
% some package with the help of some commands
% in the |polyglot.cfg| file,
% sometimes with automatic loading. At the current moment,
% only font enconding extensions
% are implemented, which are automatically taken care of.
% (In future releases, you will be allowed
% to by-pass the current default settings, and add further extensions.)
%
% \subsubsection{Font Encoding Extensions}
%
% With the help of this extension, you are allowed
% to change some commands depending of font
% encodings. When a language is loaded, the package reads
% automatically the files named |<language-file>.<ENC>|,
% if they exist, where <language-file> is the exact name of the
% file |.ld| which the language is defined in, and <ENC>
% is the name of encodings declared. So, for instance, if you
% have preinstalled |T1| (besides |OMS|, etc.) and:
% \begin{sample}
% |\documentclass{article}|\\
% |\usepackage[LXX,OT1]{fontenc}|\\
% |\usepackage[spanish,german]{polyglot}|
% \end{sample}
% the following files will be read \emph{if they exist} (if not, nothing
% happens):
% \begin{sample}
% |spanish.t1 spanish.ot1 spanish.lxx spanish.oms |etc.\\
% | german.t1 german.ot1 german.lxx german.oms |etc.
% \end{sample}
% So, for example, |german.ot1| redefines some umlauted vowels in order to
% modify the accent position and to allow hyphenation.
%
% Loading of these files may be inhibited by means of the option
% |nofontenc| when calling \textsf{polyglot}:
% \begin{sample}
% |\usepackage[spanish,german,nofontenc]{polyglot}|
% \end{sample}
%
% \section{Developpers Commands}
%
% Some command names could seem inconsistent with that of the user commands. In
% particular, when you refer to a language in a document you are referring in fact
% to a dialect, which belogs to a language. As user, you cannot access to a
% language and you instead access to a dialect named like the language.
% From now on, when we say ``current language'' we mean
% ``current language or dialect.'' For more details on dialects, see below.
%
% \subsection{General}
%
% \begin{cmd}
% |\DeclareLanguage{<language>}|
% \end{cmd}
%
% The first command in the |.ld| must be this one. Files don't always
% have the same name as the language, so this command makes things work.
%
% \begin{cmd}
% |\DeclareLanguageCommand{<cmd-name>}{<group>}[<num-arg>][<default>]{<definition>}|
% \end{cmd}
%
% Stores a command in a group of the current language. The definition will be
% activated when the group is selected, and the old definition, if any,
% will be stored for later recovery if the group is switched off.
%
% There is a point to note (which applies also to the next commands).
% Suppose the following code:
% \begin{sample}
% At |spanish.ld|:\\
% |\DeclareLanguageCommand{\partname}{names}{Parte}|\\
% | |\\
% At document:\\
% |\selectlanguage*{spanish}|\\
% |\renewcommand{\partname}{Libro}|\\
% |\selectlanguage*{english}|\\
% |\partname|
% \end{sample}
% Obviously, at this point |\partname| is `Part'. But if you follow with
% \begin{sample}
% |\selectlanguage*{spanish}|\\
% |\partname|
% \end{sample}
% Surprise! \emph{Your} value of |\partname|, i.e., `Libro', is recovered. So
% you can customize easily these macros in your document, even if you switch
% back and forth between languages.
%
% \begin{cmd}
% |\SetLanguageVariable{<var-name>}{<group>}{<value>}|
% \end{cmd}
%
% Here <var-name> stands for the internal name of a counter or a lenght as
% defined by |\newconter| (|\c@...|) or |\newlenght|. The variable must be
% already defined. When the group is selected, the new value will be assigned to
% the variable, and the old one will be stored.
%
% \begin{cmd}
% |\SetLanguageCode{<code-cmd>}{<group>}{<char-num>}{<value>}|
% \end{cmd}
%
% Similar to |\SetLanguageVariable| but for codes. For instance:
% \begin{sample}
% |\SetLanguageCode{\sfcode}{text}{`.}{1000}|
% \end{sample}
%
% Languages with |\frenchspacing| should set the |\sfcodes| with this command, so
% that a change with |\nonfrenchspacing| is recovered after a switch.
%
% \begin{cmd}
% |\DeclareLanguageSymbolCommand{<char>}{<group>}[<num-arg>][<default>]{<definition>}|
% \end{cmd}
%
% First makes <char> active and then defines it just as
% |\DeclareLanguageCommand| does.
%
% For instance, in French:
% \begin{sample}
% |\DeclareLanguageSymbolCommand{:}{spacing}{\unskip\,:}|
% \end{sample}
% Note that this command \emph{does not} change the category yet,
% and hence the previous command is valid. (Well, except if the |:|
% is already active. If you want to avoid any infinite loop, you can just
% say |{\unskip\,\string:}|).
%
% \begin{cmd}
% |\UpdateSpecial{<char>}|
% \end{cmd}
%
% Updates |\dospecials| and |\@sanitize|. First removes <char>
% from both lists; then adds it if it has categorie
% other than `other' or `letter'. With this method we avoid duplicated
% entries, as well as removing a character being usually special (for
% instance |~|).
%
% \subsection{Groups}
%
% \begin{cmd}
% |\DeclareLanguageGroup{<group>}|\\
% |\DeclareLanguageGroup*{<group>}|
% \end{cmd}
%
% Adds a new group. With the starred version, the group will be
% considered a |text| group, and hence included in the default
% of |\selectlanguage|. Group names cannot begin with |no|
% because of the |no|-form convention given above.
%
% \subsection{Ligatures}
%
% \begin{cmd}
% |\DeclareLigatureCommand{<char-1>}{<char-2>}{<definition>}|
% \end{cmd}
%
% Makes the pair |<char-1><char-2>| a shorthand for <definition>.
% For instance:
% \begin{sample}
% |\DeclareLigatureCommand{"}{u}{\"u}|
% \end{sample}
% There are some points to note:
% \begin{itemize}
% \item Spaces between <char-1> and <char-2> are not significant. So
% |"u| and \verb*=" u= will give the same result. Be careful then.
% \item If <char-1> is followed by a char which there is no
% ligature for, the original value (i.e., the value of <char-1> at
% |\selectlanguage|) is used.
%
% \item If <char-1> is followed by an ``argument'' which is
% empty or with more
% than one token, its original value is also used. This is very important
% in order to break ligatures. In German, you get `\,''und' with
% |"{}und| or |"{und}|; in French, you get `C'est' with
% |C'{}est| or |C'{est}|; in Spanish, you write
% a non-breaking space before `n' with |~{}n|, and before `\~n', with
% |~{~n}| or |~~n|. If some package (there are in fact a lot) has defined,
% say, |^| with some special function which requires an argument,
% this will be keept in most of cases (multi-token arguments), even
% when we define |^| as a ligature; if the argument has only a token
% you may trick the |^| with, say, |^{e{}}| (two tokens, `e' and
% empty). In math mode, the original math meaning is used
% (even if the |\mathcode| was |"8000|).
%
% \item Some languages, such as Spanish, make active \lc{} and \rc{} in
% order to
% declare the ligatures \lc\lc{} and \rc\rc{} for guillemets. If you define
% macros testing some counters or lengths are lesser or greater,
% load the package with option |loadonly| and select the language
% after these commands.
%
% \item Any definitionn attached to a
% ligature char is preserved, even if not
% currently `active'. This makes switching a language very
% robust.\footnote{Don't try to change the catcode of a char to `other'
% before selecting a language
% in order to `lost' its definition---that won't work. Instead,
% let it to relax if you really need it.
% (In fact, \textsf{polyglot} uses three internal variables, the
% first storing the text value, the second the
% math value, and the third the definition, which is used
% when the catcode was `active' or the mathcode was |"8000|.)}
%
% \item Yet, an error is given
% when a ligature char has certain character codes
% at the selection, namely
% `escape' (|\|), `open' (|{|), `close' (|}|),
% `return' (|^^M|) or `comment' (|%|).
% This is a very unlikely situation and for the moment
% there is nothing I can do. Furthermore, `invalid' chars
% are validated (as `other') in the scope of the language.
% \end{itemize}
%
% \begin{cmd}
% |\DeclareLigature{<char-1>}|
% \end{cmd}
% In some instances, you might wish to declare a ligature char before
% |\DeclareLigatureCommand| (which has an implicit |\DeclareLigature|).
% (I wonder when, but here it is.)
%
% \subsection{Dates}
%
% \begin{cmd}
% |\DeclareDateFunction{<date-function-name>}{<definition>}|\\
% |\DeclareDateFunctionDefault{<date-function-name>}{<definition>}|\\
% |\DeclareDateCommand{<cmd-name>}{<definition>}|
% \end{cmd}
% By means of |\DeclareDateCommand| you can define commands like |\today|. The
% good news is that a special syntax is allowed in <definition> with date
% functions called with \lc<date-funtion-name>\rc. Here
% \lc<date-funtion-name>\rc{} stands for the definition given in
% |\DeclareDateFunction| for the current language. If no such function for
% the language is given then the definition of |\DeclareDateFunctionDefault|
% is used. See |english.ld| for a very illustrative example. (The
% \lc{} and \rc{} are actual lesser and greater signs.)
%
% Predeclared functions (with |\DeclareDateFunctionDefault|) are:
% \begin{itemize}
% \item \lc|d|\rc{} one or two digits day: 1, 2, \dots, 30, 31.
% \item \lc|dd|\rc{} two digits day: 01, 02, \dots
% \item \lc|m|\rc{} one or two digits month.
% \item \lc|mm|\rc{} two digits month.
% \item \lc|yy|\rc{} two digits year: 96, 97, 98, \dots
% \item \lc|yyyy|\rc{} four digits year: 1996, 1997, 1998, \dots
% \end{itemize}
%
% Functions which are not predeclared, and hence should be declared
% by the |.ld| file, are:
%
% \begin{itemize}
% \item \lc|www|\rc{} short weekday: mon., tue., wes., \dots
% \item \lc|wwww|\rc{} weekday in full: Monday, Tuesday, \dots
% \item \lc|mmm|\rc{} short month: jan., feb., mar., \dots
% \item \lc|mmmm|\rc{} month in full: January, February, \dots
% \end{itemize}
%
% The counter |\weekday| (also |\value{weekday}|) gives a number between 1
% and 7 for Sunday, Monday, etc.
%
% For instance:
% \begin{sample}
% |\DeclareDateFunction{wwww}{\ifcase\weekday\or Sunday\or Monday\or|\\
% | Tuesday\or Wesneday\or Thursday\or Friday\or Saturday\fi}|\\
% |\DeclareDateCommand{\weektoday}{|\lc|wwww|\rc
% |, |\lc|mmmm|\rc| |\lc|dd|\rc| |\lc|yyyy|\rc|}|
% \end{sample}
%
% \subsection{Dialects}
%
% As stated above, |\selectlanguage| access to dialects rather than
% languages. |\DeclareLanguage| declares both a language and a dialect
% with the same name, and selects the actual language.
%
% \begin{cmd}
% |\DeclareDialect{<dialect>}|\\
% |\SetDialect{<dialect>}|\\
% |\SetLanguage{<language>}|
% \end{cmd}
%
% |\DeclareDialect| declares a dialect, which shares all
% of declarations for the current actual language.
% With |\SetDialect| you set the dialect so that new declarations
% will belong only to
% this dialect. |\DeclareDialect| just declares but does not set it.
%
% A dialect with the same name as the language is always implicit.
% You can handle this dialect exactly as any other dialect.
% In other words, after setting the dialect, new
% declarations belong only to this one. If you want to return to the
% actual language, so that
% new declarations will be shared by all dialects, use |\SetLanguage|.
%
% Note that commands and variables declared for a language are
% set by |\selectlanguage| before those of dialects,
% doesn't matter the order you declared it.
%
% For example:
% \begin{sample}
% |\DeclareLanguage{english}|\\
% |\DeclareDialect{american}|\\
% Declarations\\
% |\SetDialect{english}|\\
% |\DeclareDateCommmand{\today}{...}|\\
% |\SetDialect{american}|\\
% |\DeclareDateCommand{\today}{...}|\\
% |\SetLanguage{english}|\\
% More declarations shared by both |english| and |american|
% \end{sample}
%
% \subsection{Font Encoding}
%
% \begin{cmd}
% |\DeclareLanguageCompositeCommand{<cmd>}{<encoding>}{<letter>}|%
% |[<arg-num>][<default>]{<definition>}|\\
% |\DeclareLanguageTextCommand{<cmd>}{<encoding>}|%
% |[<arg-num>][<default>]{<definition>}|
% \end{cmd}
%
% The equivalent to |\DeclareTextCompositeCommand|
% and |\DeclareTextCommand| in this package. (That's
% all.) New values are
% stored in the |text| group. No default versions are provided;
% default values may be assigned to the |?| encoding.
%
% A typical file looks like:
% \begin{sample}
% |\ProvidesFile{spanish.ot1}|\\
% |\def\spanish@acute#1{\allowhyphens\accent19 #1\allowhyphens}|\\
% |\DeclareLanguageCompositeCommand{\'}{OT1}{a}{\spanish@acute a}|\\
% |\DeclareLanguageCompositeCommand{\'}{OT1}{A}{\spanish@acute A}|\\
% (And so on.)
% \end{sample}
%
% You may add files
% for your local encodings, and you can modify the files supplied
% with the package (mainly for |OT1|) provided you state clearly at
% their beginning the changes and does not distribute them as part of
% the \textsf{polyglot} package.
%
% We note a very important point here. Perhaps |\DeclareLanguageCompositeCommand|
% change the internal definition of <cmd> which is not recovered after
% you exit from a language. You will not notice that in a document at all, but if
% you are trying to access to the original value you must do it before
% selecting the language for the first time.
% Yet, if <cmd> has a particular definition declared for
% this language, the old value \emph{will} be restored, as you can expect.
%
% |\PreLoadLanguage| loads
% these files always, but you cannot
% |\PreLoadLanguage|s with these encoding extensions for encoding schemes
% not preloaded. (As far as \LaTeX\ is concerned, they don't
% exist yet!) If you want them, there are two tactics:
% \begin{enumerate}
% \item Preloading the encoding in the corresponding |.cfg|
% \LaTeXe\ file. Then both encoding a the language extensions to it are
% directly available in your \LaTeX\ instalation.
% \item Accepting the fact these files
% will be loaded when typesetting the
% document.
% \end{enumerate}
% In order to avoid a new loading, you must
% move the files preloaded to a folder where \LaTeX\ cannot find them.
%
% \subsection{Interaction with Classes}
%
% \begin{cmd}
% |\pg@no<group>|\\
% (i.e. |\pg@nonames|, |\pg@nolayout|, |\pg@noligatures|, etc.)
% \end{cmd}
%
% Initially, these commands are not defined, but if they are, the
% corresponding groups are not loaded. This mechanism is intended
% for classes designed for a certain publication and with a
% very concrete layout which we don't want to be changed.
% You simply write in the class file
% \begin{sample}
% |\newcommand{\pg@nolayout}{}|
% \end{sample}
% Note this procedure does not ever load the group---if
% you select it nothing happens.
%
% \section{Configuration}
%
% There \emph{must} be a file called |polyglot.cfg| which will define the
% configuration for your system. This file consists of two parts, the first
% one being used by the installation procedure, and the second one mainly by
% |\usepackage|. When compilling \LaTeX, you must load in some point the file
% |polyglot.ltx| if you want to install hyphenation patterns other than
% English.
%
% \begin{cmd}
% |\PreLoadPatterns{<patterns>}{<hyphens-file>}|
% \end{cmd}
% Defines a new language with the patterns in <hyphens-file>. Internally,
% these languages will be referred to as |\pgh@<language>|.
%
% \begin{cmd}
% |\PreLoadLanguage{<language>}[<file>]{<patterns>}{<more>}|
% \end{cmd}
% Loads a language \emph{at the time of installation} so that the
% language has not to be read by |\usepackage|. Even more, if you only
% want preloaded languages, you needn't call |polyglot.sty| in your
% document at all. The file read is |<file>.ld|
% or, if no optional argument, |<language>.ld|; and <patterns> has to be any
% set preloaded with |\PreLoadPatterns|. This command also preloads
% |polyglot.def|. In the part <more> you may insert commands just between
% the loading of the |.ld| file and the
% final settings made by the command.
%
% In running
% time, this command is ignored.
%
% \begin{cmd}
% |\PreLoadPolyGlot|
% \end{cmd}
% Preloads |polyglot.def|, so that the style is directly available
% in your system.
%
% \begin{cmd}
% |\LoadLanguage{<language>}[<file>]{<patterns>}{<more>}|
% \end{cmd}
% Quite similar to |\PreLoadLanguage| but in running time (i.e., when read
% with |\usepackage|). In installation time
% this command is ignored.
%
% \begin{cmd}
% |\LanguagePath{<file-path>}|
% \end{cmd}
%
% Add a path to |\input@path|. (See |ltdirchk| and the
% \emph{Local Guide} for details.) If \textsf{polyglot} has been installed,
% this command will be ignored in running time.
%
% This is a tipical |polyglot.cfg|:
% \begin{sample}
% |\PreLoadPatterns{english}{hyphen.tex}|\\
% |\PreLoadPatterns{spanish}{sphyph.tex}|\\
% | |\\
% |\LoadLanguage{english}{english}|\\
% |\LoadLanguage{spanish}{spanish}|\\
% |\LoadLanguage{german}{english}|\\
% |\LoadLanguage{austrian}[german]{english}|\\
% |\LoadLanguage{french}{spanish}|
% \end{sample}
%
% \section{Installation}
%
% If you want install the package in your basic \LaTeX\ configuration,
% follow these steps:
% \begin{enumerate}
% \item First, run |polyglot.ins|. The files |polyglot.sty|,
% |polyglot.ltx|, |polyglot.def| and |polyglot.cfg| are generated.
% \item Create a file named |hyphen.cfg| which has to include the line
% \begin{sample}
% |\input{polyglot.ltx}|
% \end{sample}
% You may also rename |polyglot.ltx| as |hyphen.cfg|.
% \item Move the package and hyphen files where \LaTeX\ can find them.
% \item Modify |polyglot.cfg| following your requirements. At this
% stage, only |\LanguagePath|, |\PreLoadPatterns|, |\PreLoadPolyGlot|,
% and |\PreLoadLanguage| are mandatory, provided you want them and you
% won't remove nor modify later at all the |\PreLoadLanguage| commands.
% (Once installed
% you are allowed to add |\LoadLanguage|s to this file freely.)
% \item Run |latex.ltx|.
% \item If installation didn't failed, remove |polyglot.ltx| and
% |polyglot.def| as they are no longer needed.
% \end{enumerate}
%
% \section{Customization}
%
% ``Well, but I dislike |spanish.ld|.''
% You can customize easily a language once
% loaded, with new commands or by redefininig the existing ones.
% \begin{itemize}
% \item If want to redefine a language command, simply select the
% group of this language which defines it
% (as with |\selectlanguage*|) and then
% redefine it with |\renewcommand|.
% \item If, in turn, you want to define a
% new command for a language, first
% make sure no language is selected
% (for instance, with |\unselectlanguage|).
% Then |\SetLanguage| and use the declaration
% commands provided by the
% package and described above.
% \end{itemize}
%
% A further step is creating a new file,
% by copying it, modifying the commands
% and, of course, renaming the file! Or with
% a file with extension |.ld| as:
% \begin{sample}
% |\ProvidesFile{...ld}|\\
% |\input{...ld} | the file you want customize\\
% |\selectlanguage*{...}|\\
% Commands to be redefined\\
% |\unselectlanguage|\\
% |\SetLanguage{...}|\\
% Commands to be created
% \end{sample}
% Then, add a line to |polyglot.cfg| with |\LoadLanguage|...
%
% \section{Errors}
%
% \begin{cmd}
% |Unknown group|
% \end{cmd}
%
% You are trying to assign a command to an inexistent group.
% Perhaps you have misspelled it.
%
% \begin{cmd}
% |Missing language file|
% \end{cmd}
%
% Probable causes:
% \begin{itemize}
% \item Wrong configuration, |\PreLoadLanguage|
% instead of |\LoadLanguage| with a language
% not preloaded.
%
% \item The corresponding |.ld| file is missing.
%
% \item Wrong path.
% \end{itemize}
%
% \begin{cmd}
% |Unknown language|
% \end{cmd}
%
% You forgot requesting it. Note that dialects
% stand apart from languages; i.e., you have no
% access to |austrian| just requesting |german|.
%
% \begin{cmd}
% |Invalid option skipped|
% \end{cmd}
%
% In the starred version of |\selectlanguage|
% you must use the |no|-forms only.
%
% \begin{cmd}
% |Bad ligature|
% \end{cmd}
%
% A very unlikely error which is generated by a bug in the
% description file of the current
% language, but also if some package has changed some categories
% to very, very extrange values.
%
% \begin{cmd}
% |Bug found (<n>)|
% \end{cmd}
%
% You will only find this error when using
% the developpers commands---never with the user ones---or if
% there is a bug in description files
% written by others. In the latter case, contact
% with the author. The meaning of the parameter <n> is
% \begin{enumerate}
% \item \emph{Unknown group in declaration.} The group hasn't been
% declared. Perhaps you misspelled it.
%
% \item \emph{Invalid group name.} Group names cannot begin
% with |no| to avoid mistakes when disabling a group.
%
% \item \emph{Declaration clash.} You are trying to
% redeclare a command or to set a new
% value to a variable for this language.
% If you want redefine it, select the language and simply
% use |\renewcommand| (or |\set..|).
% If you intend to define a new command
% for the language, sorry, you must change its name.
%
% \item \emph{Invalid language/dialect setting.} Generated by
% |\SetLanguage| or |\SetDialect| when the argument is not
% a declared language/dialect.
% \end{enumerate}
%
% Now we describe how polyglot generates \TeX{}
% and \LaTeX{} errors because of intrinsic syntax
% problems.
%
% \begin{cmd}
% |Argument of \pg@text@ligature has an extra }|
% \end{cmd}
%
% An usual problem with ligatures because the second
% letter is taken as a macro argument. If the first
% letter, for instance |"| in German, is followed
% by a |}| then |TeX| gets confused. For instance,
% \begin{sample}
% (Current language is German in full.)\\
% |\uselanguage[date]{english}{\emph{``\today"}}|
% \end{sample}
%
% Note that German ligatures are active. Fix:
% type |{}| just after |"|. (A ligature just before
% the closing |}| in |\uselanguage| is OK.)
%
% \begin{cmd}
% |TeX capacity exceeded, sorry [save_size=<n>]|
% \end{cmd}
%
% You are using to many ungrouped languages.
% Fix: use the environment version of |selectlanguage|
% or alternatively use |\unselectlanguage| before
% a new |\selectlanguage|.
%
% \section{Conventions}
%
% I strongly encourage the following conventions:
% \begin{itemize}
% \item Concerning dates, see above.
%
% \item There must be a main ligature, which will precede some special
% features. For instance, the obvious main ligature in German is |"|, and
% so we have \verb=""=, |"-|, |"ck|, etc.
%
% \item Default values for encodings, in the |.ld| file.
%
% \item A mandatory convention. The language names must consist of
% lowercase letters.
%
% \item Don't name your own language files with the name of some language.
% I'd like to reserve these to official descriptions,
% supported by myself or a group.
% \end{itemize}
%
% \section{Languages}
%
% Now follows a brief description of the languages provided. All of them
% include the group |names| and |\today| in |date|.
%
% \subsection{\texttt{american}}
%
% |english| dialect. Same as English with date in American format.
%
% \subsection{\texttt{austrian}}
%
% |german| dialect. Same as German with ``January'' in Austrian.
%
% \subsection{\texttt{english}}
%
% \begin{description}
% \item[date] Functions \lc|ddd|\rc{} (ordinal date), \lc|mmm|\rc,
% \lc|mmmm|\rc{}, \lc|www|\rc{} and \lc|wwww|\rc.
% \item[tools] |\arabicth{<counter>}|: ordinal form of <counter>.
% \end{description}
%
% \subsection{\texttt{french}}
%
% \begin{description}
% \item[date] Functions \lc|ddd|\rc{} (ordinal first),
% \lc|mmmm|\rc{} and \lc|wwww|\rc{}.
% \item[layout] |itemize| with |--|. Paragraph after section
% indented.
% \item[ligatures] Accents |`a|, |`e|, |`u|, |'e|, |^a|,
% |^e|, |^i|, |^o|, |^u|, |"y|, |"e| and |/c| (also uppercase).
% Composite letters |"ae| and |"oe| (also uppercase).
% Guillemets with automatic
% spacing \lc\lc{} and \rc\rc.
% \item[text] |OT1| guillemets and accents. Spaces before
% double punctuation signs. French spacing.
% \item[tools] |\sptext{<text>}|: small and raised text for
% abbreviations.
% \end{description}
%
% \subsection{\texttt{german}}
%
% \begin{description}
% \item[date] Functions \lc|mmm|\rc,
% \lc|mmm|\rc, \lc|www|\rc{} and \lc|wwww|\rc.
% \item[ligatures] Accents |"a|, |"e|, |"i|, |"o|,
% |"u| (also uppercase). Scharfes s |"s| and |"S|.
% Hyphenation |"ck|, |"ff|, |"ll|, etc. German quotes
% |"`| and |"'|. Guillemets |"|\lc{} and |"|\rc. Other |"-|,
% {\ttfamily\string"\string|} and |""|.
% \item[text] |OT1| guillemets, german quotes and accents
% (with lower umlauts in a, o and u).
% \end{description}
%
% \subsection{\texttt{spanish}}
%
% A new group |math| is defined for some functions names: |\lim|
% giving l\'\i m, |\tg|, etc.
%
% \begin{description}
% \item[date] Functions \lc|mmm|\rc,
% \lc|mmmm|\rc, \lc|www|\rc{} and \lc|wwww|\rc.
% \item[layout] |itemize| with |---|. |enumerate| with ``1.'',
% ``\emph{a})'', ``1)'', ``\emph{a}$'$)''. |\fnsymbol|
% produces one, two, three\ldots{} asteriscs. |\alpha|
% includes the letter ``\~n''.
% \item[ligatures] Accents |'a|, |'e|, |'i|, |'o|,
% |'u|, |"u|, |'c| (\c{c}), |~n| $=$ |'n| (also uppercase).
% Hyphenation |'rr| and |'-|.
% \item[text] |OT1| guillemets and accents. French
% spacing. Space before |\%|.
% \item[tools] |\sptext{<text>}|: small and raised text for
% abbreviations (the preceptive dot is included). |\...|
% for ellipsis.
% \end{description}
%
% \section{Comming soon}
%
% \begin{itemize}
% \item More extension facilities.
%
% \item Time, besides date, will be supported.
%
% \item Multiple ligatures (with three or more chars).
%
% \item Ligatures in index entries, which will
% provide automatic ``alphabetize as''.
% (By expanding, say, French |"oeil| into
% |oeil@\oe il| or a similar
% device.)
%
% \item Plain \TeX\ compatibility. (Not a priority.)
%
% \item Modularity, so that only required commands will be loaded. (Since this
% is one of the goals of \LaTeX3, is very unlikely I implement this
% point before the release of the new \LaTeX.)
%
% \item Releasing of unnecessary commands, if required. (For example, if
% you are going to use just a language.)
%
% \item More languages. (My goal is not to provide a large set of language files
% but rather a set of tools for users---\TeX{} groups in particular.
% I will answer to people asking for help, and of course
% contributions will be credited.)
%
% \end{itemize}
%
% \StopEventually{}
%
%<*driver>
\documentclass{article}
\usepackage{doc}
\addtolength{\topmargin}{-3pc}
\addtolength{\textwidth}{6pc}
\addtolength{\oddsidemargin}{-2pc}
\addtolength{\textheight}{7pc}
\def\lc{\texttt{\string<}}
\def\rc{\texttt{\string>}}
\DeclareRobustCommand{\cs}[1]{\texttt{\char`\\#1}}
\newenvironment{cmd}%
{\par\addvspace{4.5ex plus 1ex}%
\vskip-\parskip\small
\renewcommand{\arraystretch}{1.2}%
\noindent\hspace{-\leftmargini}%
\begin{tabular}{|l|}\hline\ignorespaces}
{\\\hline\end{tabular}\nobreak\par\nobreak
\vspace{2.3ex}\vskip-\parskip}
\newenvironment{sample}{\small\quote}{\endquote}
\catcode`>=11
\catcode`<=\active
\def<#1>{\textit{#1}}
\catcode`|=\active
\gdef|{\verb|\def<{|\syntx}}
\gdef\syntx#1>{\textit{#1}|}
\raggedright
\parindent1em
\nofiles
\OnlyDescription
\begin{document}
\DocInput{polyglot.dtx}
\end{document}
%</driver>
%
% \section{The File |polyglot.ltx|}
%
% Internal code is still evolving.
%
% \begin{macrocode}
%<*install>
\count19=-1 % The language allocator
\def\LanguagePath#1{\edef\input@path{\input@path{#1}}}
% \end{macrocode}
%
% The |\csname| trick by-passes the |\outer| checking.
%
% \begin{macrocode}
\def\PreLoadPatterns#1#2{%
\csname newlanguage\expandafter\endcsname\csname pgh@#1\endcsname
\language\csname pgh@#1\endcsname
\input{#2}}
\def\SetPatterns#1#2{\expandafter\chardef
\csname pgh@#1\endcsname#2\relax}
\def\PreLoadPolyGlot{%
\ifx\pg@add@to\@undefined\input{polyglot.def}\fi}
\def\PreLoadLanguage#1{\PreLoadPolyGlot
\@ifnextchar[{\pg@load{#1}}{\pg@load{#1}[#1]}}
\def\pg@load#1[#2]{\pg@input{#1}{#2}}
\def\pg@@{pg-}
\def\pg@input#1#2#3#4{%
\pg@to@list{#1}%
\@ifundefined{pgh@#1}%
{\expandafter\let\csname pgh@#1\expandafter\endcsname
\csname pgh@#3\endcsname%
\PackageInfo{polyglot}%
{#1 with #3 patterns\@gobble}}\@empty
\@ifundefined{\pg@@?#1}%
{\InputIfFileExists{#2.ld}{}%
{\pg@err{Missing language file}}%
\pg@extensions{#2}}\@empty
\edef\thelanguage{\csname\pg@@?#1\endcsname}#4}
\def\LoadLanguage#1#2#{\@gobbletwo}
\input{polyglot.cfg}
\language\z@
\let\LanguagePath\@gobble
\let\PreLoadPatterns\@gobbletwo
\def\PreLoadLanguage#1{%
\@ifnextchar[{\pg@preld{#1}}{\pg@preld{#1}[#1]}}
\def\pg@preld#1[#2]#3#4{%
\DeclareOption{#1}{\@ifundefined{pge@#2}%
{\pg@extensions{#2}\@namedef{pge@#2}{}}\@empty}}
\def\LoadLanguage#1{\@ifnextchar[{\pg@load{#1}}{\pg@load{#1}[#1]}}
\def\pg@load#1[#2]#3#4{%
\DeclareOption{#1}{\pg@input{#1}{#2}{#3}{#4}}}
%</install>
% \end{macrocode}
%
% \section{The Files |polyglot.sty| and |polyglot.def|}
%
% These files are quite similar.
%
% \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{polyglot}[1997/02/05 Multilingual LaTeX Package]
\DeclareOption{nofontenc}{\let\pg@extensions\@gobble}
\DeclareOption{loadonly}{\let\pg@sel@opt\relax}
% \end{macrocode}
%
% If we preloaded |polyglot| only this short code will
% be executed. We simply test if |\pg@add@to| is defined.
%
% \begin{macrocode}
\ifx\pg@add@to\@undefined\else % ie, if preloaded
\input{polyglot.cfg}
\ProcessOptions
\pg@sel@opt
\expandafter\endinput\fi
%</package>
% \end{macrocode}
%
% Some shortcuts to save memory, and initial settings.
%
% \begin{macrocode}
%<*preload|package>
\chardef\f@@r=4
\newcount\pg@count
\def\pg@@{pg-}
\def\pg@@text{pg-text-}
\def\pg@@math{pg-math-}
\def\pg@flag#1{\csname\pg@@#1-flag\endcsname}
\def\pg@@flag#1{\pg@@#1-flag}
\def\pg@last{{}{}}
\def\pg@err#1{\PackageError{polyglot}{#1}%
{See polyglot documentation for explanation}}
% \end{macrocode}
%
% If there is |\nofiles|, some commands are
% canceled to save memory and speed up typesetting.
%
% \begin{macrocode}
\AtBeginDocument{\if@filesw\else
\def\pg@file@setup#1#2#3{}%
\let\pg@file@write\@gobble
\let\pg@file@ends\relax\fi}
\def\pg@bug@err#1{\pg@err{Bug found (#1)}}
% \end{macrocode}
%
% \subsection{Internal Tools}
%
% Language commands are stored at commands in the
% form |pg-!<language>-<group>| or |pg-<language>-<group>|.
% The best way to
% understand them is with |\show|. The next command
% add something (implicit second argument) to a group (|#1|)
% of the current language (\thelanguage|)
%
% \begin{macrocode}
\def\pg@add@to#1{%
\@ifundefined{\pg@@flag{#1}}%
{\pg@err{Unknown group}}
{\@ifundefined{pg@no#1}%
{\@ifundefined{\pg@@\thelanguage-#1}%
{\expandafter\let\csname\pg@@\thelanguage-#1\endcsname\@empty}%
\@empty
\expandafter\pg@after
\csname\pg@@\thelanguage-#1\expandafter\endcsname}\@gobble}}
\@onlypreamble\pg@add@to
\def\pg@after#1#2{%
\expandafter\def\expandafter#1\expandafter{#1#2}}
\def\pg@to@list#1{\@ifundefined{languagelist}%
{\edef\languagelist{#1}}%
{\edef\languagelist{\languagelist,#1}}}
\@onlypreamble\pg@to@list
\def\pg@process#1#2{%
\begingroup\edef\pg@a{\endgroup
\noexpand\pg@xproc\noexpand#1#2,\noexpand\@nil,}\pg@a}
\def\pg@xproc#1#2,{\ifx\@nil#2\else
#1{#2}\expandafter\pg@xproc\expandafter#1\fi}
\def\pg@idend#1{#1\egroup}
% \end{macrocode}
%
% The following command returns |pg-#1-#2| (dialect form) if defined.
% If not, it returns |pg-!#1-#2| (language form). |#1| is either
% |\thelanguage| or |\pg@lig|.
%
% \begin{macrocode}
\long\def\pg@cmd#1#2{%
\pg@@
\expandafter\ifx\csname\pg@@?#1\endcsname\relax#1%
\else\expandafter\ifx\csname\pg@@#1-\string#2\endcsname\relax
\csname\pg@@?#1\endcsname
\else#1\fi\fi-\string#2}
% \end{macrocode}
%
% \subsection{Selecting a language}
%
% |\pg@ifno| tests if |#1#2| is |no|.
%
% \begin{macrocode}
\def\pg@ifno#1#2#3#4{%
\if#1n\if#2o#3\else\@firstoftwo\fi\else#4\fi}
\def\pg@step{\afterassignment\pg@groups\def\pg@elt##1}
\def\selectlanguage{%
\@ifstar{\pg@sel@i*}{\pg@sel@i{}}}
\def\pg@sel@i#1{\begingroup\catcode`\ =9 %
\@ifnextchar[{\pg@sel@ii{#1}{}}{\pg@sel@ii{#1}{}[]}}
\def\pg@sel@ii#1#2[#3]#4{%
\endgroup
\if!#1!%
\edef\pg@a{{\expandafter\@firstoftwo\pg@last}{[#3]{#4}}}%
\else
\def\pg@a{{[#3]{#4}}{}}%
\fi
\ifx\pg@a\pg@last\else
\let\pg@last\pg@a
\aftergroup\pg@file@ends
\pg@file@setup{#1}{#3}{#4}%
\pg@sel@iii#1[#3]{#4}%
\fi#2}
\def\pg@sel@iii#1[#2]#3{%
\@ifundefined{pgh@#3}%
{\pg@err{Unknown language}\language\z@}%
{\language\csname pgh@#3\endcsname}%
\pg@step{\ifcase\pg@flag{##1}\or\or
\@gobble\or\pg@disable{##1}\else
\advance\pg@flag{##1}-\tw@\fi}%
\let\thelanguage\pg@main
\def\pg@elt##1{\pg@a##1\pg@a}%
\if!#1!%
\def\pg@a##1##2##3\pg@a{%
\pg@ifno##1##2%
{\pg@ifgroup{##3}{\advance\pg@flag{##3}\f@@r}}%
{\pg@ifgroup{##1##2##3}%
{\pg@after\pg@d{\pg@elt{##1##2##3}}%
\advance\pg@flag{##1##2##3}\f@@r}}}%
\let\pg@d\@empty
\if!#2!\pg@text@groups\else
\pg@process\pg@elt{#2}\fi
\pg@step{\ifnum\pg@flag{##1}=\tw@\pg@enable{##1}\fi}%
\pg@step{\ifnum\pg@flag{##1}=\f@@r\pg@disable{##1}\fi}%
\pg@step{\pg@count\pg@flag{##1}%
\pg@flag{##1}\ifnum\pg@count>\thr@@\f@@r\else\z@\fi
\ifodd\pg@count\advance\pg@flag{##1}\@ne\fi}%
\edef\thelanguage{#3}%
\def\pg@elt##1{\pg@enable{##1}\advance\pg@flag{##1}-\tw@}%
\pg@d\let\pg@d\@undefined
\else
\pg@step{\ifnum\pg@flag{##1}=\z@\pg@disable{##1}\fi}%
\def\pg@elt##1{\pg@a##1\pg@a}%
\if!#2!\else%
\def\pg@a##1##2##3\pg@a{%
\pg@ifno##1##2%
{\pg@ifgroup{##3}{\advance\pg@flag{##3}-\@m}}% Just a mark
{\pg@err{Invalid option skipped}{}}}%
\pg@process\pg@elt{#2}%
\fi
\edef\pg@main{#3}%
\edef\thelanguage{#3}%
\pg@step{\ifnum\pg@flag{##1}<\z@\pg@flag{##1}\@ne
\else\pg@flag{##1}\z@\pg@enable{##1}\fi}%
\fi}
\def\uselanguage{\bgroup\begingroup\catcode`\ =9
\@ifnextchar[{\pg@sel@ii{}\pg@idend}%
{\pg@sel@ii{}\pg@idend[]}}
\def\unselectlanguage{\@ifstar{\selectlanguage[]{\pg@main}}%
{\pg@unsel@i\pg@unsel@ii}}
\def\pg@unsel@i{%
\c@pg@depth\z@\pg@file@ends
\def\pg@elt##1{%
\expandafter\let\csname\pg@@slot##1\endcsname\@empty}%
\pg@elt{}\pg@streams}
\def\pg@unsel@ii{%
\language\z@
\pg@step{\ifcase\pg@flag{##1}\or\or
\@gobble\or\pg@disable{##1}\fi}%
\pg@step{\ifnum\pg@flag{##1}=\z@\pg@disable{##1}\fi}%
\pg@step{\pg@flag{##1}\@ne}%
\let\thelanguage\@empty\let\pg@main\@empty
\def\pg@last{{}{}}}
\def\pg@enable#1{%
\let\pg@switch\@firstoftwo
\def\pg@group{#1}%
\edef\pg@a{\csname\pg@@?\thelanguage\endcsname}%
\expandafter\edef\csname\pg@@/#1\endcsname
{\edef\noexpand\thelanguage{\pg@a}%
\expandafter\noexpand\csname\pg@@\pg@a-#1\endcsname}%
\def\pg@b##1\pg@b{%
\let\thelanguage\pg@a
\@nameuse{\pg@@\thelanguage-#1}%
\edef\thelanguage{##1}%
\expandafter\pg@after\csname\pg@@/#1\endcsname
{\edef\thelanguage{##1}%
\csname\pg@@##1-#1\endcsname}%
\@nameuse{\pg@@\thelanguage-#1}}%
\expandafter\pg@b\thelanguage\pg@b}
\def\pg@disable#1{%
\let\pg@switch\@secondoftwo
\csname\pg@@/#1\endcsname
\expandafter\let\csname\pg@@/#1\endcsname\relax}
\def\pg@sel@opt{%
\@tempswatrue
\def\pg@d##1{\@ifundefined{pgh@##1}\@empty
{\if@tempswa
\PackageInfo{polyglot}%
{Selecting document language:\MessageBreak
##1\@gobble}%
\selectlanguage*{##1}\@tempswafalse\fi}}%
\ifx\@classoptionslist\@empty\else
\pg@process\pg@d\@classoptionslist\fi
\ifx\@curroptions\@empty\else
\if@tempswa\pg@process\pg@d\@curroptions\fi\fi
\let\pg@d\@undefined}
\@onlypreamble\pg@sel@opt
% \end{macrocode}
%
% \subsection{Wrinting to files}
%
% \begin{macrocode}
\let\pg@immediate\relax
\def\pg@@slot{pg@slot@}
\def\pg@file@setup#1#2#3{%
\advance\c@pg@depth\@ne
\def\pg@elt##1{%
\expandafter\pg@after\csname\pg@@slot##1\endcsname
{\addtocounter{\pg@@slot\the\pg@count}\@ne
\pg@immediate\write\pg@count
{\pg@begin\noexpand\selectlanguage#1[#2]{#3}}}}%
\pg@elt\@empty\pg@streams}
\def\pg@file@write#1{%
\pg@count=#1\relax
\@ifundefined{c@\pg@@slot\the\pg@count}%
{\newcounter{\pg@@slot\the\pg@count}%
\pg@slot@\let\pg@elt\relax
\xdef\pg@streams{\pg@streams\pg@elt{\the\pg@count}}}{}%
{\@nameuse{\pg@@slot\the\pg@count}}%
\expandafter\gdef\csname\pg@@slot\the\pg@count\endcsname{}}
\def\pg@file@ends{%
\def\pg@elt##1%
{\ifnum\value{\pg@@slot##1}>\c@pg@depth
\pg@immediate\write##1{\pg@end}%
\addtocounter{\pg@@slot##1}\m@ne
\expandafter\pg@elt\else\expandafter\@gobble\fi{##1}}%
\pg@streams\let\pg@elt\relax}%
\let\pg@streams\@empty
\let\pg@slot@\@empty
\let\pg@begin\begingroup
\let\pg@end\endgroup
\newcounter{pg@depth}
\AtEndDocument{\unselectlanguage
\let\pg@immediate\immediate}
% \end{macromode}
%
% Now three \LaTeX\ commands are redefined. (Sad.) The
% first and the second to write a |\selectlanguage| if necessary.
% The third to sincronize |\bibitem| with the
% language selection, since
% originally is |\immediate|.
%
% \begin{macrocode}
\long\def\protected@write#1#2#3{%
\pg@file@write{#1}%
\begingroup
\let\thepage\relax
#2%
\let\LanguageLigature\string
\let\protect\@unexpandable@protect
\edef\reserved@a{\write#1{#3}}%
\reserved@a
\endgroup
\if@nobreak\ifvmode\nobreak\fi\fi}
\long\def\@writefile#1#2{%
\@ifundefined{tf@#1}\relax
{\pg@file@write{\csname tf@#1\endcsname}%
\@temptokena{#2}%
\pg@immediate\write\csname tf@#1\endcsname{\the\@temptokena}}}
\def\@lbibitem[#1]#2{\item[\@biblabel{#1}\hfill]%
\if@filesw
\protected@write\@auxout{}%
{\string\bibcite{#2}{\protect\pg@ensure\pg@last#1}}%
\fi\ignorespaces}
\def\DeclareLanguageCommand#1#2{%
\@ifundefined{\pg@cmd\thelanguage{#1}}%
{\pg@add@to{#2}{\pg@switch@cmd#1}%
\expandafter\newcommand
\csname\pg@@\thelanguage-\string#1\endcsname}%
{\pg@bug@err3}}
\@onlypreamble\DeclareLanguageCommand
\def\pg@switch@cmd#1{%
\pg@switch
{\ifx#1\@undefined
\expandafter\pg@after
\csname\pg@@/\pg@group\endcsname{\let#1\@undefined}%
\fi}{}%
\let\pg@c=#1%
\expandafter\let\expandafter
#1\csname\pg@@\thelanguage-\string#1\endcsname
\expandafter\let
\csname\pg@@\thelanguage-\string#1\endcsname=\pg@c}
\def\SetLanguageVariable#1#2{%
\@ifundefined{\pg@cmd\thelanguage{#1}}%
{\pg@add@to{#2}{\pg@switch@var{#1}}
\@namedef{\pg@@\thelanguage-\string#1}}%
{\pg@bug@err3}}
\@onlypreamble\SetLanguageVariable
\def\pg@switch@var#1{%
\edef\pg@c{\the#1}%
#1=\csname\pg@@\thelanguage-\string#1\endcsname\relax
\expandafter\edef\csname\pg@@\thelanguage-\string#1\endcsname{\pg@c}}
% \end{macrocode}
%
% \subsection{Special codes}
%
% \begin{macrocode}
\def\SetLanguageCode#1#2#3{\pg@count=#3\relax
\edef\pg@a{\noexpand\SetLanguageVariable
{\noexpand#1\the\pg@count}}%
\pg@a{#2}}
\@onlypreamble\SetLanguageCode
\begingroup
\catcode`~=\active
\gdef\DeclareLanguageSymbolCommand#1#2{%
\SetLanguageCode{\catcode}{#2}{`#1}{\active}%
\def\pg@a{#2}%
\begingroup \lccode`~=`#1 \lccode`#1=`#1
\lowercase{\endgroup
\pg@add@to\pg@a{\UpdateSpecial{#1}}%
\DeclareLanguageCommand{~}\pg@a}}
\endgroup
\@onlypreamble\DeclareLanguageSymbolCommand
% \end{macrocode}
%
% \subsection{Declaring things}
%
% \begin{macrocode}
\def\DeclareLanguage#1{%
\def\thelanguage{!#1}%
\@namedef{\pg@@?#1}{!#1}%
\def\pg@main{!#1}}
\def\DeclareDialect#1{%
\expandafter\let\csname\pg@@?#1\endcsname\pg@main}
\@onlypreamble\DeclareLanguage
\@onlypreamble\DeclareDialect
\def\SetLanguage#1{%
\@ifundefined{\pg@@?#1}%
{\pg@bug@err4}%
{\edef\thelanguage{!#1}}}
\def\SetDialect#1{
\@ifundefined{\pg@@?#1}%
{\pg@bug@err4}%
{\edef\thelanguage{#1}}}
\@onlypreamble\SetLanguage
\@onlypreamble\SetDialect
% \end{macrocode}
%
% \subsection{Groups}
%
% \begin{macrocode}
\def\pg@ifgroup#1{\@ifundefined{\pg@@flag{#1}}%
{\pg@bug@err1\@gobble}}
\def\DeclareLanguageGroup{%
\@ifstar{\pg@newgroup\pg@c}%
{\pg@newgroup\pg@text@groups}}
\def\pg@newgroup#1#2{%
\def\pg@a##1##2##3\pg@a{%
\pg@ifno##1##2}%
\pg@a#2\pg@a
{\pg@bug@err2}%
{\@ifundefined{\pg@@flag{#2}}%
{\pg@after\pg@groups{\pg@elt{#2}}%
\pg@after#1{\pg@elt{#2}}%
\expandafter\newcount\csname\pg@@flag{#2}\endcsname
\pg@flag{#2}\@ne}%
{\PackageInfo{polyglot}%
{Ignoring group declaration: #2.^^J%
Already declared\@gobble}}}}
\@onlypreamble\DeclareLanguageGroup
\@onlypreamble\pg@newgroup
\let\pg@groups\@empty
\let\pg@text@groups\@empty
\let\pg@c\@empty
\DeclareLanguageGroup*{names}
\DeclareLanguageGroup*{layout}
\DeclareLanguageGroup*{date}
\DeclareLanguageGroup{ligatures}
\DeclareLanguageGroup{text}
\DeclareLanguageGroup{tools}
% \end{macrocode}
%
% \section{Date}
%
% \begin{macrocode}
\def\DeclareDateFunctionDefault#1{%
\expandafter\providecommand\csname\pg@@ DF-#1\endcsname}
\def\DeclareDateFunction#1{%
\expandafter\DeclareLanguageCommand
\csname\pg@@ DF-#1\endcsname{date}}
\@onlypreamble\DeclareDateFunctionDefault
\@onlypreamble\DeclareDateFunction
\begingroup
\catcode`<=\active
\gdef\DeclareDateCommand#1{%
\begingroup
\let\protect\@unexpandable@protect
\catcode`<=\active
\def<##1>{\expandafter\noexpand\csname\pg@@ DF-##1\endcsname}%
\def\pg@a{%
\edef\pg@b{\endgroup%
\noexpand\DeclareLanguageCommand{\noexpand#1}{date}{\pg@c}}
\pg@b}%
\afterassignment\pg@a\def\pg@c}
\endgroup
\@onlypreamble\DeclareDateCommand
\newcount\weekday
\let\c@day\day
\let\c@weekday\weekday
\let\c@month\month
\let\c@year\year
\def\SetWeekDay{\pg@count=\year\divide\pg@count4
\weekday=\pg@count
\multiply\pg@count4
\advance\pg@count-\year
\ifnum\pg@count=\z@
\ifnum\month<\thr@@\advance\weekday -1\fi\fi
\advance\weekday\year
\advance\weekday-1899
\advance\weekday\ifcase\month\or0 \or31 \or59 \or90 \or120
\or151 \or181 \or212 \or243 \or293 \or304 \or334 \fi
\advance\weekday\day
\pg@count=\weekday
\divide\pg@count7
\multiply\pg@count7
\advance\weekday-\pg@count
\advance\weekday\@ne}
\SetWeekDay
\DeclareDateFunctionDefault{d}{\the\day}
\DeclareDateFunctionDefault{dd}{\ifnum\day<10 0\fi\the\day}
\DeclareDateFunctionDefault{m}{\the\month}
\DeclareDateFunctionDefault{mm}{\ifnum\month<10 0\fi\the\month}
\DeclareDateFunctionDefault{yy}{\expandafter\@gobbletwo\the\year}
\DeclareDateFunctionDefault{yyyy}{\the\year}
% \end{macrocode}
%
% \subsection{Ligatures}
%
% \begin{macrocode}
\def\pg@lig{\ifcase\pg@flag{ligatures}\pg@main\or\or
\@gobble\or\thelanguage\fi}
\def\pg@cs@lig{%
\ifmmode\expandafter\pg@math@ligature
\else\expandafter\pg@text@ligature\fi}
\def\LanguageLigature{%
\ifx\protect\@unexpandable@protect
\expandafter\noexpand
\else\ifx\protect\@typeset@protect
\expandafter\expandafter\expandafter\pg@cs@lig
\else\expandafter\expandafter\expandafter\protect
\fi\fi}
\begingroup
\catcode`~=\active
\gdef\DeclareLigature#1{%
\pg@add@to{ligatures}{\pg@switch{\pg@set@lig{#1}}{}}%
\begingroup \lccode`~=`#1 \lccode`#1=`#1
\lowercase{\endgroup
\DeclareLanguageSymbolCommand{#1}{ligatures}%
{\LanguageLigature~}}}
\endgroup
\@onlypreamble\DeclareLigature
% \end{macrocode}
%\begin{verbatim}
%\def\DeclareLigatureSubtitution#1#2{%
% \@ifundefined{\pg@@root}\@empty
% {\pg@err{Ligature subtitution in dialect}%
% {You cannot subtitute a ligature after^^J%
% \string\GenerateDialects}}%
% \pg@add@to{ligatures}%
% {\@namedef{\pg@@text\string#1}{#2}}}
%\end{verbatim}
%
% The optional argument will be used in index
% entries. Not yet implemented.
%
% \begin{macrocode}
\def\DeclareLigatureCommand#1#2{%
\@ifnextchar[%
{\pg@declare@lig{#1}{#2}}%
{\pg@declare@lig{#1}{#2}[]}}
\def\pg@declare@lig#1#2[#3]{%
\@ifundefined{\pg@cmd\thelanguage{#1}}%
{\DeclareLigature{#1}}\@empty
\@ifundefined{\pg@cmd\thelanguage{#1-\string#2}}%
{\@namedef{\pg@@\thelanguage-\string#1-\string#2}}%
{\pg@bug@err3}}
\@onlypreamble\DeclareLigatureCommand
% \end{macrocode}
%
% We need take care of categorie codes because they can
% be changed by a package or by the user. Most of them
% perform the same action does not matter its char code;
% however, 11 and 12 mean ``I print myself'' and 13
% means ``I'm a command''. The right char is
% set by |\lccode|. Here |^^<letter>| is conventional, and
% is used for letter (|L|), and other (|O|).
% If the setting is valid, |\pg@b| expands to
% |\let \pg@text@<char> <other char>| but if not it
% expands simply to |\let \pg@text@<char>| which
% gobbles |\@gobbletwo| and makes the error to be
% expanded.
%
% \begin{macrocode}
\begingroup
\catcode`\$=3 \catcode`\&=4
\catcode`\#=6
\catcode`\^=7 \catcode`\_=8
\catcode`\ =10 \gdef\pg@space{ }
\catcode`\^^L=11 \catcode`\^^O=12
\catcode`\~=13
\gdef\pg@set@lig#1{\begingroup
\lccode`^^L=`#1 \lccode`^^O=`#1 \lccode`~=`#1 \lccode`#1=`#1
\lowercase{\endgroup
\edef\pg@b{\noexpand\let
\expandafter\noexpand\csname\pg@@text\string#1\endcsname
\ifcase\catcode`#1 \or\or\or$\or&\or
\or####\or^\or_\or\or\noexpand\pg@space
\or ^^L\or^^O\or\noexpand~\or\or^^O\fi}%
\pg@b\@gobbletwo\pg@lig@err{\string#1}%
\expandafter\let\csname\pg@@math\string#1\expandafter
\endcsname\csname\pg@@text\string#1\endcsname
\ifnum\catcode`#1>10 \ifnum\catcode`#1<13 \ifnum\mathcode`#1="8000
\expandafter\let\csname\pg@@math\string#1\endcsname=~%
\fi\fi\fi}}
\endgroup
\def\pg@lig@err{\pg@err{Bad ligature}}
% \end{macrocode}
%
% In the following lines note the change of categories!
% This command checks there are exactly one token
% in the argument. Commands are long to handle the
% case the ligature comes at the end of a paragraph.
%
% \begin{macrocode}
\begingroup
\catcode`\%=12 \catcode`\&=14
\long\gdef\pg@text@ligature#1#2{&
\expandafter\if\expandafter%\@gobble#2%\@empty
\expandafter\pg@ligature\expandafter#1&
\else
\csname\pg@@text\string#1\expandafter\endcsname
\fi{#2}}
\endgroup
\long\def\pg@ligature#1#2{%
\expandafter\ifx\csname\pg@cmd\pg@lig{#1-\string#2}\endcsname\relax
\csname\pg@@text\string#1\expandafter\endcsname\expandafter#2%
\else
\csname\pg@cmd\pg@lig{#1-\string#2}\expandafter\endcsname
\fi}
\long\def\pg@math@ligature#1{%
\@nameuse{\pg@@math\string#1}}
\def\UpdateSpecial#1{\expandafter\pg@update@special
\csname\string#1\endcsname}
\def\pg@update@special#1{%
\def\pg@b##1##2{\ifnum`#1=`##2 \else
\noexpand##1\noexpand##2\fi}%
\def\pg@c##1##2{\ifnum\catcode`##2<\active
\ifnum\catcode`##2>10 \else\@firstoftwo\fi
\else\noexpand##1\noexpand##2\fi}%
\def\do{\pg@b\do}%
\def\@makeother{\pg@b\@makeother}%
\edef\dospecials{\dospecials\pg@c\do#1}%
\edef\@sanitize{\@sanitize\pg@c\@makeother#1}%
\let\do\relax
\def\@makeother##1{\catcode`##1=12\relax}}
\begingroup
\catcode`*=\active \catcode`^=7
\catcode`~=\active \catcode`'=12
\lccode`*=`^ \lccode`^=`^ \lccode`~=`' \lccode`'=`'
\lowercase{%
\gdef\pr@m@s{%
\ifx~\@let@token\let\@let@token='\fi
\ifx*\@let@token\let\@let@token=^\fi
\ifx'\@let@token
\expandafter\pr@@@s
\else\ifx^\@let@token
\expandafter\expandafter\expandafter\pr@@@t
\else
\egroup
\fi\fi}}
\endgroup
% \end{macrocode}
%
% \section{Tools}
%
% Take, for instance, catalan. We may say:
% |\DeclareLigatureCommand{`}{a}{\`a}|.
% This command cancels any possibility to say:
% |\counterx=`a|. The following commands allow us
% to subtitute |\charnumber| by |`|:
% |\counterx=\charnumber a|. The same applies to
% |"| (|\DeclareLigatureCommand{"}{A}{\"A}|) or |'|.
%
% \begin{macrocode}
\begingroup
\catcode`"=12 \catcode`'=12 \catcode``=12
\gdef\hexnumber{"}
\gdef\octalnumber{'}
\gdef\charnumber{`}
\endgroup
\def\allowhyphens{\ifhmode\nobreak\hskip\z@skip\fi}
\providecommand\@tabacckludge[1]{%
\expandafter\@changed@cmd\csname#1\endcsname\relax}
\def\ensurelanguage{\ifx\glossary\relax
\protect\pg@ensure\pg@last\fi}
\def\pg@ensure#1#2{%
\def\pg@a{{#1}{#2}}%
\ifx\pg@a\pg@last\else
\def\pg@a{#1}%
\ifx\pg@a\@empty\def\pg@c{\pg@unsel@ii}\else
\def\pg@c{\pg@sel@iii*#1}\fi
\def\pg@a{#2}%
\ifx\pg@a\@empty\else
\def\pg@a{#1}\edef\pg@b{\expandafter\@firstoftwo\pg@last}%
\ifx\pg@b\pg@a\expandafter\def\else\expandafter\pg@after\fi
\pg@c{\pg@sel@iii{}#2}%
\fi
\expandafter\pg@c
\fi}
\def\ensuredcommand#1#2{%
\expandafter\gdef\expandafter#1\expandafter
{\expandafter{\expandafter\pg@ensure\pg@last#2}}}
% \end{macrocode}
%
% Two \LaTeX\ commands for marks are redefined. (Sad.)
%
% \begin{macrocode}
\def\markboth#1#2{%
\gdef\@themark{{\ensurelanguage#1}{\ensurelanguage#2}}{%
\let\protect\@unexpandable@protect
\let\label\relax \let\index\relax \let\glossary\relax
\mark{\@themark}}\if@nobreak\ifvmode\nobreak\fi\fi}
\def\@markright#1#2#3{%
\gdef\@themark{{#1}{\ensurelanguage#3}}}
% \end{macrocode}
%
% \section{Font Encoding Commands}
%
% \begin{macrocode}
\def\DeclareLanguageCompositeCommand#1#2#3{%
\pg@add@to{text}{\pg@composite{#1}{#2}}%
\expandafter\DeclareLanguageCommand
\csname\expandafter\string\csname#2\endcsname
\string#1-\string#3\endcsname{text}}
\def\pg@composite#1#2{%
\@ifundefined{\pg@cmd\thelanguage{#1}}%
{\expandafter\let\csname\pg@@\thelanguage-\string#1\endcsname#1%
\expandafter\pg@after\csname\pg@@/text\endcsname
{\expandafter\let\expandafter
#1\csname\pg@@\thelanguage-\string#1\endcsname}}{}%
\expandafter\let\expandafter\reserved@a\csname#2\string#1\endcsname
\expandafter\expandafter\expandafter\ifx
\expandafter\@car\reserved@a\relax\relax\@nil \@text@composite \else
\edef\reserved@b##1{%
\def\expandafter\noexpand
\csname#2\string#1\endcsname####1{%
\noexpand\@text@composite
\expandafter\noexpand\csname#2\string#1\endcsname
####1\noexpand\@empty\noexpand\@text@composite
{##1}}}%
\expandafter\reserved@b\expandafter{\reserved@a{##1}}%
\fi}
\@onlypreamble\DeclareLanguageCompositeCommand
% \end{macrocode}
%
% The following code was written but eventually
% discarded. It was intended for an argument
% expanded in full with some others not expanded
% at all.
% \begin{verbatim}
% \def\pg@expand#1{\edef\pg@b{#1}%
% \afterassignment\pg@@expand\def\pg@c##1\pg@c}
% \pg@@expand{\expandafter\pg@c\pg@b\pg@c}
% \end{verbatim}
% For example, in |\SetLanguageCode|
% \begin{verbatim}
% \pg@expand{\the\count@}{\SetLanguageVariable{#1##1}}{#2}
% \end{verbatim}
%
% \begin{macrocode}
\def\DeclareLanguageTextCommand#1#2{%
\@ifundefined{\pg@cmd\thelanguage{#1}}%
{\DeclareLanguageCommand{#1}{text}%
{\pg@text@cmd{#1}{#2}}%
\expandafter\DeclareLanguageCommand
\csname#2\string#1\endcsname{text}}%
{\expandafter\let\expandafter\pg@a
\csname\pg@@\thelanguage-\string#1\endcsname
\expandafter\in@\expandafter\pg@text@cmd
\expandafter{\pg@a}%
\ifin@\def\pg@a{\expandafter\DeclareLanguageCommand
\csname#2\string#1\endcsname{text}}%
\expandafter\pg@a
\else\pg@bug@err3\fi}}
\@onlypreamble\DeclareLanguageTextCommand
\def\pg@text@cmd#1#2{%
\csname#2-cmd\expandafter\endcsname
\expandafter#1%
\csname#2\string#1\endcsname}
% \end{macrocode}
%
% \subsection{Extensions handling}
%
% Not yet implemented. |\pge@<language>| will keep
% track of loaded extensions; now is just a flag.
% The next command is provisional. (If you read the manual
% you have guessed it.)
%
% \begin{macrocode}
\def\pg@extensions#1{%
\edef\cdp@elt##1##2##3##4{%
\def\noexpand\DeclareCompositeLanguageCommand####1{%
\noexpand\pg@composite{####1}{##1}}%
\def\noexpand\DeclareTextLanguageCommand####1{%
\noexpand\pg@text{####1}{##1}}%
\noexpand\InputIfFileExists{#1.##1}{}{}}%
\cdp@list}
%</preload|package>
%<*package>
% \end{macrocode}
%
% \subsection{Loading requested languages}
%
% Some commands will be defined if you didn't
% use the installation procedure.
%
% \begin{macrocode}
\ifx\PreLoadPatterns\@undefined
\def\LanguagePath#1{\edef\input@path{\input@path{#1}}}
\let\PreLoadPatterns\@gobbletwo
\def\SetPatterns#1#2{\expandafter\chardef
\csname pgh@#1\endcsname=#2\relax}
\def\PreLoadLanguage#1#2#{\@gobbletwo}
\def\LoadLanguage#1{\@ifnextchar[{\pg@load{#1}}%
{\pg@load{#1}[#1]}}
\def\pg@load#1[#2]#3#4{%
\DeclareOption{#1}{\pg@input{#1}{#2}{#3}{#4}}}
\def\pg@input#1#2#3#4{%
\pg@to@list{#1}%
\@ifundefined{pgh@#1}%
{\expandafter\let\csname pgh@#1\expandafter\endcsname
\csname pgh@#3\endcsname%
\PackageInfo{polyglot}%
{#1 with #3 patterns\@gobble}}\@empty
\@ifundefined{\pg@@?#1}%
{\InputIfFileExists{#2.ld}{}%
{\pg@err{Missing language file}}%
\pg@extensions{#2}}\@empty
\edef\thelanguage{\csname\pg@@?#1\endcsname}#4}
\fi
%</package>
%<*preload>
\everyjob\expandafter{\the\everyjob\SetWeekDay}
%</preload>
%<*preload|package>
\@onlypreamble\PreLoadPatterns
\@onlypreamble\SetPatterns
\@onlypreamble\PreLoadLanguage
\@onlypreamble\LoadLanguage
\@onlypreamble\pg@input
\@onlypreamble\pg@load
%</preload|package>
%<*package>
\input{polyglot.cfg}
\ProcessOptions
\pg@sel@opt
%</package>
% \end{macrocode}
%
% \section{A basic |polyglot.cfg| file}
%
% \begin{macrocode}
%<*config>
\SetPatterns{english}{0}
\LoadLanguage{english}{english}{}
\LoadLanguage{american}[english]{english}{}
\LoadLanguage{french}{english}{}
\LoadLanguage{german}{english}{}
\LoadLanguage{austrian}[german]{english}{}
\LoadLanguage{spanish}{english}{}
\LoadLanguage{hebrew}[r_hebrew]{english}{}
%</config>
% \end{macrocode}
\endinput
% \Finale
|