*** empty log message ***
[m17n/m17n-db.git] / LANGDATA / LANGUAGE.awk
1 # LANGUAGE.awk -- awk script to generate LANGUAGE.tbl   -*- coding: utf-8; -*-
2 # Copyright (C) 2007
3 #   National Institute of Advanced Industrial Science and Technology (AIST)
4 #   Registration Number H15PRO112
5
6 # This file is part of the m17n database; a sub-part of the m17n
7 # library.
8
9 # The m17n library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1 of
12 # the License, or (at your option) any later version.
13
14 # The m17n library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Lesser General Public License for more details.
18
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with the m17n library; if not, write to the Free
21 # Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 # Boston, MA 02110-1301, USA.
23
24 BEGIN {
25     print ";; LANGUAGE.tbl -- ISO639 Language Code              -*- mode:lisp; coding:utf-8; -*-";
26     print ";; Copyright (C) 2007";
27     print ";;   National Institute of Advanced Industrial Science and Technology (AIST)";
28     print ";;   Registration Number H15PRO112";
29     print "";
30     print ";; This file is part of the m17n database; a sub-part of the m17n";
31     print ";; library.";
32     print "";
33     print ";; The m17n library is free software; you can redistribute it and/or";
34     print ";; modify it under the terms of the GNU Lesser General Public License";
35     print ";; as published by the Free Software Foundation; either version 2.1 of";
36     print ";; the License, or (at your option) any later version.";
37     print "";
38     print ";; The m17n library is distributed in the hope that it will be useful,";
39     print ";; but WITHOUT ANY WARRANTY; without even the implied warranty of";
40     print ";; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU";
41     print ";; Lesser General Public License for more details.";
42     print "";
43     print ";; You should have received a copy of the GNU Lesser General Public";
44     print ";; License along with the m17n library; if not, write to the Free";
45     print ";; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,";
46     print ";; Boston, MA 02110-1301, USA.";
47     print ";;";
48     print ";; The file format is this:";
49     print ";;    (ISO639-2 ISO639-1 \"ENGLISH-NAME\" [ \"NATIVE-NAME\" [ \"EXTRA-CHARS\" ]]) ...";
50     print ";; ISO639-2: 3-letter language code of ISO639-2.";
51     print ";; ISO639-1: 2-letter language code of ISO639-1, or nil if it doesn't exist.";
52     print ";; ENGLISH-NAME: English name of the language.";
53     print ";; NATIVE-NAME: Native name of the language.";
54     print ";; EXTRA-CHARS: Extra characters that uniquifies the language.";
55     print ";;";
56     print ";; ISO639-2 and ISO639-1 are extracted from ISO-639-2.txt.";
57     print ";; ENGLISH-NAME and NATIVE-NAME are mainly extracted from CLDR,";
58     print ";;   but are also supplemented from these sites:";
59
60     while (getline < "native.txt") {
61         if ($0 ~ /^[a-z]/) {
62             NATIVE[$1] = $2;
63             if ($3 != "")
64                 CHARS[$1] = $3;
65         } else if ($0 ~ /^;;/) {
66             print;
67         }
68     }
69     while (getline < "native.ext") {
70         if ($0 ~ /^[a-z]/) {
71             NATIVE[$1] = $2;
72         }
73     }
74     while (getline < "en.lnm") {
75         split($0, array, "[( ]");
76         code = array[2];
77         split($0, array, "\"");
78         ENGLISH[code] = array[2];
79     }
80 }
81
82 /^[a-z][a-z][a-z]\|/ {
83     code3 = $1;
84     code2 = $3;
85     if (code2 == "" || code2 == "NULL")
86         code2 = "nil";
87     native = NATIVE[code2];
88     if (! native)
89         native = NATIVE[code3];
90     chars = CHARS[code3];
91     name = $4;
92     name = ENGLISH[code2];
93     if (! name)
94         name = ENGLISH[code3];
95 #     if (name == "Greek, Modern (1453-)")
96 #       name = "Greek";
97 #     else {
98 #       gsub("; .*", "", name);
99 #       gsub(" \\(Other\\)$", "", name);
100 #       gsub(" languages$", "", name);
101 #       gsub(" Languages$", "", name);
102 #       if (name ~ /\(.*[0-9].*\)$/)
103 #           gsub(" \\([^)]*\\)$", "", name);
104 #       if (name ~ ", ") {
105 #           split(name, array, ", ");
106 #           name = array[2] " " array[1];
107 #       }
108 #     }
109     printf "(%s %-3s \"%s\"", code3, code2, name;
110     if (native != "")
111         printf " \"%s\"", native;
112     else if (chars != "")
113         printf " nil";
114     if (chars != "")
115         printf " \"%s\"", chars;
116     printf ")\n";
117 }