Knowledge

Module:CountryData

Source 📝

310:{{ {{{1}}} | altlink = | flag alias-naval-1790 = Flag of French-Navy-Revolution.svg | link alias-coast guard = French Maritime Gendarmerie | border-coast guard = | flag alias-1848 = Drapeau france 1848.svg | flag alias = Flag of France.svg | variant = | flag alias-1814 = Flag of the Kingdom of France (1814-1830).svg | flag alias-1830 = Flag of France (1794–1815, 1830–1958).svg | alias = France | flag alias-1794 = Flag of France (1794–1815, 1830–1958).svg | flag alias-army = Flag of France.svg | flag alias-naval = Civil and Naval Ensign of France.svg | flag alias-navy = Civil and Naval Ensign of France.svg | flag alias-1848b = Flag of France (1794–1815, 1830–1958).svg | name = | size = | flag alias-1848a = Drapeau france 1848.svg | link alias-naval = French Navy | flag alias-1974 = Flag of France (lighter variant).svg | link alias-air force = French Air and Space Force | link alias-army = French Army | flag alias-coast guard = French Maritime Gendarmerie racing stripe.svg | flag alias-1790 = Flag of France (1790–1794).svg | flag alias-air force = Flag of France.svg | link alias-navy = French Navy }} 307:{{ {{{1}}} | alias = France | flag alias = Flag of France.svg | flag alias-1790 = Flag of France (1790–1794).svg | flag alias-1794 = Flag of France (1794–1815, 1830–1958).svg | flag alias-1814 = Flag of the Kingdom of France (1814-1830).svg | flag alias-1830 = Flag of France (1794–1815, 1830–1958).svg | flag alias-1848 = Drapeau france 1848.svg | flag alias-1848a = Drapeau france 1848.svg | flag alias-1848b = Flag of France (1794–1815, 1830–1958).svg | flag alias-1974 = Flag of France (lighter variant).svg | flag alias-naval = Civil and Naval Ensign of France.svg | flag alias-naval-1790 = Flag of French-Navy-Revolution.svg | flag alias-air force = Flag of France.svg | link alias-air force = French Air and Space Force | flag alias-coast guard = French Maritime Gendarmerie racing stripe.svg | border-coast guard = | link alias-coast guard = French Maritime Gendarmerie | flag alias-army = Flag of France.svg | link alias-army = French Army | link alias-naval = French Navy | flag alias-navy = Civil and Naval Ensign of France.svg | link alias-navy = French Navy | size = | name = | altlink = | variant = }} 21: 52: 84: 277:, because it transcludes the data template from Lua and converts it to a Lua table using the above function, picks the wanted parameter name, and returns it to wikicode, whereas other templates perform two simple non-Lua transclusions to get, in most cases, the same result. The Lua version does have the advantage that using it with a non-existing country data template returns "nil" (or the value of 297:
This function concatenates the fields of a data template into a string similar to what you get when transcluding it directly. It can be compared with a direct transclusion to test if a template is being converted to Lua correctly:
241:
If used from wikicode, this function returns the value of a single field in a data template. The first parameter is the country or other entity whose data to return; the second is the name of the field. For example,
150:
of the invoking module; the second is the country or other entity to get the data of. The optional third parameter is a table of parameters to pass into the data template; this may, for example, include
102: 360: 110: 352: 69:
very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is
135:
Extracts all parameters from a data template and returns them as a Lua table. This function is only usable from other Lua modules; invoke it using
1845: 348: 58: 336: 36: 367: 332: 32: 254:
for the fallback output if the wanted data template or field does not exist, the default for which is a literal "nil".
91: 230: 318: 40: 282: 120: 250:
to return a variant parameter value, with fallback to the main field value if the variant does not exist, and
1850: 62: 313:
Note that, like with all Lua tables, the order of entries is not preserved, so the parameters are mixed up.
70: 343: 98: 109:. The tested changes can be added to this page in a single edit. Consider discussing changes on the 229:
The function returns an empty table if a data template does not exist or does not conform to the
326: 66: 28: 301:{{#tag:pre|{{Country data France}}}} {{#tag:pre|{{#invoke:CountryData|gettemplate|France}}}} 8: 97:
To avoid major disruption and server load, any changes should be tested in the module's
271: 322: 261: 124: 106: 281:) rather than a redlink to the data template. See a comparison of the four at 1839: 15: 257:
Note: This is likely not quicker than wikicode-only alternatives such as
159:, which are used in the values of some sports alias parameters. E.g., 1630:--For testing, recreates the country data from the created Lua table 854:--Returns the parameters of a country data template as a Lua table 92:
approximately 416,000 pages, or roughly 1% of all pages
982:--Replace parameter delimiters with arbitrary control characters 652:-- Uses mw.loadData to cache data for the most-used templates 989:--to avoid clashes if param values contain equals/pipe signs 1392:--Returns a single parameter value from a data template 246:→ Flag of France.svg. The other parameters are 119:
This module has three functions to extract data from
861:--If not a valid data template, return empty table 244:{{#invoke:CountryData|getalias|France|flag alias}} 1837: 1687:--Concatenate fields into a template-like string 65:in use by a very large number of pages, or is 1082:--Loop over string and add params to table 18: 342:Editors can experiment in this module's 137:require('Module:CountryData').gettable( 1838: 965:"^%{%{safesubst: *%{%{%{1" 418:'Module:CountryData/summary' 78: 46: 13: 1846:Modules subject to page protection 699:'Module:CountryData/cache' 14: 1862: 82: 50: 19: 287:/Flagg tests#Lua-based getalias 292: 1: 179:'Module:CountryData' 7: 236: 146:The first parameter is the 130: 90:This Lua module is used on 10: 1867: 944:"^%{%{ *%{%{%{1" 316: 59:subject to page protection 1824: 1823: 1820: 1819: 1813: 1812: 1791: 1790: 1784: 1783: 1741: 1740: 1707: 1706: 1691: 1690: 1684: 1683: 1641: 1640: 1634: 1633: 1627: 1626: 1602: 1601: 1598: 1597: 1591: 1590: 1584: 1583: 1541: 1540: 1507: 1506: 1461: 1460: 1439: 1438: 1396: 1395: 1389: 1388: 1364: 1363: 1360: 1359: 1353: 1352: 1346: 1345: 1336: 1335: 1329: 1328: 1319: 1318: 1312: 1311: 1305: 1304: 1292: 1291: 1240: 1239: 1197: 1196: 1154: 1153: 1102: 1101: 1086: 1085: 1079: 1078: 1039: 1038: 993: 992: 986: 985: 979: 978: 972: 971: 917: 916: 865: 864: 858: 857: 851: 850: 814: 813: 810: 809: 803: 802: 766: 765: 759: 758: 752: 751: 718: 717: 675: 674: 656: 655: 649: 648: 585: 584: 487:"Country data " 123:(which are used for most 113:before implementing them. 105:subpages, or in your own 560: 559: 523: 522: 519: 518: 512: 511: 463: 462: 429: 428: 425: 424: 394: 393: 378: 377: 375: 161: 1282:"^flag alias" 368:Subpages of this module 1703:"{{ {{{1}}}" 327:Module:CountryData/doc 121:country data templates 221:"men's" 63:highly visible module 1851:Flag template system 24:Module documentation 1060:"}}%s*$ " 762:-- if not in cache 248:|variant= 231:standard structure 197:"France" 1014:"|(-)=" 117: 116: 77: 76: 1858: 1832: 1831: 1828: 1822: 1818: 1817: 1811: 1810: 1807: 1804: 1801: 1798: 1795: 1789: 1788: 1782: 1781: 1778: 1775: 1772: 1769: 1766: 1763: 1760: 1757: 1754: 1751: 1748: 1745: 1739: 1738: 1735: 1732: 1729: 1726: 1723: 1720: 1717: 1714: 1711: 1705: 1704: 1701: 1698: 1695: 1689: 1688: 1682: 1681: 1678: 1675: 1672: 1669: 1666: 1663: 1660: 1657: 1654: 1651: 1648: 1645: 1639: 1638: 1637:--Get data table 1632: 1631: 1625: 1624: 1621: 1618: 1615: 1612: 1609: 1606: 1600: 1596: 1595: 1589: 1588: 1582: 1581: 1578: 1575: 1572: 1569: 1566: 1563: 1560: 1557: 1554: 1551: 1548: 1545: 1539: 1538: 1535: 1532: 1529: 1526: 1523: 1520: 1517: 1514: 1511: 1505: 1504: 1501: 1498: 1495: 1492: 1489: 1486: 1483: 1480: 1477: 1474: 1471: 1468: 1465: 1459: 1458: 1455: 1452: 1449: 1446: 1443: 1437: 1436: 1433: 1430: 1427: 1424: 1421: 1418: 1415: 1412: 1409: 1406: 1403: 1400: 1394: 1393: 1387: 1386: 1383: 1380: 1377: 1374: 1371: 1368: 1362: 1358: 1357: 1351: 1350: 1344: 1343: 1340: 1334: 1333: 1327: 1326: 1323: 1317: 1316: 1310: 1309: 1303: 1302: 1299: 1296: 1290: 1289: 1286: 1283: 1280: 1277: 1274: 1271: 1268: 1265: 1262: 1259: 1256: 1253: 1250: 1247: 1244: 1238: 1237: 1234: 1231: 1228: 1225: 1222: 1219: 1216: 1213: 1210: 1207: 1204: 1201: 1195: 1194: 1191: 1188: 1185: 1182: 1179: 1176: 1173: 1170: 1167: 1164: 1161: 1158: 1152: 1151: 1148: 1145: 1142: 1139: 1136: 1133: 1130: 1127: 1124: 1121: 1118: 1115: 1112: 1109: 1106: 1100: 1099: 1096: 1093: 1090: 1084: 1083: 1077: 1076: 1073: 1070: 1067: 1064: 1061: 1058: 1055: 1052: 1049: 1046: 1043: 1037: 1036: 1033: 1030: 1027: 1024: 1021: 1018: 1015: 1012: 1009: 1006: 1003: 1000: 997: 991: 990: 984: 983: 977: 976: 970: 969: 966: 963: 960: 957: 954: 951: 948: 945: 942: 939: 936: 933: 930: 927: 924: 921: 915: 914: 911: 908: 905: 902: 899: 896: 893: 890: 887: 884: 881: 878: 875: 872: 869: 863: 862: 856: 855: 849: 848: 845: 842: 839: 836: 833: 830: 827: 824: 821: 818: 812: 808: 807: 801: 800: 797: 794: 791: 788: 785: 782: 779: 776: 773: 770: 764: 763: 757: 756: 750: 749: 746: 743: 740: 737: 734: 731: 728: 725: 722: 716: 715: 712: 709: 706: 703: 700: 697: 694: 691: 688: 685: 682: 679: 673: 672: 669: 666: 663: 660: 654: 653: 647: 646: 643: 640: 637: 634: 631: 628: 625: 622: 619: 616: 613: 610: 607: 604: 601: 598: 595: 592: 589: 583: 582: 579: 576: 573: 570: 567: 564: 558: 557: 554: 551: 548: 545: 542: 539: 536: 533: 530: 527: 521: 517: 516: 510: 509: 506: 503: 500: 497: 494: 491: 488: 485: 482: 479: 476: 473: 470: 467: 461: 460: 457: 454: 451: 448: 445: 442: 439: 436: 433: 427: 423: 422: 419: 416: 413: 410: 407: 404: 401: 398: 392: 391: 388: 385: 382: 364: 356: 340: 280: 276: 270: 266: 260: 253: 249: 245: 225: 222: 219: 216: 213: 210: 207: 204: 201: 198: 195: 192: 189: 186: 183: 180: 177: 174: 171: 168: 165: 158: 154: 149: 142: 86: 85: 79: 54: 53: 47: 44: 25: 23: 22: 1866: 1865: 1861: 1860: 1859: 1857: 1856: 1855: 1836: 1835: 1834: 1833: 1829: 1826: 1815: 1808: 1805: 1802: 1799: 1796: 1793: 1786: 1779: 1776: 1774:" = " 1773: 1770: 1767: 1764: 1761: 1758: 1755: 1752: 1749: 1746: 1743: 1736: 1733: 1730: 1727: 1724: 1721: 1718: 1715: 1712: 1709: 1702: 1699: 1696: 1693: 1686: 1679: 1676: 1673: 1670: 1667: 1664: 1661: 1658: 1655: 1652: 1649: 1646: 1643: 1636: 1629: 1622: 1619: 1616: 1613: 1610: 1607: 1604: 1593: 1586: 1579: 1576: 1573: 1570: 1567: 1564: 1561: 1558: 1555: 1552: 1549: 1546: 1543: 1536: 1533: 1530: 1527: 1524: 1521: 1518: 1515: 1512: 1509: 1502: 1499: 1496: 1493: 1490: 1487: 1484: 1481: 1478: 1475: 1472: 1469: 1466: 1463: 1456: 1453: 1450: 1447: 1444: 1441: 1434: 1431: 1428: 1425: 1422: 1419: 1416: 1413: 1410: 1407: 1404: 1401: 1398: 1391: 1384: 1381: 1378: 1375: 1372: 1369: 1366: 1355: 1348: 1341: 1338: 1331: 1324: 1321: 1314: 1307: 1300: 1297: 1294: 1287: 1284: 1281: 1278: 1275: 1272: 1269: 1266: 1263: 1260: 1257: 1254: 1251: 1248: 1245: 1242: 1235: 1232: 1229: 1226: 1223: 1220: 1217: 1214: 1211: 1208: 1205: 1202: 1199: 1192: 1189: 1186: 1183: 1180: 1177: 1174: 1171: 1168: 1165: 1162: 1159: 1156: 1149: 1146: 1143: 1140: 1137: 1134: 1131: 1128: 1125: 1122: 1119: 1116: 1113: 1110: 1107: 1104: 1097: 1094: 1091: 1088: 1081: 1074: 1071: 1068: 1065: 1062: 1059: 1056: 1053: 1050: 1047: 1044: 1041: 1034: 1031: 1028: 1025: 1022: 1019: 1016: 1013: 1010: 1007: 1004: 1001: 998: 995: 988: 981: 974: 967: 964: 961: 958: 955: 952: 949: 946: 943: 940: 937: 934: 931: 928: 925: 922: 919: 912: 909: 906: 903: 900: 897: 894: 891: 888: 885: 882: 879: 876: 873: 870: 867: 860: 853: 846: 843: 840: 837: 834: 831: 828: 825: 822: 819: 816: 805: 798: 795: 792: 789: 786: 783: 780: 777: 774: 771: 768: 761: 754: 747: 744: 741: 738: 735: 732: 729: 726: 723: 720: 713: 710: 707: 704: 701: 698: 695: 692: 689: 686: 683: 680: 677: 670: 667: 664: 661: 658: 651: 644: 641: 638: 635: 632: 629: 626: 623: 620: 617: 614: 611: 608: 605: 602: 599: 596: 593: 590: 587: 580: 577: 574: 571: 568: 565: 562: 555: 552: 549: 546: 543: 540: 537: 534: 531: 528: 525: 514: 507: 504: 501: 498: 495: 492: 489: 486: 483: 480: 477: 474: 471: 468: 465: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 420: 417: 414: 411: 408: 405: 402: 399: 396: 389: 386: 383: 380: 372: 371: 366: 358: 346: 341: 330: 315: 311: 308: 302: 295: 286: 278: 274: 268: 264: 258: 251: 247: 243: 239: 227: 226: 223: 220: 217: 214: 211: 208: 205: 202: 199: 196: 193: 190: 187: 184: 181: 178: 175: 172: 169: 166: 163: 156: 152: 147: 136: 133: 96: 83: 57:This module is 51: 45: 26: 20: 12: 11: 5: 1864: 1854: 1853: 1848: 535:getcachedtable 475:expandTemplate 376: 357:and testcases 309: 306: 300: 294: 291: 284: 279:|def= 252:|def= 238: 235: 209:"20" 162: 153:|age= 132: 129: 125:flag templates 115: 114: 107:module sandbox 87: 75: 74: 55: 17: 16: 9: 6: 4: 3: 2: 1863: 1852: 1849: 1847: 1844: 1843: 1841: 1825: 1821: 1814: 1792: 1785: 1742: 1708: 1692: 1685: 1642: 1635: 1628: 1603: 1599: 1592: 1585: 1542: 1508: 1482:"-" 1462: 1440: 1397: 1390: 1365: 1361: 1354: 1347: 1337: 1330: 1320: 1313: 1306: 1293: 1241: 1198: 1155: 1114:string.gmatch 1103: 1087: 1080: 1040: 994: 987: 980: 973: 918: 866: 859: 852: 815: 811: 804: 767: 760: 753: 719: 676: 657: 650: 586: 561: 524: 520: 513: 464: 430: 426: 395: 379: 374: 369: 362: 354: 350: 345: 338: 334: 328: 324: 320: 319:documentation 314: 305: 299: 290: 288: 273: 263: 255: 234: 232: 160: 157:|mw= 144: 140: 128: 126: 122: 112: 108: 104: 100: 94: 93: 88: 81: 80: 73:from editing. 72: 68: 64: 60: 56: 49: 48: 42: 38: 34: 30: 1264:"" 1209:string.match 1166:string.match 373: 312: 303: 296: 275:}} 269:{{ 265:}} 259:{{ 256: 240: 228: 145: 138: 134: 118: 89: 1614:gettemplate 1270:string.find 1048:string.gsub 1002:string.gsub 953:string.find 932:string.find 889:getcontents 438:getcontents 323:transcluded 293:gettemplate 67:substituted 39:] [ 35:] [ 31:] [ 1840:Categories 1227:%s*(.-)%s* 1184:%s*(.-)%s* 317:The above 139:parameters 103:/testcases 61:. It is a 575:redirects 283:User:SiBr 272:getalias2 111:talk page 71:protected 1809:}}" 1762:| " 1659:gettable 1605:function 1550:tostring 1470:tostring 1414:gettable 1376:getalias 1367:function 826:gettable 817:function 778:gettable 705:mostUsed 693:loadData 662:mostUsed 621:gettable 569:mostUsed 526:function 435:function 412:loadData 400:mostUsed 262:getalias 237:getalias 185:gettable 131:gettable 99:/sandbox 1500:variant 1457:variant 901:country 838:country 790:country 633:country 581:country 563:country 547:country 493:country 450:country 351:| 344:sandbox 337:history 335:| 173:require 37:history 1827:return 1803:" 1794:return 1756:" 1547:return 1467:return 1339:return 1322:return 1233:" 1221:" 1190:" 1178:" 1144:" 1126:" 1072:" 1066:" 1032:" 1020:" 907:params 844:params 796:params 769:return 736:return 639:params 612:return 603:params 591:params 553:params 505:params 466:return 456:params 365:pages. 361:create 304:gives 1725:pairs 1694:local 1671:frame 1665:frame 1644:local 1620:frame 1565:frame 1522:frame 1488:frame 1445:frame 1426:frame 1420:frame 1399:local 1382:frame 1200:local 1157:local 1089:local 895:frame 883:pcall 868:local 832:frame 784:frame 739:cache 724:cache 711:pages 681:cache 678:local 668:pages 627:frame 541:frame 481:title 469:frame 444:frame 432:local 397:local 381:local 325:from 191:frame 164:local 148:frame 43:] 41:purge 27:[ 1731:data 1677:args 1647:data 1571:args 1556:part 1544:else 1528:args 1513:part 1494:args 1476:part 1464:then 1451:args 1432:args 1402:part 1332:else 1325:part 1295:part 1288:then 1092:part 1023:\1\1 975:then 923:bool 871:bool 745:data 733:then 730:data 671:then 609:then 597:next 499:args 353:diff 349:edit 333:edit 267:and 167:data 33:edit 29:view 1816:end 1797:out 1787:end 1750:out 1744:out 1710:for 1697:out 1594:end 1587:end 1577:def 1534:def 1356:end 1349:end 1315:end 1308:end 1267:and 1252:not 1249:and 1215:par 1172:par 1108:par 1105:for 926:and 913:{}) 806:end 755:end 748:end 645:end 594:and 515:end 321:is 203:age 155:or 127:). 101:or 1842:: 1806:\n 1800:.. 1777:.. 1771:.. 1765:.. 1759:\n 1753:.. 1737:do 1722:in 1562:or 1519:or 1510:or 1485:.. 1479:.. 1442:if 1342:{} 1285:)) 1261:== 1243:if 1230:\1 1224:\2 1187:\2 1181:\1 1150:do 1141:\1 1135:\2 1129:\1 1111:in 1098:{} 1069:\1 1029:\2 1026:%1 968:)) 950:or 920:if 910:or 721:if 702:.. 687:mw 659:if 588:if 578:or 508:}) 490:.. 478:({ 406:mw 390:{} 329:. 289:. 233:. 224:}) 215:mw 200:,{ 182:). 143:. 1830:p 1780:v 1768:k 1747:= 1734:) 1728:( 1719:v 1716:, 1713:k 1700:= 1680:) 1674:. 1668:, 1662:( 1656:. 1653:p 1650:= 1623:) 1617:( 1611:. 1608:p 1580:) 1574:. 1568:. 1559:] 1553:( 1537:) 1531:. 1525:. 1516:] 1503:] 1497:. 1491:. 1473:( 1454:. 1448:. 1435:) 1429:. 1423:, 1417:( 1411:. 1408:p 1405:= 1385:) 1379:( 1373:. 1370:p 1301:v 1298:= 1279:, 1276:k 1273:( 1258:v 1255:( 1246:v 1236:) 1218:, 1212:( 1206:= 1203:v 1193:) 1175:, 1169:( 1163:= 1160:k 1147:) 1138:- 1132:- 1123:, 1120:s 1117:( 1095:= 1075:) 1063:, 1057:, 1054:s 1051:( 1045:= 1042:s 1035:) 1017:, 1011:, 1008:s 1005:( 999:= 996:s 962:, 959:s 956:( 947:) 941:, 938:s 935:( 929:( 904:, 898:, 892:, 886:( 880:= 877:s 874:, 847:) 841:, 835:, 829:( 823:. 820:p 799:) 793:, 787:, 781:( 775:. 772:p 742:. 727:. 714:) 708:. 696:( 690:. 684:= 665:. 642:) 636:, 630:, 624:( 618:. 615:p 606:) 600:( 572:. 566:= 556:) 550:, 544:, 538:( 532:. 529:p 502:= 496:; 484:= 472:: 459:) 453:, 447:, 441:( 421:) 415:( 409:. 403:= 387:= 384:p 370:. 363:) 359:( 355:) 347:( 339:) 331:( 285:4 218:= 212:, 206:= 194:, 188:( 176:( 170:= 141:) 95:.

Index

view
edit
history
purge
subject to page protection
highly visible module
substituted
protected
approximately 416,000 pages, or roughly 1% of all pages
/sandbox
/testcases
module sandbox
talk page
country data templates
flag templates
standard structure
getalias
getalias2
User:SiBr4/Flagg tests#Lua-based getalias
documentation
transcluded
Module:CountryData/doc
edit
history
sandbox
edit
diff
create
Subpages of this module

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.