530ef1a02171c0072d83b38f49afa220fa4841cb
[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 }
78
79 {
80     iso = $1;
81     for (idx in names) delete names[idx];
82     if (LANG == "en") {
83         split($4, array, "; ");
84         for (idx in array) {
85             name = array[idx]
86             if (name == "Greek, Modern (1453-)")
87                 name = "Greek";
88             else {
89                 gsub(" \(Other\)$", "", name);
90                 gsub(" languages$", "", name);
91                 if (name ~ /\(.*[0-9].*\)$/)
92                     gsub(" \([^)]*\)$", "", name);
93                 if (name ~ ", ") {
94                     split(name,array2,", ");
95                     name = array2[2] " " array2[1];
96                 }
97             }
98             names[name] = 1;
99         }
100     } else {
101         split($5, array, "; ");
102         for (idx in array) {
103             name = array[idx]
104             if (name == "grec ancien (jusqu'à 1453)")
105                 name = "grec";
106             else {
107                 gsub(", autres langues$", "", name);
108                 gsub(", autres$", "", name);
109                 gsub(", langues$", "", name);
110                 gsub(", langues (famille)$", "", name);
111                 if (name ~ /\(.*[0-9].*\)$/)
112                     gsub(" \([^)]*\)$", "", name);
113                 if (name ~ ", ") {
114                     split(name,array2,", ");
115                     name = array2[2] " " array2[1];
116                 }
117             }
118             names[name] = 1;
119         }
120     }
121     printf "(%s", $1;
122     for (name in names) {
123         printf " \"%s\"", name;
124     }
125     printf ")\n";
126 }
127
128 # Local Variables:
129 # coding: utf-8
130 # End: