-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.py
More file actions
158 lines (142 loc) · 4.91 KB
/
main.py
File metadata and controls
158 lines (142 loc) · 4.91 KB
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
# -*- coding: utf-8 -*-
# !/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import translit
import logging
import os
import webapp2
from google.appengine.ext.webapp import template
# English name, language code, name in the language.
LanguageList = [
(u'A\u1e49angu Yol\u014bu', 'en_anangu', 'Aṉangu-Yolngu'),
('Ahom', 'aho'),
('Bamum', 'bax'),
(u'Bété', 'bete'),
('Batak Sinalungun', 'bts'),
('Chakma', 'ccp', u'\ud804\udd0c\ud804\udd0b\ud804\udd34\ud804\udd1f\ud804\udd33\ud804\udd26'),
('Gondi', 'gon', 'Gōndi family'),
('Gondi Northern (Gunjala)', 'gno', 'Northern Gōndi (Gunjala)'),
('Gondi Aheri (Masaram)', 'esg', 'Aheri Gōndi Masaram'),
('Igbo Nsibidi', 'ig'),
('Nyaikeng Puachue Hmong', 'Igbo Nsibidi'),
('Cherokee', 'chr', 'ᏣᎳᎩ ᎦᏬᏂᎯᏍᏗ'),
('Hoocąk (Ho-chunk)', 'win', 'Hoocąk'),
('Laz', 'lzz'),
('Makah', 'myh'),
('Menoninee', 'mez', 'Oma͞eqnomenew'),
('Mende', 'men', 'Mɛnde yia'),
('Mingrelian', 'xmf'),
('Kuṛmāli / Kudmali', 'kyw'),
('Tai Yo', 'tyj'),
# ('Myanmar', 'my', 'မြန်မာဘာသာ'),
# ('Navajo', 'nv', 'Diné bizaad'),
('Oneida', 'one', 'Onʌyoteʔa·ká·'),
('Otomanguean phonetic', 'omq'),
('Qiang', 'qiang'),
('Rohingya', 'rhg', ),
('Tamashek', 'tmh', 'ⵜⴰⵎⴰⵌⴰⵆ'),
('Tai Phake', 'phk'),
('Tangsa', 'nst', 'Tangsa'),
('Tibetan', 'bod'),
('Wolof', 'wo'),
('Bangali', 'bn'),
('Bassa', 'bsq'),
('Choctaw', 'cho'),
('Cree', 'cr'),
('Lenape', 'del'),
('Ho', 'hoc'),
('Igbo', 'ig'),
('Kaingang', 'kgp'),
('Kpelle', 'kpe'),
('Loma', 'lom'),
('Tai Viet script', 'tavt'),
('Karen', 'ksw'),
('Lampung', 'lampung'),
('Lepcha', 'lep'),
('Mongolian', 'mn'),
('Mende Kikakui', 'men'),
('Wancho', 'nnp'),
('Ojibwe', 'oj'),
('Nyiakeng Puachue Hmong', 'hnj'),
('Nigerian Pidgin', 'pcm'),
('Kinyarwanda', 'rw'),
('Shan', 'shn', 'လိၵ်ႈတႆ'),
('Sora', 'srb'),
('Tulu', 'tcy'),
('Tongan', 'to'),
('Sunuwar', 'suz'),
('Mundari', 'unr'),
('Yoruba', 'yo'),
('Zaghawa', 'zag'),
('Burmese', 'my'),
('Elfdalian', 'ovd', 'övdalsk'), # Added 9-Nov-2021
('Blackfoot', 'bla', 'ᓱᖽᐧᖿ'), # Added 10-Nov-2021
('Tamil', 'ta', 'தமிழ்'),
('Santali', 'sat', 'ᱥᱟᱱᱛᱟᱲᱤ'),
('Meitei (Manipuri)', 'mni', 'ꯃꯤꯇꯩ ꯃꯌꯦꯛ'),
('Aiton', 'aio', '(တႝ)ဢႝတွꩫ်'),
('Khamti', 'kmt', '(တဲး)ၵမ်းတီ'),
('Kalabari', 'ijn'),
('Mru', 'mro'),
('Sylheti', 'syl'),
('Fulfulde', 'ff'),
('Rhade', 'rad', 'klei Êđê'),
('Mahasu', 'bfz'),
('Vietnamese', 'vn', 'tiếng Việt'),
('Inupiaq', 'ik', 'Iñupiaq'),
('Lakota', 'lkt', 'Lakȟótiyapi'),
('Kihunde', 'hke'),
('Comanche', 'com', 'Nʉmʉ Tekwapʉ'),
('Kurmanji Yezidi', 'ku'),
]
class MainHandler(webapp2.RequestHandler):
def get(self):
template_values = {
'langlist': sorted(LanguageList, key=lambda lang: lang[0])
}
path = os.path.join(os.path.dirname(__file__), 'HTML/languagetools.html')
self.response.out.write(template.render(path, template_values))
class DownloadKBText(webapp2.RequestHandler):
def get(self):
infile = self.request.get("infile", "")
outfile = self.request.get("outfile", "")
template_values = {
'infile': infile,
'outfile': outfile,
}
path = os.path.join(os.path.dirname(__file__), 'HTML/keyboardTemplate.html')
self.response.out.write(template.render(path, template_values))
# Error catching
def handle_404(request, response, exception):
logging.exception(exception)
response.write('Sorry, but we cannot find that page in MAIN. Please try again.\n\n')
response.write('Request = %s\n' % request.url)
response.set_status(404)
def handle_500(request, response, exception):
logging.exception(exception)
response.write('A server error occurred in MAIN!')
response.write('Request = %s\n' % request.url)
response.set_status(500)
app = webapp2.WSGIApplication(
[
('/', MainHandler),
('/transliterate/', translit.TranslitUIHandler),
('/dotransliterate/', translit.DoTranslitHandler),
],
debug=True)
app.error_handlers[404] = handle_404
app.error_handlers[500] = handle_500