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
|
#!/usr/bin/perl
use strict;
use warnings;
use 5.006;
use lib './lib', 'tools/lib';
use Data::Dumper;
use File::Copy qw( copy );
use File::Find::Rule;
use File::Slurp qw( read_file );
use Getopt::Long;
use LDML;
use Lingua::EN::Inflect qw( PL_N );
use List::AllUtils qw( first );
use Locale::Country
qw( country_code2code LOCALE_CODE_ALPHA_2 LOCALE_CODE_ALPHA_3 );
use Path::Class;
my $VERSION = '0.05';
my $ScriptName = file($0)->basename();
{
no warnings 'once';
$DateTime::Locale::InGenerator = 1;
}
my %opts;
my $glibc_dir;
sub main {
GetOptions(
'dir:s' => \$opts{dir},
'file:s' => \$opts{file},
'version:s' => \$opts{version},
'clean' => \$opts{clean},
'quiet' => \$opts{quiet},
'verbose' => \$opts{verbose},
'help' => \$opts{help},
);
$opts{help} = 1
unless defined $opts{dir} && -d $opts{dir};
usage() if $opts{help};
require_version();
clean() if $opts{clean};
binmode STDOUT, ':utf8' if $opts{verbose};
$| = 1;
( $glibc_dir = $opts{dir} ) =~ s{cldr/.+}{};
$glibc_dir .= 'glibc';
generate_from_cldr_xml();
}
sub usage {
print <<'EOF';
This script parses the CLDR locale files and turns them into a set of
Perl modules. It also generates the MANIFEST file.
It takes the following arguments:
--dir A directory containing CLDR XML files. Required.
--file Parse just the file with the given name. For debugging.
--version The CLDR version. Required when not debugging a single file.
--clean Remove old generated modules (which may not be valid with
the latest CLDR data).
--quiet Don't display any output while processing files.
--verbose Spew lots of output while processing.
--help What you are reading
If the --file or --name options are specified, the MANIFEST will not
be generated.
EOF
exit;
}
sub require_version {
return if $opts{version};
warn <<'EOF';
You must supply a CLDR version.
EOF
exit;
}
sub clean {
for my $f ( File::Find::Rule->file->name('*.pm')
->grep('This file is auto-generated')->in('lib') ) {
unlink $f or die "Cannot unlink $f: $!";
}
}
sub generate_from_cldr_xml {
my @ldml = read_all_files();
generate_pm_files(@ldml);
generate_catalog(@ldml);
generate_pm_file_pod($_) for @ldml;
print "\nAll done\n" unless $opts{quiet};
}
sub read_all_files {
my $dir = dir( $opts{dir} );
my @ldml;
while ( my $file = $dir->next() ) {
next unless -f $file;
next unless $file->basename() =~ /\.xml$/;
next if $opts{file} && $opts{file} ne $file->basename();
print "Reading $file\n" if $opts{verbose};
my $ldml = LDML->new_from_file($file);
# Any locale without this cannot be registered by
# DateTime::Locale.
next unless defined $ldml->en_language();
push @ldml, $ldml;
}
return sort { $a->id() cmp $b->id() } @ldml;
}
sub generate_pm_files {
my @ldml = @_;
print "\nGenerating PM files\n" if $opts{verbose};
for my $ldml ( sort @ldml ) {
if ( $opts{verbose} ) {
print sprintf(
<<"EOF", $ldml->id(), $ldml->parent_id(), $ldml->version(), $ldml->generation_date() );
%s
parent_id: %s
version: %s
generation date: %s
EOF
}
generate_pm_file($ldml);
}
}
sub generate_pm_file {
my $ldml = shift;
my $pm_file = file( qw( lib DateTime Locale ), $ldml->id() . q{.pm} );
write_to_manifest($pm_file);
open my $fh, '>:utf8', $pm_file
or die "Cannot write to $pm_file: $!";
write_pm_header( $fh, $ldml );
write_pm_inheritance( $fh, $ldml );
write_pm_cldr_version($fh);
write_pm_subs( $fh, $ldml );
write_pm_glibc_subs( $fh, $ldml );
write_pm_footer( $fh, $ldml );
}
sub write_pm_header {
my $fh = shift;
my $ldml = shift;
my $source_file = $ldml->source_file()->basename();
my $version = $ldml->version();
my $date = $ldml->generation_date();
my $id = $ldml->id();
print {$fh} <<"EOF" or die "print failed: $!";
###########################################################################
#
# This file is auto-generated by the Perl DateTime Suite locale
# generator ($VERSION). This code generator comes with the
# DateTime::Locale distribution in the tools/ directory, and is called
# $ScriptName.
#
# This file as generated from the CLDR XML locale data. See the
# LICENSE.cldr file included in this distribution for license details.
#
# This file was generated from the source file $source_file
# The source file version number was $version, generated on
# $date.
#
# Do not edit this file directly.
#
###########################################################################
package DateTime::Locale::$id;
use strict;
use warnings;
use utf8;
EOF
}
sub write_pm_inheritance {
my $fh = shift;
my $ldml = shift;
my $parent = $ldml->parent_id();
print {$fh} "use base 'DateTime::Locale::$parent';\n\n";
}
sub write_pm_cldr_version {
my $fh = shift;
my $cldr_version = q{"} . quotemeta( $opts{version} ) . q{"};
print {$fh} "sub cldr_version { return $cldr_version }\n\n";
}
sub write_pm_subs {
my $fh = shift;
my $ldml = shift;
foreach my $attr ( sort { $a->name() cmp $b->name() }
LDML->meta()->get_all_attributes() ) {
next
unless $attr->name()
=~ /^(?:day_|month_|quarter_|am_pm|era_|date_|time_|datetime_|first_day_)/;
next if make_alias( $fh, $ldml, $attr->name() );
my $type = $attr->type_constraint();
if ( $type->is_a_type_of('ArrayRef') ) {
write_arrayref_sub( $fh, $ldml, $attr->name() );
}
elsif ( $type->is_a_type_of('HashRef') ) {
write_hashref_sub( $fh, $ldml, $attr->name() );
}
elsif ( $type->is_a_type_of('Str') ) {
write_string_sub( $fh, $ldml, $attr->name() );
}
elsif ( $type->is_a_type_of('Int') ) {
write_int_sub( $fh, $ldml, $attr->name() );
}
else {
die "Cannot handle type: " . $type->name();
}
}
for my $attr (qw( default_date_format_length default_time_format_length ))
{
my $def = $ldml->$attr();
next unless defined $def;
print {$fh} string_sub( q{_} . $attr,, $def );
}
write_available_format_subs( $fh, $ldml );
}
sub write_pm_glibc_subs {
my $fh = shift;
my $ldml = shift;
my $file = _glibc_file_for_ldml($ldml);
return unless -f $file;
my %formats = _read_glibc_data($file);
for my $key ( grep { defined $formats{$_} } sort keys %formats ) {
print {$fh} string_sub( 'glibc_' . $key . '_format', $formats{$key} );
}
}
sub _glibc_file_for_ldml
{
my $ldml = shift;
my $glibc_id = join '_', grep { defined } $ldml->language(), $ldml->territory();
if ( my $script = $ldml->en_script() ) {
$glibc_id .= '@' . lc $script;
}
# This ensures some sort of sanish fallback
$glibc_id = 'POSIX' if $ldml->id() eq 'root';
return "$glibc_dir/$glibc_id";
}
sub _read_glibc_data {
my $file = shift;
my $glibc = read_file($file);
return (
datetime => _extract_glibc_value( 'd_t_fmt', $glibc ),
date => _extract_glibc_value( 'd_fmt', $glibc ),
time => _extract_glibc_value( 't_fmt', $glibc ),
time_12 => _extract_glibc_value( 't_fmt_ampm', $glibc ),
date_1 => _extract_glibc_value( 'date_fmt', $glibc ),
);
}
sub _extract_glibc_value {
my $key = shift;
my $data = shift;
my ($val) = $data =~ /^\Q$key\E\s+"([^"]+?)"/m
or return undef;
$val =~ s/[\\\/]\n//g;
$val =~ s/\<U([A-F\d]+)\>/chr(hex($1))/eg;
return $val;
}
sub make_alias {
my $fh = shift;
my $ldml = shift;
my $name = shift;
if ( $name =~ /stand_alone/ ) {
return make_stand_alone_alias( $fh, $ldml, $name );
}
elsif ( $name =~ /(?:abbreviated|narrow)/ ) {
return make_length_alias( $fh, $ldml, $name );
}
}
sub make_stand_alone_alias {
my $fh = shift;
my $ldml = shift;
my $name = shift;
( my $format = $name ) =~ s/stand_alone/format/;
return maybe_make_alias( $fh, $ldml, $name, $format );
}
sub make_length_alias {
my $fh = shift;
my $ldml = shift;
my $name = shift;
# This isn't well documented (or really documented at all) in the
# LDML spec, but the example seem to suggest that for the narrow
# form, the format type should "inherit" from the stand-alone
# type if possible, rather than the abbreviated type.
#
# See
# http://www.unicode.org/cldr/data/charts/by_type/calendar-gregorian.day.html
# for examples of the expected output. Note that the format narrow
# days for English are inherited from its stand-alone narrow form,
# not the root locale.
if ( $name =~ /format_narrow/ ) {
( my $to_name = $name ) =~ s/format/stand_alone/;
return 1
if maybe_make_alias( $fh, $ldml, $name, $to_name );
}
# It seems like the quarters should just inherit up the (Perl)
# inheritance chain, rather than from the next biggest size. See
# http://www.unicode.org/cldr/data/charts/by_type/calendar-gregorian.quarter.html
# for an example. Note that the English format narrow quarter is
# "1", not "Q1".
if ( $name =~ /quarter_(\w+)_narrow/ ) {
return;
}
( my $to_name = $name );
$to_name =~ s/abbreviated/wide/;
$to_name =~ s/narrow/abbreviated/;
return maybe_make_alias( $fh, $ldml, $name, $to_name );
}
sub maybe_make_alias {
my $fh = shift;
my $ldml = shift;
my $from = shift;
my $to = shift;
my $val = $ldml->$from();
return if @{$val};
return unless $ldml->can($to);
my $to_val = $ldml->$to();
return unless @{$to_val};
write_alias_sub( $fh, $from, $to );
return 1;
}
sub write_alias_sub {
my $fh = shift;
my $from = shift;
my $to = shift;
print {$fh} <<"EOF";
sub $from { \$_[0]->$to() }
EOF
}
sub write_arrayref_sub {
my $fh = shift;
my $ldml = shift;
my $name = shift;
my $arr = $ldml->$name();
return unless @{$arr};
print {$fh} arrayref_sub( $name, $arr );
}
sub arrayref_sub {
my $name = shift;
my $arr = shift;
my $val = join ', ', map { q{"} . quotemeta($_) . q{"} } @{$arr};
return <<"EOF";
{
my \$$name = [ $val ];
sub $name { return \$$name }
}
EOF
}
sub write_hashref_sub {
my $fh = shift;
my $ldml = shift;
my $name = shift;
my $hash = $ldml->$name();
return unless keys %{$hash};
print {$fh} hashref_sub( $name, $hash );
}
sub hashref_sub {
my $name = shift;
my $hash = shift;
my $val = (
join ",\n",
map {
q{ "}
. quotemeta($_)
. q{" => "}
. quotemeta( $hash->{$_} ) . q{"}
}
sort keys %{$hash}
);
return <<"EOF";
{
my \$$name =
{
$val
};
sub $name { return \$$name }
}
EOF
}
sub write_string_sub {
my $fh = shift;
my $ldml = shift;
my $name = shift;
my $str = $ldml->$name();
return unless defined $str;
print {$fh} string_sub( $name, $str );
}
sub string_sub {
my $name = shift;
my $str = shift;
my $val = quotemeta $str;
return <<"EOF";
{
my \$$name = "$val";
sub $name { return \$$name }
}
EOF
}
sub write_int_sub {
my $fh = shift;
my $ldml = shift;
my $name = shift;
my $int = $ldml->$name();
return unless defined $int;
print {$fh} int_sub( $name, $int );
}
sub int_sub {
my $name = shift;
my $int = shift;
return <<"EOF";
{
my \$$name = $int;
sub $name { return \$$name }
}
EOF
}
sub write_available_format_subs {
my $fh = shift;
my $ldml = shift;
my $formats = $ldml->available_formats();
return unless keys %{$formats};
for my $format ( sort keys %{$formats} ) {
my $sub_name = '_format_for_' . $format;
print {$fh} string_sub( $sub_name, $formats->{$format} );
}
my $avail = join ', ',
map { q{"} . quotemeta($_) . q{"} } keys %{$formats};
print {$fh} hashref_sub( '_available_formats', $formats );
}
sub write_pm_footer {
my $fh = shift;
my $ldml = shift;
print {$fh} <<'EOF';
1;
__END__
EOF
}
sub generate_catalog {
my @ldml = @_;
my $file = file(qw( lib DateTime Locale Catalog.pm ));
open my $fh, '>:utf8', $file
or die "Cannot write to $file: $!";
generate_catalog_code( $fh, \@ldml );
generate_catalog_pod( $fh, \@ldml );
}
sub generate_catalog_code {
my $fh = shift;
my $ldml = shift;
my $cldr_version = q{"} . quotemeta( $opts{version} ) . q{"};
print {$fh} <<"EOF";
###########################################################################
#
# This file is auto-generated by the Perl DateTime Suite time locale
# generator ($VERSION). This code generator comes with the
# DateTime::Locale distribution in the tools/ directory, and is called
# $ScriptName.
#
# This file as generated from the CLDR XML locale data. See the
# LICENSE.cldr file included in this distribution for license details.
#
# Do not edit this file directly.
#
###########################################################################
package DateTime::Locale::Catalog;
use strict;
use warnings;
use utf8;
sub CLDRVersion { return $cldr_version }
my \@Locales;
sub Locales { return \@Locales }
my \%Aliases;
sub Aliases { return \%Aliases }
EOF
print {$fh} '@Locales = (', "\n";
for my $l ( @{$ldml} ) {
print {$fh} catalog_data_for_locale($l);
}
print {$fh} q{);};
print {$fh} "\n\n";
print {$fh} catalog_data_for_aliases($ldml);
print {$fh} <<'EOF';
1;
__END__
EOF
}
sub catalog_data_for_locale {
my $ldml = shift;
my $data = qq[ {\n];
foreach my $k (
qw( id
en_language en_script en_territory en_variant
native_language native_script native_territory native_variant
)
) {
my $val = $ldml->$k();
next unless defined $val;
$data .= sprintf( q{ %-16s => "}, $k );
$data .= quotemeta($val);
$data .= q{",} . "\n";
}
$data .= qq[ },\n];
return $data;
}
sub catalog_data_for_aliases {
my $ldml = shift;
my %aliases = valid_aliases($ldml);
my $code = '%Aliases = (' . "\n";
for my $id ( sort keys %aliases ) {
$code .= qq{ $id => "} . quotemeta( $aliases{$id} ) . qq{",\n};
}
$code .= ");\n";
return $code;
}
sub generate_catalog_pod {
my $fh = shift;
my $ldml = shift;
my $locales_in_pod = '';
for my $ldml ( @{$ldml} ) {
my @pieces = join ' ',
grep {defined}
map { $ldml->$_() } qw( en_language en_territory en_variant );
my $script = $ldml->en_script();
push @pieces, "($script)" if defined $script;
$locales_in_pod
.= sprintf( " %-18s %s\n", $ldml->id(), join ' ', @pieces );
}
my %aliases = valid_aliases($ldml);
my $aliases_in_pod = '';
foreach my $id ( sort keys %aliases ) {
$aliases_in_pod .= sprintf( " %-18s %s\n", $id, $aliases{$id} );
}
print {$fh} <<"EOF";
=head1 NAME
DateTime::Locale::Catalog - Provides a list of all valid locale names
=head1 SYNOPSIS
See DateTime::Locale for usage details.
=head1 DESCRIPTION
This module contains a list of all known locales.
=head1 LOCALES
Any method taking locale id or name arguments should use one of the
values listed below. Ids and names are case sensitive. The id starts
with the ISO639-1 language code, and may also include information
identifying any or all of territory, script, or variant.
Always select the closest matching locale - for example, French
Canadians would choose fr_CA over fr - and B<always> use locale ids in
preference to names; locale ids offer greater compatibility when using
localized third party modules.
The available locales are:
Locale id Locale name
==================================================
$locales_in_pod
There are also many aliases available, mostly for three-letter
(ISO639-2) language codes, these are:
Locale id Is an alias for
==================================================
$aliases_in_pod
=head1 SUPPORT
See L<DateTime::Locale>.
=head1 AUTHOR
Dave Rolsky <autarch\@urth.org>
=head1 COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
This module was generated from data provided by the CLDR project, see
the LICENSE.cldr in this distribution for details on the CLDR data's
license.
=cut
EOF
}
{
my %aliases;
sub valid_aliases {
return %aliases if keys %aliases;
my $ldml = shift;
my %ids = map { $_->id() => 1 } @{$ldml};
for my $ldml ( @{$ldml} ) {
my $three = iso639_2_to_3( $ldml->language() );
next unless defined $three;
my $three_id = (
join '_',
grep {defined}
$three, $ldml->territory(), $ldml->script(),
$ldml->variant()
);
next if $ids{$three_id};
$aliases{$three_id} = $ldml->id();
}
%aliases = ( %aliases, %{ LDML->Aliases() } );
return %aliases;
}
}
{
my %iso639_map;
sub iso639_2_to_3 {
my $two = shift;
_build_iso639_map() unless keys %iso639_map;
return $iso639_map{$two};
}
sub _build_iso639_map {
while ( defined( my $line = <DATA> ) ) {
next unless $line =~ /\S/;
next if $line =~ /^\#/;
my ( $three, undef, $two, undef, undef ) = split /\|/, $line;
next unless defined $two;
$iso639_map{$two} = $three;
}
}
}
sub generate_pm_file_pod {
my $ldml = shift;
my $pm_file = file( qw( lib DateTime Locale ), $ldml->id() . q{.pm} );
require DateTime::Locale;
my $locale = DateTime::Locale->load( $ldml->id() );
open my $fh, '>>:utf8', $pm_file
or die "Cannot append to $pm_file: $!";
write_pm_file_pod_header( $fh, $locale, $ldml );
print {$fh} pod_for_days($locale);
print {$fh} pod_for_months($locale);
print {$fh} pod_for_quarters($locale);
print {$fh} pod_for_eras($locale);
print {$fh} pod_for_formats($locale);
print {$fh} pod_for_misc($locale);
print {$fh} pod_footer($locale);
}
sub write_pm_file_pod_header {
my $fh = shift;
my $locale = shift;
my $ldml = shift;
my $class = ref $locale;
my $id = $locale->id();
my $name = $locale->name();
print {$fh} <<"EOF";
=pod
=encoding utf8
=head1 NAME
$class
=head1 SYNOPSIS
use DateTime;
my \$dt = DateTime->now( locale => '$id' );
print \$dt->month_name();
=head1 DESCRIPTION
This is the DateTime locale package for $name.
=head1 DATA
EOF
if ( $id ne 'root' ) {
print {$fh} 'This locale inherits from the L<DateTime::Locale::'
. $ldml->parent_id()
. "> locale.\n\n";
}
print {$fh} "It contains the following data.\n\n";
}
sub pod_for_days {
my $locale = shift;
return pod_for_variations( $locale, 'day' );
}
sub pod_for_months {
my $locale = shift;
return pod_for_variations( $locale, 'month' );
}
sub pod_for_quarters {
my $locale = shift;
return pod_for_variations( $locale, 'quarter' );
}
sub pod_for_eras {
my $locale = shift;
return pod_for_variations( $locale, 'era' );
}
sub pod_for_variations {
my $locale = shift;
my $thing = shift;
my $pod = '';
my $pl = PL_N($thing);
$pod .= "=head2 \u$pl\n\n";
my @forms = $thing eq 'era' ? ('') : ( 'format', 'stand_alone' );
for my $form (@forms) {
for my $size (qw( wide abbreviated narrow )) {
my $meth
= $form
? $thing . q{_} . $form . q{_} . $size
: $thing . q{_} . $size;
next unless $locale->can($meth);
my $head = ucfirst $size;
if ($form) {
( my $f = $form ) =~ s/_/-/;
$head .= " ($f)";
}
$pod .= "=head3 $head\n\n";
for my $val ( @{ $locale->$meth() } ) {
$pod .= " $val\n";
}
$pod .= "\n";
}
}
return $pod;
}
sub pod_for_formats {
my $locale = shift;
unless ( DateTime->can('new') ) {
eval "use DateTime 0.43";
die $@ if $@;
}
my @dts = (
DateTime->new(
year => 2008,
month => 2,
day => 5,
hour => 18,
minute => 30,
second => 30,
locale => $locale,
time_zone => 'UTC',
),
DateTime->new(
year => 1995,
month => 12,
day => 22,
hour => 9,
minute => 5,
second => 2,
nanosecond => 505_196,
locale => $locale,
time_zone => 'UTC',
),
DateTime->new(
year => -10,
month => 9,
day => 15,
hour => 4,
minute => 44,
second => 23,
locale => $locale,
time_zone => 'UTC',
),
);
return pod_for_standard_formats( $locale, \@dts )
. pod_for_available_formats( $locale, \@dts );
}
sub pod_for_standard_formats {
my $locale = shift;
my $dts = shift;
my $pod = '';
for my $type (qw( date time datetime )) {
$pod .= "=head2 \u$type Formats\n\n";
for my $length (qw( full long medium short default )) {
$pod .= "=head3 \u$length\n\n";
my $meth = $type . q{_} . 'format' . q{_} . $length;
for my $dt ( @{$dts} ) {
$pod .= sprintf(
' %20s = %s',
$dt->iso8601(),
$dt->format_cldr( $locale->$meth() ),
);
$pod .= "\n";
}
$pod .= "\n";
}
}
return $pod;
}
sub pod_for_available_formats {
my $locale = shift;
my $dts = shift;
my $pod = '';
$pod .= "=head2 Available Formats\n\n";
for my $format ( sort { lc $a cmp lc $b or $a cmp $b }
$locale->available_formats() ) {
my $cldr = $locale->format_for($format);
$pod .= "=head3 $format ($cldr)\n\n";
for my $dt ( @{$dts} ) {
$pod .= sprintf(
' %20s = %s',
$dt->iso8601(),
$dt->format_cldr($cldr),
);
$pod .= "\n";
}
$pod .= "\n";
}
return $pod;
}
sub pod_for_misc {
my $locale = shift;
my $pod = "=head2 Miscellaneous\n\n";
$pod .= "=head3 Prefers 24 hour time?\n\n";
$pod .= $locale->prefers_24_hour_time() ? 'Yes' : 'No';
$pod .= "\n\n";
$pod .= "=head3 Local first day of the week\n\n";
$pod .= $locale->day_format_wide()->[ $locale->first_day_of_week() - 1 ];
$pod .= "\n\n";
return $pod;
}
sub pod_footer {
return <<'EOF';
=head1 SUPPORT
See L<DateTime::Locale>.
=head1 AUTHOR
Dave Rolsky <autarch@urth.org>
=head1 COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
This module was generated from data provided by the CLDR project, see
the LICENSE.cldr in this distribution for details on the CLDR data's
license.
=cut
EOF
}
sub write_to_manifest {
return if $opts{file};
my $fh = _manifest_handle();
print {$fh} $_, "\n" for @_;
}
{
my $fh;
sub _manifest_handle {
return $fh if defined $fh;
copy( 'MANIFEST.base', 'MANIFEST' );
open $fh, '>>', 'MANIFEST' or die "Cannot write to MANIFEST: $!";
return $fh;
}
}
main();
__DATA__
# This is the ISO-639 data downloaded from http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
# The version in the Locale::Codes distro is way out of date.
aar||aa|Afar|afar
abk||ab|Abkhazian|abkhaze
ace|||Achinese|aceh
ach|||Acoli|acoli
ada|||Adangme|adangme
ady|||Adyghe; Adygei|adyghé
afa|||Afro-Asiatic languages|afro-asiatiques, langues
afh|||Afrihili|afrihili
afr||af|Afrikaans|afrikaans
ain|||Ainu|aïnou
aka||ak|Akan|akan
akk|||Akkadian|akkadien
alb|sqi|sq|Albanian|albanais
ale|||Aleut|aléoute
alg|||Algonquian languages|algonquines, langues
alt|||Southern Altai|altai du Sud
amh||am|Amharic|amharique
ang|||English, Old (ca.450-1100)|anglo-saxon (ca.450-1100)
anp|||Angika|angika
apa|||Apache languages|apaches, langues
ara||ar|Arabic|arabe
arc|||Official Aramaic (700-300 BCE); Imperial Aramaic (700-300 BCE)|araméen d'empire (700-300 BCE)
arg||an|Aragonese|aragonais
arm|hye|hy|Armenian|arménien
arn|||Mapudungun; Mapuche|mapudungun; mapuche; mapuce
arp|||Arapaho|arapaho
art|||Artificial languages|artificielles, langues
arw|||Arawak|arawak
asm||as|Assamese|assamais
ast|||Asturian; Bable; Leonese; Asturleonese|asturien; bable; léonais; asturoléonais
ath|||Athapascan languages|athapascanes, langues
aus|||Australian languages|australiennes, langues
ava||av|Avaric|avar
ave||ae|Avestan|avestique
awa|||Awadhi|awadhi
aym||ay|Aymara|aymara
aze||az|Azerbaijani|azéri
bad|||Banda languages|banda, langues
bai|||Bamileke languages|bamiléké, langues
bak||ba|Bashkir|bachkir
bal|||Baluchi|baloutchi
bam||bm|Bambara|bambara
ban|||Balinese|balinais
baq|eus|eu|Basque|basque
bas|||Basa|basa
bat|||Baltic languages|baltes, langues
bej|||Beja; Bedawiyet|bedja
bel||be|Belarusian|biélorusse
bem|||Bemba|bemba
ben||bn|Bengali|bengali
ber|||Berber languages|berbères, langues
bho|||Bhojpuri|bhojpuri
bih||bh|Bihari|bihari
bik|||Bikol|bikol
bin|||Bini; Edo|bini; edo
bis||bi|Bislama|bichlamar
bla|||Siksika|blackfoot
bnt|||Bantu (Other)|bantoues, autres langues
bos||bs|Bosnian|bosniaque
bra|||Braj|braj
bre||br|Breton|breton
btk|||Batak languages|batak, langues
bua|||Buriat|bouriate
bug|||Buginese|bugi
bul||bg|Bulgarian|bulgare
bur|mya|my|Burmese|birman
byn|||Blin; Bilin|blin; bilen
cad|||Caddo|caddo
cai|||Central American Indian languages|amérindiennes de L'Amérique centrale, langues
car|||Galibi Carib|karib; galibi; carib
cat||ca|Catalan; Valencian|catalan; valencien
cau|||Caucasian languages|caucasiennes, langues
ceb|||Cebuano|cebuano
cel|||Celtic languages|celtiques, langues; celtes, langues
cha||ch|Chamorro|chamorro
chb|||Chibcha|chibcha
che||ce|Chechen|tchétchène
chg|||Chagatai|djaghataï
chi|zho|zh|Chinese|chinois
chk|||Chuukese|chuuk
chm|||Mari|mari
chn|||Chinook jargon|chinook, jargon
cho|||Choctaw|choctaw
chp|||Chipewyan; Dene Suline|chipewyan
chr|||Cherokee|cherokee
chu||cu|Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic|slavon d'église; vieux slave; slavon liturgique; vieux bulgare
chv||cv|Chuvash|tchouvache
chy|||Cheyenne|cheyenne
cmc|||Chamic languages|chames, langues
cop|||Coptic|copte
cor||kw|Cornish|cornique
cos||co|Corsican|corse
cpe|||Creoles and pidgins, English based|créoles et pidgins basés sur l'anglais
cpf|||Creoles and pidgins, French-based |créoles et pidgins basés sur le français
cpp|||Creoles and pidgins, Portuguese-based |créoles et pidgins basés sur le portugais
cre||cr|Cree|cree
crh|||Crimean Tatar; Crimean Turkish|tatar de Crimé
crp|||Creoles and pidgins |créoles et pidgins
csb|||Kashubian|kachoube
cus|||Cushitic languages|couchitiques, langues
cze|ces|cs|Czech|tchèque
dak|||Dakota|dakota
dan||da|Danish|danois
dar|||Dargwa|dargwa
day|||Land Dayak languages|dayak, langues
del|||Delaware|delaware
den|||Slave (Athapascan)|esclave (athapascan)
dgr|||Dogrib|dogrib
din|||Dinka|dinka
div||dv|Divehi; Dhivehi; Maldivian|maldivien
doi|||Dogri|dogri
dra|||Dravidian languages|dravidiennes, langues
dsb|||Lower Sorbian|bas-sorabe
dua|||Duala|douala
dum|||Dutch, Middle (ca.1050-1350)|néerlandais moyen (ca. 1050-1350)
dut|nld|nl|Dutch; Flemish|néerlandais; flamand
dyu|||Dyula|dioula
dzo||dz|Dzongkha|dzongkha
efi|||Efik|efik
egy|||Egyptian (Ancient)|égyptien
eka|||Ekajuk|ekajuk
elx|||Elamite|élamite
eng||en|English|anglais
enm|||English, Middle (1100-1500)|anglais moyen (1100-1500)
epo||eo|Esperanto|espéranto
est||et|Estonian|estonien
ewe||ee|Ewe|éwé
ewo|||Ewondo|éwondo
fan|||Fang|fang
fao||fo|Faroese|féroïen
fat|||Fanti|fanti
fij||fj|Fijian|fidjien
fil|||Filipino; Pilipino|filipino; pilipino
fin||fi|Finnish|finnois
fiu|||Finno-Ugrian languages|finno-ougriennes, langues
fon|||Fon|fon
fre|fra|fr|French|français
frm|||French, Middle (ca.1400-1600)|français moyen (1400-1600)
fro|||French, Old (842-ca.1400)|français ancien (842-ca.1400)
frr|||Northern Frisian|frison septentrional
frs|||Eastern Frisian|frison oriental
fry||fy|Western Frisian|frison occidental
ful||ff|Fulah|peul
fur|||Friulian|frioulan
gaa|||Ga|ga
gay|||Gayo|gayo
gba|||Gbaya|gbaya
gem|||Germanic languages|germaniques, langues
geo|kat|ka|Georgian|géorgien
ger|deu|de|German|allemand
gez|||Geez|guèze
gil|||Gilbertese|kiribati
gla||gd|Gaelic; Scottish Gaelic|gaélique; gaélique écossais
gle||ga|Irish|irlandais
glg||gl|Galician|galicien
glv||gv|Manx|manx; mannois
gmh|||German, Middle High (ca.1050-1500)|allemand, moyen haut (ca. 1050-1500)
goh|||German, Old High (ca.750-1050)|allemand, vieux haut (ca. 750-1050)
gon|||Gondi|gond
gor|||Gorontalo|gorontalo
got|||Gothic|gothique
grb|||Grebo|grebo
grc|||Greek, Ancient (to 1453)|grec ancien (jusqu'à 1453)
gre|ell|el|Greek, Modern (1453-)|grec moderne (après 1453)
grn||gn|Guarani|guarani
gsw|||Swiss German; Alemannic; Alsatian|suisse alémanique; alémanique; alsacien
guj||gu|Gujarati|goudjrati
gwi|||Gwich'in|gwich'in
hai|||Haida|haida
hat||ht|Haitian; Haitian Creole|haïtien; créole haïtien
hau||ha|Hausa|haoussa
haw|||Hawaiian|hawaïen
heb||he|Hebrew|hébreu
her||hz|Herero|herero
hil|||Hiligaynon|hiligaynon
him|||Himachali|himachali
hin||hi|Hindi|hindi
hit|||Hittite|hittite
hmn|||Hmong|hmong
hmo||ho|Hiri Motu|hiri motu
hrv||hr|Croatian|croate
hsb|||Upper Sorbian|haut-sorabe
hun||hu|Hungarian|hongrois
hup|||Hupa|hupa
iba|||Iban|iban
ibo||ig|Igbo|igbo
ice|isl|is|Icelandic|islandais
ido||io|Ido|ido
iii||ii|Sichuan Yi; Nuosu|yi de Sichuan
ijo|||Ijo languages|ijo, langues
iku||iu|Inuktitut|inuktitut
ile||ie|Interlingue; Occidental|interlingue
ilo|||Iloko|ilocano
ina||ia|Interlingua (International Auxiliary Language Association)|interlingua (langue auxiliaire internationale)
inc|||Indic languages|indo-aryennes, langues
ind||id|Indonesian|indonésien
ine|||Indo-European languages|indo-européennes, langues
inh|||Ingush|ingouche
ipk||ik|Inupiaq|inupiaq
ira|||Iranian languages|iraniennes, langues
iro|||Iroquoian languages|iroquoises, langues
ita||it|Italian|italien
jav||jv|Javanese|javanais
jbo|||Lojban|lojban
jpn||ja|Japanese|japonais
jpr|||Judeo-Persian|judéo-persan
jrb|||Judeo-Arabic|judéo-arabe
kaa|||Kara-Kalpak|karakalpak
kab|||Kabyle|kabyle
kac|||Kachin; Jingpho|kachin; jingpho
kal||kl|Kalaallisut; Greenlandic|groenlandais
kam|||Kamba|kamba
kan||kn|Kannada|kannada
kar|||Karen languages|karen, langues
kas||ks|Kashmiri|kashmiri
kau||kr|Kanuri|kanouri
kaw|||Kawi|kawi
kaz||kk|Kazakh|kazakh
kbd|||Kabardian|kabardien
kha|||Khasi|khasi
khi|||Khoisan languages|khoïsan, langues
khm||km|Central Khmer|khmer central
kho|||Khotanese; Sakan|khotanais; sakan
kik||ki|Kikuyu; Gikuyu|kikuyu
kin||rw|Kinyarwanda|rwanda
kir||ky|Kirghiz; Kyrgyz|kirghiz
kmb|||Kimbundu|kimbundu
kok|||Konkani|konkani
kom||kv|Komi|kom
kon||kg|Kongo|kongo
kor||ko|Korean|coréen
kos|||Kosraean|kosrae
kpe|||Kpelle|kpellé
krc|||Karachay-Balkar|karatchai balkar
krl|||Karelian|carélien
kro|||Kru languages|krou, langues
kru|||Kurukh|kurukh
kua||kj|Kuanyama; Kwanyama|kuanyama; kwanyama
kum|||Kumyk|koumyk
kur||ku|Kurdish|kurde
kut|||Kutenai|kutenai
lad|||Ladino|judéo-espagnol
lah|||Lahnda|lahnda
lam|||Lamba|lamba
lao||lo|Lao|lao
lat||la|Latin|latin
lav||lv|Latvian|letton
lez|||Lezghian|lezghien
lim||li|Limburgan; Limburger; Limburgish|limbourgeois
lin||ln|Lingala|lingala
lit||lt|Lithuanian|lituanien
lol|||Mongo|mongo
loz|||Lozi|lozi
ltz||lb|Luxembourgish; Letzeburgesch|luxembourgeois
lua|||Luba-Lulua|luba-lulua
lub||lu|Luba-Katanga|luba-katanga
lug||lg|Ganda|ganda
lui|||Luiseno|luiseno
lun|||Lunda|lunda
luo|||Luo (Kenya and Tanzania)|luo (Kenya et Tanzanie)
lus|||Lushai|lushai
mac|mkd|mk|Macedonian|macédonien
mad|||Madurese|madourais
mag|||Magahi|magahi
mah||mh|Marshallese|marshall
mai|||Maithili|maithili
mak|||Makasar|makassar
mal||ml|Malayalam|malayalam
man|||Mandingo|mandingue
mao|mri|mi|Maori|maori
map|||Austronesian languages|austronésiennes, langues
mar||mr|Marathi|marathe
mas|||Masai|massaï
may|msa|ms|Malay|malais
mdf|||Moksha|moksa
mdr|||Mandar|mandar
men|||Mende|mendé
mga|||Irish, Middle (900-1200)|irlandais moyen (900-1200)
mic|||Mi'kmaq; Micmac|mi'kmaq; micmac
min|||Minangkabau|minangkabau
mis|||Uncoded languages|langues non codées
mkh|||Mon-Khmer languages|môn-khmer, langues
mlg||mg|Malagasy|malgache
mlt||mt|Maltese|maltais
mnc|||Manchu|mandchou
mni|||Manipuri|manipuri
mno|||Manobo languages|manobo, langues
moh|||Mohawk|mohawk
mon||mn|Mongolian|mongol
mos|||Mossi|moré
mul|||Multiple languages|multilingue
mun|||Munda languages|mounda, langues
mus|||Creek|muskogee
mwl|||Mirandese|mirandais
mwr|||Marwari|marvari
myn|||Mayan languages|maya, langues
myv|||Erzya|erza
nah|||Nahuatl languages|nahuatl, langues
nai|||North American Indian languages|nord-amérindiennes, langues
nap|||Neapolitan|napolitain
nau||na|Nauru|nauruan
nav||nv|Navajo; Navaho|navaho
nbl||nr|Ndebele, South; South Ndebele|ndébélé du Sud
nde||nd|Ndebele, North; North Ndebele|ndébélé du Nord
ndo||ng|Ndonga|ndonga
nds|||Low German; Low Saxon; German, Low; Saxon, Low|bas allemand; bas saxon; allemand, bas; saxon, bas
nep||ne|Nepali|népalais
new|||Nepal Bhasa; Newari|nepal bhasa; newari
nia|||Nias|nias
nic|||Niger-Kordofanian languages|nigéro-kordofaniennes, langues
niu|||Niuean|niué
nno||nn|Norwegian Nynorsk; Nynorsk, Norwegian|norvégien nynorsk; nynorsk, norvégien
nob||nb|Bokmål, Norwegian; Norwegian Bokmål|norvégien bokmål
nog|||Nogai|nogaï; nogay
non|||Norse, Old|norrois, vieux
nor||no|Norwegian|norvégien
nqo|||N'Ko|n'ko
nso|||Pedi; Sepedi; Northern Sotho|pedi; sepedi; sotho du Nord
nub|||Nubian languages|nubiennes, langues
nwc|||Classical Newari; Old Newari; Classical Nepal Bhasa|newari classique
nya||ny|Chichewa; Chewa; Nyanja|chichewa; chewa; nyanja
nym|||Nyamwezi|nyamwezi
nyn|||Nyankole|nyankolé
nyo|||Nyoro|nyoro
nzi|||Nzima|nzema
oci||oc|Occitan (post 1500); Provençal|occitan (après 1500); provençal
oji||oj|Ojibwa|ojibwa
ori||or|Oriya|oriya
orm||om|Oromo|galla
osa|||Osage|osage
oss||os|Ossetian; Ossetic|ossète
ota|||Turkish, Ottoman (1500-1928)|turc ottoman (1500-1928)
oto|||Otomian languages|otomi, langues
paa|||Papuan languages|papoues, langues
pag|||Pangasinan|pangasinan
pal|||Pahlavi|pahlavi
pam|||Pampanga; Kapampangan|pampangan
pan||pa|Panjabi; Punjabi|pendjabi
pap|||Papiamento|papiamento
pau|||Palauan|palau
peo|||Persian, Old (ca.600-400 B.C.)|perse, vieux (ca. 600-400 av. J.-C.)
per|fas|fa|Persian|persan
phi|||Philippine languages|philippines, langues
phn|||Phoenician|phénicien
pli||pi|Pali|pali
pol||pl|Polish|polonais
pon|||Pohnpeian|pohnpei
por||pt|Portuguese|portugais
pra|||Prakrit languages|prâkrit, langues
pro|||Provençal, Old (to 1500)|provençal ancien (jusqu'à 1500)
pus||ps|Pushto; Pashto|pachto
qaa-qtz|||Reserved for local use|réservée à l'usage local
que||qu|Quechua|quechua
raj|||Rajasthani|rajasthani
rap|||Rapanui|rapanui
rar|||Rarotongan; Cook Islands Maori|rarotonga; maori des îles Cook
roa|||Romance languages|romanes, langues
roh||rm|Romansh|romanche
rom|||Romany|tsigane
rum|ron|ro|Romanian; Moldavian; Moldovan|roumain; moldave
run||rn|Rundi|rundi
rup|||Aromanian; Arumanian; Macedo-Romanian|aroumain; macédo-roumain
rus||ru|Russian|russe
sad|||Sandawe|sandawe
sag||sg|Sango|sango
sah|||Yakut|iakoute
sai|||South American Indian (Other)|indiennes d'Amérique du Sud, autres langues
sal|||Salishan languages|salishennes, langues
sam|||Samaritan Aramaic|samaritain
san||sa|Sanskrit|sanskrit
sas|||Sasak|sasak
sat|||Santali|santal
scn|||Sicilian|sicilien
sco|||Scots|écossais
sel|||Selkup|selkoupe
sem|||Semitic languages|sémitiques, langues
sga|||Irish, Old (to 900)|irlandais ancien (jusqu'à 900)
sgn|||Sign Languages|langues des signes
shn|||Shan|chan
sid|||Sidamo|sidamo
sin||si|Sinhala; Sinhalese|singhalais
sio|||Siouan languages|sioux, langues
sit|||Sino-Tibetan languages|sino-tibétaines, langues
sla|||Slavic languages|slaves, langues
slo|slk|sk|Slovak|slovaque
slv||sl|Slovenian|slovène
sma|||Southern Sami|sami du Sud
sme||se|Northern Sami|sami du Nord
smi|||Sami languages|sames, langues
smj|||Lule Sami|sami de Lule
smn|||Inari Sami|sami d'Inari
smo||sm|Samoan|samoan
sms|||Skolt Sami|sami skolt
sna||sn|Shona|shona
snd||sd|Sindhi|sindhi
snk|||Soninke|soninké
sog|||Sogdian|sogdien
som||so|Somali|somali
son|||Songhai languages|songhai, langues
sot||st|Sotho, Southern|sotho du Sud
spa||es|Spanish; Castilian|espagnol; castillan
srd||sc|Sardinian|sarde
srn|||Sranan Tongo|sranan tongo
srp||sr|Serbian|serbe
srr|||Serer|sérère
ssa|||Nilo-Saharan languages|nilo-sahariennes, langues
ssw||ss|Swati|swati
suk|||Sukuma|sukuma
sun||su|Sundanese|soundanais
sus|||Susu|soussou
sux|||Sumerian|sumérien
swa||sw|Swahili|swahili
swe||sv|Swedish|suédois
syc|||Classical Syriac|syriaque classique
syr|||Syriac|syriaque
tah||ty|Tahitian|tahitien
tai|||Tai languages|tai, langues
tam||ta|Tamil|tamoul
tat||tt|Tatar|tatar
tel||te|Telugu|télougou
tem|||Timne|temne
ter|||Tereno|tereno
tet|||Tetum|tetum
tgk||tg|Tajik|tadjik
tgl||tl|Tagalog|tagalog
tha||th|Thai|thaï
tib|bod|bo|Tibetan|tibétain
tig|||Tigre|tigré
tir||ti|Tigrinya|tigrigna
tiv|||Tiv|tiv
tkl|||Tokelau|tokelau
tlh|||Klingon; tlhIngan-Hol|klingon
tli|||Tlingit|tlingit
tmh|||Tamashek|tamacheq
tog|||Tonga (Nyasa)|tonga (Nyasa)
ton||to|Tonga (Tonga Islands)|tongan (Îles Tonga)
tpi|||Tok Pisin|tok pisin
tsi|||Tsimshian|tsimshian
tsn||tn|Tswana|tswana
tso||ts|Tsonga|tsonga
tuk||tk|Turkmen|turkmène
tum|||Tumbuka|tumbuka
tup|||Tupi languages|tupi, langues
tur||tr|Turkish|turc
tut|||Altaic languages|altaïques, langues
tvl|||Tuvalu|tuvalu
twi||tw|Twi|twi
tyv|||Tuvinian|touva
udm|||Udmurt|oudmourte
uga|||Ugaritic|ougaritique
uig||ug|Uighur; Uyghur|ouïgour
ukr||uk|Ukrainian|ukrainien
umb|||Umbundu|umbundu
und|||Undetermined|indéterminée
urd||ur|Urdu|ourdou
uzb||uz|Uzbek|ouszbek
vai|||Vai|vaï
ven||ve|Venda|venda
vie||vi|Vietnamese|vietnamien
vol||vo|Volapük|volapük
vot|||Votic|vote
wak|||Wakashan languages|wakashanes, langues
wal|||Walamo|walamo
war|||Waray|waray
was|||Washo|washo
wel|cym|cy|Welsh|gallois
wen|||Sorbian languages|sorabes, langues
wln||wa|Walloon|wallon
wol||wo|Wolof|wolof
xal|||Kalmyk; Oirat|kalmouk; oïrat
xho||xh|Xhosa|xhosa
yao|||Yao|yao
yap|||Yapese|yapois
yid||yi|Yiddish|yiddish
yor||yo|Yoruba|yoruba
ypk|||Yupik languages|yupik, langues
zap|||Zapotec|zapotèque
zbl|||Blissymbols; Blissymbolics; Bliss|symboles Bliss; Bliss
zen|||Zenaga|zenaga
zha||za|Zhuang; Chuang|zhuang; chuang
znd|||Zande languages|zandé, langues
zul||zu|Zulu|zoulou
zun|||Zuni|zuni
zxx|||No linguistic content; Not applicable|pas de contenu linguistique; non applicable
zza|||Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki|zaza; dimili; dimli; kirdki; kirmanjki; zazaki
|