Moved from ../LANGUAGE.awk. Modified to
[m17n/m17n-db.git] / LANGNAME.awk
1 # LANGNAME.awk -- awk script to generate LANGNAME.en and LANGNAME.fr
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     if (LANG == "en") {
26         Language = "English";
27         LANGUAGE = "ENGLISH";
28     } else {
29         Language = "French";
30         LANGUAGE = "FRENCH";
31     }
32     printf ";; LANGNAME.%s -- %s language names -*- mode:lisp; coding:utf-8; -*-\n", LANG, Language;
33     print ";; Copyright (C) 2007";
34     print ";;   National Institute of Advanced Industrial Science and Technology (AIST)";
35     print ";;   Registration Number H15PRO112";
36     print "";
37     print ";; This file is part of the m17n database; a sub-part of the m17n";
38     print ";; library.";
39     print "";
40     print ";; The m17n library is free software; you can redistribute it and/or";
41     print ";; modify it under the terms of the GNU Lesser General Public License";
42     print ";; as published by the Free Software Foundation; either version 2.1 of";
43     print ";; the License, or (at your option) any later version.";
44     print "";
45     print ";; The m17n library is distributed in the hope that it will be useful,";
46     print ";; but WITHOUT ANY WARRANTY; without even the implied warranty of";
47     print ";; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU";
48     print ";; Lesser General Public License for more details.";
49     print "";
50     print ";; You should have received a copy of the GNU Lesser General Public";
51     print ";; License along with the m17n library; if not, write to the Free";
52     print ";; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,";
53     print ";; Boston, MA 02110-1301, USA.";
54     print ";;";
55     print ";; Each line of this file has this form:";
56     printf ";;    (ISO639-2 \"%s-NAME\" ...)\n", LANGUAGE;
57     print ";; ISO639-2: 3-letter language code of ISO639-2.";
58     printf ";; %s-NAME: %s name of the language\n", LANGUAGE, Language;
59     print ";;    in ISO639-2 with the following modifications:";
60     if (LANG == "en") {
61         print ";;       'Greek, Modern (1453-)' is changed to 'Greek'";
62         print ";;       Tailing ' (Other)' is deleted.";
63         print ";;       Tailing ' languages' is deleted.";
64         print ";;       Tailing part specifying the date (e.g. ' (ca.450-1100)') is deleted.";
65         print ";;       Reorder, for instance, 'English, Old' to 'Old English'.";
66     } else {
67         print ";;       'grec moderne (après 1453)' is changed to 'grec'";
68         print ";;       Tailing ', autres langues' is deleted.";
69         print ";;       Tailing ', autres' is deleted.";
70         print ";;       Tailing ', langues' is deleted.";
71         print ";;       Tailing ', langues (famille)' is deleted.";
72         print ";;       Tailing part specifying the date (e.g. ' (ca.450-1100)') is deleted.";
73         print ";;       Reorder, for instance, 'saxon, bas' to 'bas saxon'.";
74     }
75     print ";;   Delete duplicated names after the above modifications.";
76     print "";
77     printf "(language name %s)\n", LANG;
78     print "";
79 }
80
81 {
82     iso = $1;
83     for (idx in names) delete names[idx];
84     if (LANG == "en") {
85         split($4, array, "; ");
86         for (idx in array) {
87             name = array[idx]
88             if (name == "Greek, Modern (1453-)")
89                 name = "Greek";
90             else if (name == "Multiple languages")
91                 ;
92             else {
93                 gsub(" \\(Other\\)$", "", name);
94                 gsub(" languages$", "", name);
95                 if (name ~ /\(.*[0-9].*\)$/) {
96                     gsub(" \\([^)]*\\)$", "", name);
97                 }
98                 if (name ~ ", ") {
99                     split(name,array2,", ");
100                     name = array2[2] " " array2[1];
101                 }
102             }
103             names[name] = 1;
104         }
105     } else {
106         split($5, array, "; ");
107         for (idx in array) {
108             name = array[idx]
109             if (name == "grec ancien (jusqu'à 1453)")
110                 name = "grec";
111             else {
112                 gsub(", autres langues$", "", name);
113                 gsub(", autres$", "", name);
114                 gsub(", langues$", "", name);
115                 gsub(", langues \\(famille\\)$", "", name);
116                 if (name ~ /\(.*[0-9].*\)$/)
117                     gsub(" \\([^)]*\\)$", "", name);
118                 if (name ~ ", ") {
119                     split(name,array2,", ");
120                     name = array2[2] " " array2[1];
121                 }
122             }
123             names[name] = 1;
124         }
125     }
126     printf "(%s", $1;
127     for (name in names) {
128         printf " \"%s\"", name;
129     }
130     printf ")\n";
131 }
132
133 # Local Variables:
134 # coding: utf-8
135 # End: