forked from eliranwong/UniqueBible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanguages.py
440 lines (432 loc) · 19.4 KB
/
Languages.py
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
import config, pprint, platform, myTranslation
from translations import translations
# [Optional] Google-translate
try:
from googletrans import Translator
googletransInstall = True
except:
googletransInstall = False
class Languages:
codes = {
"Afrikaans": "af",
"Albanian": "sq",
"Amharic": "am",
"Arabic": "ar",
"Armenian": "hy",
"Azerbaijani": "az",
"Basque": "eu",
"Belarusian": "be",
"Bengali": "bn",
"Bosnian": "bs",
"Bulgarian": "bg",
"Catalan": "ca",
"Cebuano": "ceb",
"Chinese (Simplied)": "zh-CN",
"Chinese (Traditional)": "zh-TW",
"Corsican": "co",
"Croatian": "hr",
"Czech": "cs",
"Danish": "da",
"Dutch": "nl",
"English": "en",
"Esperanto": "eo",
"Estonian": "et",
"Finnish": "fi",
"French": "fr",
"Frisian": "fy",
"Galician": "gl",
"Georgian": "ka",
"German": "de",
"Greek": "el",
"Gujarati": "gu",
"Haitian Creole": "ht",
"Hausa": "ha",
"Hawaiian": "haw",
"Hebrew he or": "iw",
"Hindi": "hi",
"Hmong": "hmn",
"Hungarian": "hu",
"Icelandic": "is",
"Igbo": "ig",
"Indonesian": "id",
"Irish": "ga",
"Italian": "it",
"Japanese": "ja",
"Javanese": "jv",
"Kannada": "kn",
"Kazakh": "kk",
"Khmer": "km",
"Korean": "ko",
"Kurdish": "ku",
"Kyrgyz": "ky",
"Lao": "lo",
"Latin": "la",
"Latvian": "lv",
"Lithuanian": "lt",
"Luxembourgish": "lb",
"Macedonian": "mk",
"Malagasy": "mg",
"Malay": "ms",
"Malayalam": "ml",
"Maltese": "mt",
"Maori": "mi",
"Marathi": "mr",
"Mongolian": "mn",
"Myanmar (Burmese)": "my",
"Nepali": "ne",
"Norwegian": "no",
"Nyanja (Chichewa)": "ny",
"Pashto": "ps",
"Persian": "fa",
"Polish": "pl",
"Portuguese (Portugal, Brazil)": "pt",
"Punjabi": "pa",
"Romanian": "ro",
"Russian": "ru",
"Samoan": "sm",
"Scots Gaelic": "gd",
"Serbian": "sr",
"Sesotho": "st",
"Shona": "sn",
"Sindhi": "sd",
"Sinhala (Sinhalese)": "si",
"Slovak": "sk",
"Slovenian": "sl",
"Somali": "so",
"Spanish": "es",
"Sundanese": "su",
"Swahili": "sw",
"Swedish": "sv",
"Tagalog (Filipino)": "tl",
"Tajik": "tg",
"Tamil": "ta",
"Telugu": "te",
"Thai": "th",
"Turkish": "tr",
"Ukrainian": "uk",
"Urdu": "ur",
"Uzbek": "uz",
"Vietnamese": "vi",
"Welsh": "cy",
"Xhosa": "xh",
"Yiddish": "yi",
"Yoruba": "yo",
"Zulu": "zu",
}
translation = {
"menu1_app": "UniqueBible",
"menu1_fullScreen": "Full Screen",
"menu1_resize": "Resize",
"menu1_topHalf": "Top Half",
"menu1_leftHalf": "Left Half",
"menu1_remoteControl": "Open / Close Remote Control",
"menu1_setDefaultFont": "Select Default Font and Size",
"menu1_setChineseFont": "Select Chinese Font",
"menu1_setAbbreviations": "Select Bible Abbreviations",
"menu1_setMyFavouriteBible": "Select my Favourite Bible",
"menu1_setMyLanguage": "Select my Language",
"menu1_translateInterface": "Translate Program Interface into my Language",
"menu1_toogleInterface": "Program Interface: English / My Translation",
"menu1_wikiPages": "Wiki Pages",
"menu1_update": "Update",
"menu1_exit": "Exit",
"menu2_view": "Layout",
"menu2_all": "All Toolbars [Show / Hide]",
"menu2_topOnly": "All Toolbars / Only Top Toolbar",
"menu2_top": "Top Toolbar [Show / Hide]",
"menu2_second": "Second Toolbar [Show / Hide]",
"menu2_left": "Left Sidebar [Show / Hide]",
"menu2_right": "Right Sidebar [Show / Hide]",
"menu2_icons": "Toolbar Icons [Full-size / Standard]",
"menu2_landscape": "Landscape / Portrait Orientation",
"menu2_study": "Study Window [Resize / Hide]",
"menu2_bottom": "Bottom Window [Show / Hide]",
"menu2_hover": "Instant feature [Enable / Disable]",
"menu2_larger": "Increase Font Size",
"menu2_smaller": "Decrease Font Size",
"menu2_format": "Formatted / Simple Style Bible",
"menu2_subHeadings": "Add Paragraph headings on Simple Style Bible",
"menu3_history": "History",
"menu3_main": "Bible Window's History",
"menu3_mainBack": "Bible Window's Previous Record",
"menu3_mainForward": "Bible Window's Next Record",
"menu3_study": "Study Window's History",
"menu3_studyBack": "Study Window's Previous Record",
"menu3_studyForward": "Study Window's Next Record",
"menu4_further": "Further Study",
"menu4_book": "Book Features",
"menu4_chapter": "Chapter Features",
"menu4_next": "Next Chapter",
"menu4_previous": "Previous Chapter",
"menu4_indexes": "Smart Indexes",
"menu4_commentary": "Bible Commentary",
"menu4_traslations": "Translations",
"menu4_discourse": "Discourse Analysis",
"menu4_words": "Individual Words",
"menu4_tdw": "TDW Combo",
"menu4_crossRef": "Cross References",
"menu4_tske": "TSK (Enhanced edition)",
"menu4_compareAll": "Compare All Bible Versions",
"menu4_moreComparison": "Comparison / Parallel Reading / Difference",
"menu5_search": "Search",
"menu5_bible": "Bibles",
"menu5_main": "Bible Window's Last Opened Bible",
"menu5_study": "Study Window's Last Opened Bible",
"menu5_dictionary": "The Last Opened Bible Dictionary",
"menu5_encyclopedia": "The Last Opened Bible Encyclopedia",
"menu5_book": "The Last Opened Reference Book",
"menu5_selectBook": "Reference Book",
"menu5_favouriteBook": "My Favourite Reference Books",
"menu5_allBook": "All Reference Books",
"menu5_characters": "Bible Characters",
"menu5_names": "Bible People Names",
"menu5_locations": "Bible Locations",
"menu5_topics": "Bible Topics",
"menu5_lastTopics": "The Last Opened Bible Topics",
"menu5_allTopics": "All Bible Topics",
"menu5_lexicon": "Hebrew / Greek Lexicon",
"menu5_3rdDict": "Third Party Dictionaries",
"menu6_notes": "Bible Notes",
"menu6_mainChapter": "Bible Window's Bible Chapter Notes",
"menu6_studyChapter": "Study Window's Bible Chapter Notes",
"menu6_searchChapters": "Search Bible Chapter Notes",
"menu6_mainVerse": "Bible Window's Bible Verse Notes",
"menu6_studyVerse": "Study Window's Bible Verse Notes",
"menu6_searchVerses": "Search Bible Verse Notes",
"menu7_topics": "Note Files",
"menu7_create": "Create a New File",
"menu7_open": "Open an Existing File",
"menu7_recent": "Recently Opened Files",
"menu7_read": "Read the Last Opened File",
"menu7_edit": "Edit the Last Opened File",
"menu7_paste": "Read Clipboard's Text",
"menu8_resources": "Resources",
"menu8_bibles": "Install Formatted Bible",
"menu8_commentaries": "Install Bible Commentary",
"menu8_datasets": "Install Marvel.bible Datasets",
"menu8_plusLexicons": "Install BibleBentoPlus Lexicon",
"menu8_plusDictionaries": "Install BibleBentoPlus Dictionary",
"menu8_3rdParty": "Import 3rd Party Module",
"menu8_3rdPartyInFolder": "Import Multiple 3rd Party Modules",
"menu8_settings": "Select Import Options",
"menu8_tagFile": "Add Bible Reference Links to a File",
"menu8_tagFiles": "Add Bible Reference Links to Multiple Files",
"menu8_tagFolder": "Add Bible Reference Links to a Folder's Files",
"menu9_information": "Information",
"menu9_credits": "Sources",
"menu9_contact": "Contact us",
"menu10_books": "Books",
"menu10_dialog": "Open a Reference Book",
"menu10_addFavourite": "Add a Favourite Reference Book",
"menu10_displayContent": "Display Content: Study / New Window",
"menu10_bookOnNew": "Further book content will be opened on a new window.",
"menu10_bookOnStudy": "Further book content will be opened on Study Window.",
"context1_copy": "Copy",
"context1_copyReferences": "Copy All Bible References",
"context1_speak": "Speak",
"context1_english": "Translate into English",
"context1_tChinese": "翻譯成繁體中文",
"context1_sChinese": "翻译成简体中文",
"context1_my": "My Language",
"context1_translate": "Translate into",
"context1_pinyin": "翻译成汉语拼音",
"context1_search": "Search",
"context1_current": "Search Opened Bible Book",
"context1_favourite": "Search my Favourite Bible",
"context1_original": "Search Hebrew / Greek Bible",
"context1_originalLexicon": "Search Hebrew / Greek Lexicon",
"context1_favouriteBooks": "Search my Favourite Reference Books",
"context1_allBooks": "Search All Reference Books",
"context1_encyclopedia": "Bible Encyclopedia",
"context1_dict": "Bible Dictionary",
"context1_extract": "Extract All Bible References",
"context1_command": "Run as Command",
"bar1_title": "Top Toolbar",
"bar2_title": "Second Toolbar",
"bar3_title": "Left Sidebar",
"bar4_title": "Right Sidebar",
"bar2_enableBible": "Open Bible References on Study Window",
"bar2_disableBible": "Open Bible References on Bible Window",
"bar1_menu": "Select / Search Bible Window's Bible",
"bar1_reference": "Bible Window's Bible Reference",
"bar1_chapterNotes": "Bible Window's Bible Chapter Notes",
"bar1_verseNotes": "Bible Window's Bible Verse Notes",
"bar1_searchBible": "Search Bible Window's Last Opened Bible",
"bar1_searchBibles": "Search Bible Window's Bible",
"bar1_command": "Type your command here",
"bar1_toolbars": "Show / Hide Other Toolbars",
"bar2_menu": "Select / Search Study Window's Bible",
"bar2_reference": "Study Window's Bible Reference",
"bar2_chapterNotes": "Study Window's Bible Chapter Notes",
"bar2_verseNotes": "Study Window's Bible Verse Notes",
"bar2_searchBible": "Search Study Window's Last Opened Bible",
"bar2_searchBibles": "Search Study Window's Bible",
"bar2_searchBooks": "Search Reference Book",
"bar3_pdf": "Export to PDF",
"note_title": "Note Editor Menu Bar",
"note_save": "Save",
"note_saveAs": "Save as",
"note_print": "Print",
"note_toolbar": "Show / Hide Toolbar",
"note_mode": "Rich Format / Plain Mode",
"noteTool_title": "Toolbar",
"noteTool_bold": "Bold Font",
"noteTool_italic": "Italic Font",
"noteTool_underline": "Underline Style",
"noteTool_trans0": "Transform Selected Text",
"noteTool_trans1": "For example, create a bullet list:",
"noteTool_trans2": "For example, create a numbered list:",
"noteTool_trans3": "For example, create a table:",
"noteTool_no1": "one",
"noteTool_no2": "two",
"noteTool_no3": "three",
"noteTool_no4": "four",
"noteTool_no5": "five",
"noteTool_no6": "six",
"noteTool_left": "Align Left",
"noteTool_centre": "Align Centre",
"noteTool_right": "Align Right",
"noteTool_justify": "Justify Text",
"noteTool_delete": "Delete Formatting",
"noteTool_hyperlink": "Add a Hyperlink",
"noteTool_externalImage": "Link to an External Image File",
"noteTool_image": "Embed an Image",
"noteTool_exportImage": "Export Embedded Images",
"tabBible": "Bible",
"tabStudy": "Tool",
"message_done": "Done.",
"message_fail": "Failed to complete the last operation!",
"message_invalid": "Entered command is invalid!",
"message_missing": "Missing component:",
"message_installFirst": "Install it first and try again.",
"message_restart": "Restart this application to apply the new changes.",
"message_run": "Before you can run this feature, you need to:",
"message_selectWord": "Select a word or some words.",
"message_setLanguage": "Select your language.",
"message_translateFirst": "Translate program interface into your language.",
"message_improveTrans": "To improve the quality of interface translation, you may close this application first and manually edit this file:",
"message_newInterfaceItems": "Added new translated items of program interface.",
"message_migration": "Some of your files are old. We are helping you to upgrade those files.",
"message_noReference": "Found no bible reference.",
"message_noSupport": "It looks like that this feature does not work on your device.",
"message_newerFile": "This file has a newer version:",
"message_installFrom": "Install from menu:",
"message_downloadAllFiles": "It takes time to complete this operation.",
"message_noSupportedFile": "No valid file.",
"message_tagged": "Tagged file is prefixed with:",
"message_willBeNoticed": "You will receive another message when the operation is done.",
"html_searchBible2": "Search Bible:",
"html_searchBibles2": "Search Multiple Bibles:",
"html_features": "Special Features:",
"html_and": "and:",
"html_showCompare": "Show Comparison",
"html_showParallel": "Show Parallel Reading",
"html_showDifference": "Show Difference",
"html_current": "Current Selection:",
"html_bibles": "Bible Version:",
"html_book": "Bible Book:",
"html_chapter": "Bible Chapter:",
"html_verse": "Bible Verse:",
"html_open": "open",
"html_openHere": "open HERE",
"html_openMain": "open on Bible Window",
"html_openStudy": "open on Study Window",
"html_introduction": "Introduction",
"html_overview": "Overview",
"html_summary": "Summary",
"html_chapterIndex": "Bible Characters & Locations",
"html_timelines": "Timelines",
"message_remarks": "Remarks:",
"message_cancel": "Cancel",
"message_install": "Download and Install",
"message_downloadHelper": "Download Helper",
"message_searchMorphology": "Search Morphology",
"import_linebreak": "Additional linebreak for each bible verse",
"import_strongNo": "Allow search for Strong's numbers",
"import_morphCode": "Allow search for morphology codes",
"import_rtl": "Old Testament Text Direction: Right-to-left",
"import_interlinear": "Interlinear Bible",
"message_addFavouriteVersion": "Add as a parallel version for reading multiple bible verse references:",
"search_notFound": "[no result]",
"menu11_multimedia": "Multimedia",
"menu11_images": "Images",
"menu11_music": "Music",
"menu11_video": "Video",
"menu11_setupDownload": "Instructions to Setup YouTube Downloader",
"menu11_youtube": "Download YouTube Audio / Video",
"youtube_back": "Back",
"youtube_forward": "Forward",
"youtube_mp3": "Download Audio in mp3 Format",
"youtube_mp4": "Download Video in mp4 Format",
"youtube_address": "Enter a YouTube address:",
"youtube_copy": "Copy Opened Link",
"menu9_donate": "Donate to us",
"menu8_moreBooks": "Download More Reference Books",
"menu1_moreConfig": "Select More ...",
"message_readWiki": "You may check this Wiki page for description of the following items:",
"menu1_tabNo": "Select Number of Tabs",
"menu5_last3rdDict": "The Last Opened Third Party Dictionary",
"menu8_marvelData": "Database Files",
"menu8_download3rdParty": "Download 3rd Party Modules",
"menu10_bookFromImages": "Create a Reference Book from Image Files",
"menu10_bookFromHtml": "Create a Reference Book from HTML Files",
"menu10_bookFromNotes": "Create a Reference Book from Note Files",
"noteTool_header1": "Header 1",
"noteTool_header2": "Header 2",
"noteTool_header3": "Header 3",
"noteTool_textFont": "Text Font",
"noteTool_textColor": "Text Color",
"noteTool_textBackgroundColor": "Text Background Color",
"menu10_clearBookHighlights": "Clear Highlights of Search Result",
"menu1_reload": "Reload the Last Opened Records",
"select_a_folder": "Select a Folder",
"bar2_commentarySyncEnabled": "Commentary in Sync with Main Window",
"bar2_commentarySyncDisabled": "Commentary out of Sync with Main Window",
"bar2_studyWindowBibleSyncEnabled": "Study Window's Bible in Sync with Main Window",
"bar2_studyWindowBibleSyncDisabled": "Study Window's Bible out of Sync with Main Window",
"empty": "[empty]",
}
def translateInterface(self, language):
code = self.codes[language]
if code in translations:
config.translationLanguage = language
if hasattr(myTranslation, "translation"):
open("myTranslation.py", "w", encoding="utf-8").close()
return True
else:
print("translating interface into '{0}' ...".format(language))
translator = Translator()
tempDict = {}
for key, value in self.translation.items():
try:
tempDict[key] = translator.translate(value, dest=code).text
except:
tempDict[key] = value
#config.translationLanguage = language
self.writeMyTranslation(tempDict, language)
print("Done")
return True
return False
def writeMyTranslation(self, translationDict, language):
with open("myTranslation.py", "w", encoding="utf-8") as fileObj:
content = "translationLanguage = {0}\ntranslation = {1}\n".format(pprint.pformat(language), pprint.pformat(translationDict))
fileObj.write(content)
def createTranslationTemplates(self):
if googletransInstall:
for code in self.codes.values():
print("creating '{0}' template ...".format(code))
translator = Translator()
tempDict = {}
for key, value in self.translation.items():
tempDict[key] = value
# Note: Attempted to use Google Translate to translate interface into all languages, but access is blocked in the middle of the operation. It looks like Google blocks access by ip, when there are too many queries within a short time.
# Don't use the following 4 lines, or ip will be blocked for Google Translate
# try:
# tempDict[key] = translator.translate(value, dest=code).text
# except:
# tempDict[key] = value
with open("translations.py", "a", encoding="utf-8") as fileObj:
code = code.replace("-", "")
fileObj.write("uB{0} = {1}\n\n".format(code, pprint.pformat(tempDict)))
if __name__ == '__main__':
Languages().createTranslationTemplates()