-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaraz
5010 lines (4914 loc) · 234 KB
/
taraz
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
#Email : [email protected]
# This software is the property of Taraz.
# No part of this software may be reproduced in any form without the prior written permission of Taraz.
"""
Name: Taraz_Software.exe
Version: 1.0.0
Author: mjt369
https://www.taraz.com
Date Created: 2024
Description: text edit and translator and books search_internet etc .
"""
#بسم الله الرحمن الرحیم#
import sys
import os
import time
from unicodedata import digit
from PyQt5.QtCore import QCoreApplication, QEvent
import pyperclip
import ttkthemes # type: ignore
script_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, script_dir)
try:
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QPushButton, QComboBox, QMessageBox,QTextEdit,QCheckBox
from PyQt5.QtCore import Qt
from PyQt5 import QtGui
import re
from bidi.algorithm import get_display
import threading
except:
pass
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
from tkinter import messagebox,colorchooser
from tkinter.simpledialog import askstring
from tkinter import PhotoImage
class LazyImport:
def __init__(self, module_name):
self.module_name = module_name
self.module = None
def __getattr__(self, name):
if self.module is None:
self.module = __import__(self.module_name, fromlist=[name])
return getattr(self.module, name)
Sequence = LazyImport("difflib")
langdetec = LazyImport("langdetect")
pdf2= LazyImport("pdf2docx")
dox = LazyImport("docx")
SpellChecke = LazyImport("spellchecker")
Translator1 = LazyImport("translatepy")
Translator2 = LazyImport("argostranslate.translate")
pakage=LazyImport('argostranslate')
Translator3 = LazyImport("googletrans")
Translator5 = LazyImport("deep_translator")
translator6 = LazyImport("translators")
ggl = LazyImport("google_searching")
wikipedia = LazyImport("wikipedia")
gc = LazyImport("gc")
shutil = LazyImport("shutil")
farsi_tool = LazyImport("farsi_tools")
Speller = LazyImport("autocorrect")
requests = LazyImport("requests")
urllib = LazyImport("urllib.parse")
hashlib = LazyImport("hashlib")
unicodedata = LazyImport("unicodedata")
ftfy = LazyImport("ftfy")
def on_close():
if messagebox.askokcancel("Quit \n بستن برنامه", "Do you want to quit? \n\n برنامه بسته شود؟"):
os._exit(0)
def importer():
try:
from difflib import SequenceMatcher
from collections import Counter
import re
from langdetect import detect
except:
pass
try:
import argostranslate.translate
import argostranslate.package
from pdf2docx import Converter
from docx2pdf import convert
import docx2pdf
from docx import Document
from docx.shared import Pt, RGBColor
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from spellchecker import SpellChecker
except:
pass
try:
import translatepy
import translators # type: ignore
except:
pass
try:
import googletrans
except:
pass
try:
import deep_translator
except:
pass
try:
import threading
import time
import requests
import hashlib
import gc
import shutil
except:
pass
try:
from farsi_tools import replace_ascii_digits_with_farsi,stop_words
from autocorrect import Speller
from google_searching import ggl
import wikipedia
except:
pass
def restart():
TranslationWindow(root)
class TranslationWindow:
def __init__(self, root):
super().__init__()
self.nam="Taraz Software 313 بِسْمِ اللهِ الرَّحْمنِ الرَّحِیم"
self.myColor = '#dee9ef'
self.myColor2= '#d3ecfa'
self.myColor3='#8de0d1'
self.myColor4='#d3ecfa'
self.myColor5='#a67b19'
self.myColor6='#a67b19'
self.default="""
plastik
فارسی
فارسی
False
#141414
14
Arial
مترجم دیپ
spaceCorrect1"""
self.default2="""
plastik
English
English
False
#141414
14
Arial
Google 1
spaceCorrect1"""
try:
self.root = root
root.title(self.nam)
try:
with open('them.json', 'r',encoding="utf-8") as f:
lines = f.read().splitlines()
self.them1 = lines[1]
self.lang_in1 = lines[2]
self.lang_out1 = lines[3]
self.corrections1 = lines[4]
self.color1 = lines[5]
self.size1 = lines[6]
self.font1 = lines[7]
self.translator1 = lines[8]
self.spaceCorrect1 = lines[9]
except:
#self.update_notification(self.M254)
with open('them.json', 'w',encoding="utf-8") as f:
f.write(self.default)
with open('them.json', 'r',encoding="utf-8") as f:
lines = f.read().splitlines()
self.them1 = lines[1]
self.lang_in1 = lines[2]
self.lang_out1 = lines[3]
self.corrections1 = lines[4]
self.color1 = lines[5]
self.size1 = lines[6]
self.font1 = lines[7]
self.translator1 = lines[8]
self.spaceCorrect1 = lines[9]
self.num=self.them1
root.geometry("1280x600")
root.configure(bg=self.myColor3) # Setting color of main window to self.myColor
self.dir= os.getcwd()
style = ttkthemes.ThemedStyle()
try:
style.theme_use(self.num) # Replace with the desired theme (e.g., 'adapta') itft1 breeze plastik adapta radiance clearlooks kroc smog
except:
style.theme_use('plastik')
style.configure('TButton', font=('arial', 11,'bold'))
book = tk.StringVar(value="کتابخانه")
books = ["قرآن",'نهج البلاغه',"اصول کافي","نهج الفصاحه","موعظه","سه دقیقه در قیامت","تمنای وصال",'شعر تمنای وصال']
self.book_box = tk.OptionMenu(root, book, *books)
self.book_box.config(font=('Arial', 11,"bold"),bg=self.myColor4,highlightthickness=1)
self.book_box.bind("<<StringVarSelected>>", self.gift)
self.var = tk.IntVar()
self.var2 = tk.IntVar()
book.trace("w", self.gift)
font_var = tk.StringVar(value='Arial')
fonts = ["Arial",'Arial (Arabic)','Simplified Arabic Fixed',
'Courier New (Arabic)','Urdu Typesetting','Sakkal Majalla',
'Simplified Arabic','Traditional Arabic', ]
self.font_box = tk.OptionMenu(root, font_var, *fonts)
self.font_box.cget("text")
self.size_var = tk.StringVar(value=self.size1) # Create a StringVar
self.size_box = tk.Spinbox(root, from_=0, to=100, textvariable=self.size_var,width=10, relief="sunken", repeatdelay=500, repeatinterval=100,
font=("Arial", 12), bg="lightgrey", fg="blue", command=self.update_font)
self.text_font = ( self.font1, self.size1)
font_var.trace("w", self.update_font)
self.empty_1=False
self.regui()
self.start1()
except :
pass
def regui(self):
try:
root.configure(bg=self.myColor) # Setting color of main window to self.myColor
except :
pass
def start1(self):
try:
self.dir= os.getcwd()
self.size_box.config(font=('Arial', 11,"bold"),bg=self.myColor4,highlightthickness=1)
self.font_box.config(font=('Arial', 11,"bold"),bg=self.myColor4,highlightthickness=1)
self.file_button = ttk.Button(root, command=self.select_file,)
self.translate_button = ttk.Button(root, command=self.translate,)
self.trans_file_button = ttk.Button(root, command=self.trans_file,)
self.pdf_convert = ttk.Button(root, command=self.pdf_converter,)
self.export_button = ttk.Button(root, command=self.export_docx,)
self.clear_button = ttk.Button(root, command=self.clear,)
self.Qt_translator = ttk.Button(root, command=self.Qt_translator_,)
self.stop_button = ttk.Button(root,command=self.stop,)
self.copy_button = ttk.Button(root, command=self.copy_to_clipboard,)
self.copy_button.pack(pady=10, padx=10) # paste from
self.paste_button = ttk.Button(root, command=self.paste_from_clipboard,)
self.reset_button = ttk.Button(root, command=self.restart_program,)
self.help_button = ttk.Button(root, command=self.show_help_message,)
self.lang_button = ttk.Button(self.root, text="فارسی", command=self.Lang, compound="center",)
self.lang2_button = ttk.Button(self.root, text="English", command=self.Lang2, compound="center",)
self.source_language_label = ttk.Label(root)
self.source_language_label.config(font=('Arial', 10,"bold"))
self.target_language_label = ttk.Label(root, text="To language :")
self.target_language_label.config(font=('Arial', 10,"bold"))
with open('index_lang.json', 'r') as f:
lang = f.read()
if lang == 'en':
self.lang_en()
else:
self.lang_fa()
self.space = tk.IntVar()
self.space_corect = tk.Checkbutton(root, text=self.M11, variable=self.space, command=self.aktive_space)
self.text=""
self.language_codes_2 = {
"en":self.M100,
"auto":self.M104,
"fa":self.M102,
"de":self.M101,
"ar":self.M109,
"fr":self.M108,
"zh": self.M103,
"es": self.M110,
"ru": self.M111,
"it": self.M106,
"tr":self.M112,
"pt":self.M113,
"id": self.M114,
"nl": self.M107,
"hi": self.M115,
"ja": self.M116,
"ur":self.M117}
self.language_codes = {
self.M100: "en",
self.M104:"auto",
self.M102: "fa",
self.M101: "de",
self.M109: "ar",
self.M108: "fr",
self.M103: "zh-CN",
self.M110: "es",
self.M111: "ru",
self.M106: "it",
self.M112: "tr",
self.M113: "pt",
self.M114: "id",
self.M107: "nl",
self.M115: "hi",
self.M116: "ja",
self.M117: "ur",}
self.input_text_label = ttk.Label(root, text=self.M200)
self.output_text_label = ttk.Label(root, text=self.M202)
self.correction = tk.Checkbutton(root, text=self.M84, variable=self.var, command=self.aktive_correction)
self.virastar = tk.Checkbutton(root, text=self.M94, variable=self.var2, command=self.aktive_virast)
self.translator_var = tk.StringVar()
self.translator_var_label = ttk.Label(root, text=self.M124)
self.translator_var_label.config(font=('Arial', 11))
self.translator_var.set(self.translator1) # Set default value
self.translator_menu = ttk.Combobox(root,state="readonly", textvariable=self.translator_var,
values=[self.M118,self.M119,self.M120,self.M259,self.M260,self.M261,self.M121,self.M122,self.M201,self.M123])
self.translator_menu.bind("<<ComboboxSelected>>", self.lang_code)
# self.translator_menu.pack()
self.translator_menu.config(font=('Arial', 13))
them=[
'itft1','aquativo','plastik','radiance','clearlooks',
'adapta','kroc','breeze','smog','alt',
'classic','winnative','clam','default',
'vista', 'xpnative','arc','elegance'
]
self.them_num_var = tk.StringVar()
self.them_num_var.set(self.num)
self.them_num = ttk.Combobox(root,state="readonly", textvariable=self.them_num_var,
values=them)
self.them_num.bind("<<ComboboxSelected>>", self.them)
self.them_num.config(font=('Arial', 13))
document_mode = tk.StringVar(value=self.M96)
docu = [self.M96,self.M98,self.M99,self.M97, ]
self.document_mode_box = tk.OptionMenu(root, document_mode, *docu)
self.document_mode_box.config(font=('Arial', 10,"bold"),bg=self.myColor4,highlightthickness=1)
fot = tk.StringVar(value=self.M12)
docfot = [self.M153,self.M12,self.M146,self.M152 ,self.M182,self.M196]
self.format_box= tk.OptionMenu(root, fot, *docfot)
self.format_box.config(font=('Arial', 10,"bold"),bg=self.myColor4,highlightthickness=1)
self.source_language_combo = ttk.Combobox(root, state="readonly",values=[self.M102,self.M100, self.M103,self.M110,self.M101,self.M104,
self.M109,self.M113,self.M106,self.M107,
self.M108, self.M111,
self.M112,self.M113,self.M114,self.M115,
self.M116,self.M117],cursor="hand2")
self.source_language_combo.set(self.lang_in1)
self.target_language_combo = ttk.Combobox(root,state="readonly",values=[self.M102,self.M100,self.M103,self.M113, self.M101,
self.M109,self.M106,self.M107,
self.M108, self.M110, self.M111,
self.M112,self.M113,self.M114,self.M115,
self.M116,self.M117],cursor="hand2")
self.target_language_combo.set(self.lang_out1)
self.target_language_combo.config(font=('Arial', 12,"bold"))
self.source_language_combo.config(font=('Arial', 12,"bold"))
self.source_language_combo.bind("<<ComboboxSelected>>", self.lang_code)
self.target_language_combo.bind("<<ComboboxSelected>>", self.lang_code)
self.output_console = self.create_console("white", "blue", 550, 100, 520, 380)
self.output_console.configure(state=tk.DISABLED)
self.input_console = self.create_console("white", "black", 10, 100, 520, 380)
self.input_console.bind('<Return>', self.translate_aout)
self.notif_console = self.create_console("white", "red", 10, 487, 520, 30)
self.notif_console.config(font='Arial')
self.notif_console.config(state=tk.DISABLED)
self.info_console = self.create_console("white", "red", 550, 487, 520, 30)
self.info2_console = self.create_console("white", "green", 1100, 10, 160, 30)
self.info2_console.config(font='Arial')
self.info3_console = self.create_console("white", "green", 1100, 260, 160, 90)
self.input_text_label.place(x=440, y=76,width=110, height=25)
self.output_text_label.place(x=970, y=76,width=110, height=25)
self.info3_console.config(font='Arial')
self.info_console.config(font='Arial')
self.info_console.config(state=tk.DISABLED)
self.info2_console.config(state=tk.DISABLED)
self.info3_console.config(state=tk.DISABLED)
input_scrollbar = tk.Scrollbar(self.root, command=self.input_console.yview)
output_scrollbar = tk.Scrollbar(self.root, command=self.output_console.yview)
output_scrollbar.place(x=1070, y=110, height=360)
input_scrollbar.place(x=530, y=110, height=360)
self.output_console.config(yscrollcommand=output_scrollbar.set)
self.input_console.config(yscrollcommand=input_scrollbar.set)
self.translate_pay=False
self.arg_para=False
self.extract=False
self.start2()
self.start()
except :
pass
def start2(self):
# Copy Button
#==========Check boxes====================
self.font_box.place(x=570, y=38,width=210, height=25)
self.correction.place(x=790, y=38,width=95, height=25)
self.virastar.place(x=35, y=66,width=250, height=25)
self.space_corect.place(x=900, y=38,width=180, height=25)
self.size_box.place(x=500, y=38,width=66, height=25)
self.document_mode_box.place(x=14, y=38,width=178, height=25)
self.format_box.place(x=200, y=38,width=210, height=25)
self.book_box.place(x=420, y=38,width=78, height=25)
#===========combo=========================
self.source_language_label.place(x=15, y=10,width=210, height=25)
self.source_language_combo.place(x=118, y=10,width=170, height=25)
self.them_num.place(x=700, y=10,width=110, height=25)
self.target_language_label.place(x=370, y=10,width=210, height=25)
self.target_language_combo.place(x=470, y=10,width=170, height=25)
self.translator_var_label.place(x=835, y=10,width=77, height=25)
self.translator_menu.place(x=910, y=10,width=170, height=25)
#===========================================
# Translate Button
self.Qt_translator.place(x=790, y=530, width=110, height=50)
self.stop_button.place(x=670, y=530, width=110, height=50)
self.export_button.place(x=910, y=530, width=85, height=50)
self.copy_button.place(x=1000, y=530, width=85, height=50)
self.trans_file_button.place(x=490, y=530, width=170, height=50)
self.translate_button.place(x=310, y=530, width=170, height=50)
self.paste_button.place(x=10, y=530, width=96, height=50)
self.file_button.place(x=110, y=530, width=96, height=50)
# Gift Button
self.pdf_convert .place(x=210, y=530, width=96, height=50)
#lang_button
self.lang_button.place(x=1100, y=390, width=160, height=30)
#lang2_button
self.lang2_button.place(x=1100, y=430, width=160, height=30)
# Clear Button
self.clear_button.place(x=1100 ,y=510, width=160, height=30)
# Help Button
self.help_button.place(x=1100, y=470, width=160, height=30)
#color
self.reset_button.place(x=1100, y=550,width=160, height=30)
self.internet_aktive=False
self.book_aktive=False
self.dict_aktive=False
self.coorrect_aktive=True
self.search_Active=False
self.separate_search=True
self.offline_installed=False
self.ketab_=""
self.file_path=''
self.tranc_err=False
self.word_office_not_installed=False
self.search_process=''
self.save_word=False
self.clicked=False
self.clicked_trueWords=False
self.pdf=False
self.excel=False
self.words2=''
self.virastar=True
self.i=0
self.update_font()
self.anti_crash()
self.books_handle()
def info(self,text):
self.info_console.config(state=tk.NORMAL)
self.info_console.delete(1.0, tk.END)
self.info_console.insert(tk.END, text)
self.info_console.config(state=tk.DISABLED)
def info2(self,text):
self.info2_console.config(state=tk.NORMAL)
self.info2_console.delete(1.0, tk.END)
self.info2_console.insert(tk.END, text)
self.info2_console.config(state=tk.DISABLED)
def info3(self,text):
self.info3_console.config(state=tk.NORMAL)
self.info3_console.delete(1.0, tk.END)
self.info3_console.insert(tk.END, text)
self.info3_console.config(state=tk.DISABLED)
def jamal(self):
self.info2("https://www.iranlawclinic.com")
try:
os.startfile('کلینیک حقوقی ایران.html')
except:
self.info("\n https://www.iranlawclinic.com")
def them(self,event):
t=self.them_num.get()
try:
with open('them.json', 'r',encoding="utf-8") as f:
lines = f.read().splitlines()
if len(lines) > 1:
lines[1] = t # replace the second line
with open('them.json', 'w',encoding="utf-8") as f:
for line in lines:
f.write(line + '\n')
except:
self.update_notification(self.M254)
with open('them.json', 'w',encoding="utf-8") as f:
f.write(self.default)
result = messagebox.askquestion(self.M258,self.M87)
if result == 'yes':
self.restart_program()
return
def anti_crash(self):
self.filter = ['Download', 'Herunterladen', 'تحميل', 'Télécharger','اکستروژن','فلز','game','بازی','Punch-tera','موسیقی','Crush','جادوگر',
'"','Descargar', 'Загружать', 'Scaricare', 'İndirmek', 'Baixar','دانلود','کامپیوتری','Britney' ,'Bastard','Punch']
try:
self.perian_num=tk.BooleanVar()
self.Farsi_text_edit=tk.BooleanVar()
self.virast=tk.BooleanVar()
self.space_word__disabled=tk.BooleanVar()
self.using_orginal_text_enable=tk.BooleanVar()
self.rtl_format_true=tk.BooleanVar()
self.text_edit=tk.BooleanVar()
self.nazar=tk.BooleanVar()
self.jomlesazi=tk.BooleanVar()
self.deghat=tk.BooleanVar()
self.sjmle=tk.BooleanVar()
self.gf=tk.BooleanVar()
menubar = tk.Menu(self.root)
self.root.config(menu=menubar)
self.file_menu = tk.Menu(menubar, tearoff=0)
self.edit_menu = tk.Menu(menubar, tearoff=0)
self.rakb_menu = tk.Menu(menubar, tearoff=0)
self.frg = tk.Menu(menubar, tearoff=0)
self.format = tk.Menu(menubar, tearoff=0)
self.input_console.config(fg=self.color1)
self.output_console.config(fg=self.color1)
menubar.add_cascade(label=self.M1, menu=self.file_menu)
menubar.add_cascade(label=self.M8, menu=self.edit_menu)
menubar.add_cascade(label=self.M150, menu=self.rakb_menu)
menubar.add_cascade(label=self.M212, menu=self.frg)
self.file_menu.add_command(label=self.M6, command=on_close)
self.file_menu.add_command(label=self.M2, command=self.new_file)
self.file_menu.add_command(label=self.M3, command=self.open_file)
self.file_menu.add_command(label=self.M4, command= self.save_file)
self.file_menu.add_command(label=self.M411, command= self.save_file_in)
self.file_menu.add_separator()
self.edit_menu.add_checkbutton(label=self.M94, variable=self.virast)
self.edit_menu.add_checkbutton(label=self.M127,variable=self.jomlesazi)
self.edit_menu.add_checkbutton(label=self.M14, variable=self.Farsi_text_edit)
self.edit_menu.add_checkbutton(label=self.M11, variable=self.space_word__disabled)
self.edit_menu.add_checkbutton(label=self.M16, variable=self.perian_num)
self.edit_menu.add_checkbutton(label=self.M17, variable=self.rtl_format_true)
self.edit_menu.add_checkbutton(label=self.M18, variable=self.using_orginal_text_enable)
self.rakb_menu.add_command(label=self.M10, command=self.choose_color)
self.rakb_menu.add_command(label=self.M19, command=self.cut_text)
self.rakb_menu.add_command(label=self.M20, command=self.copy_text)
self.rakb_menu.add_command(label=self.M21, command=self.paste_text)
def sent_degh ():
self.sjmle.set(0)
self.gf.set(0)
def sent_degh_2 ():
self.deghat.set(0)
self.gf.set(0)
def sent_degh_3():
self.deghat.set(0)
self.sjmle.set(0)
self.frg.add_checkbutton(label=self.M178, variable=self.deghat,command=sent_degh)
self.frg.add_checkbutton(label=self.M180, variable=self.sjmle,command=sent_degh_2)
self.frg.add_checkbutton(label=self.M213, variable=self.gf,command=sent_degh_3)
self.frg.add_command(label=self.M255,command=self.show)
except:
pass
def books_handle(self):
try:
dic_labels= [self.M125, self.M154,self.M181, self.M159, self.M160, self.M166,self.M207,
self.M167, self.M168, self.M169, self.M173,self.M188,self.M213]
ketab_labels = [self.M172,self.M194,
self.M170,self.M208,self.M211, self.M174, self.M175,
self.M179,self.M244,self.M183,self.M209, self.M210,
self.M186, self.M187,self.M265,self.M266,self.M264,
self.M190, self.M192,self.M193,self.M262 , self.M263,self.M213,
]
int_labels= [self.M163, self.M164,self.M238,self.M73,self.M213]
sina_labels= [self.M216,self.M217,self.M218,self.M219,self.M220,self.M221,
self.M222,self.M223,self.M224,self.M225,self.M226,
]
sher_labels = [self.M171,self.M189,self.M191,self.M228,self.M229,self.M230,
self.M231,self.M232,self.M233,self.M234,self.M235,
self.M213
]
teb_labels = [self.M185, self.M199,self.M242 ,self.M267,self.M213 ]
self.dict= ttk.Combobox(root, state="readonly",values=dic_labels,cursor="hand2")
self.dict.set(self.M177)
self.dict.config(font=('Arial', 11))
self.dict.bind("<<ComboboxSelected>>", self.on_ketab_1)
self.sher= ttk.Combobox(root, state="readonly",values=sher_labels,cursor="hand2")
self.sher.set(self.M227)
self.sher.config(font=('Arial', 11))
self.sher.bind("<<ComboboxSelected>>", self.on_ketab_6)
self.books= ttk.Combobox(root, state="readonly",values=ketab_labels,cursor="hand2")
self.books.set(self.M176)
self.books.config(font=('Arial', 11))
self.books.bind("<<ComboboxSelected>>", self.on_ketab_2)
self.internet= ttk.Combobox(root, state="readonly",values=int_labels,cursor="hand2")
self.internet.set(self.M165)
self.internet.config(font=('Arial', 11))
self.internet.bind("<<ComboboxSelected>>", self.on_ketab_3)
self.sina= ttk.Combobox(root, state="readonly",values=sina_labels,cursor="hand2")
self.sina.set(self.M203)
self.sina.config(font=('Arial', 11))
self.sina.bind("<<ComboboxSelected>>", self.on_ketab_4)
self.teb= ttk.Combobox(root, state="readonly",values=teb_labels,cursor="hand2")
self.teb.set(self.M241)
self.teb.config(font=('Arial', 11))
self.teb.bind("<<ComboboxSelected>>", self.on_ketab_7)
self.correct= ttk.Combobox(root, state="readonly",values=[self.M128,self.M15,self.M213,],cursor="hand2")
self.correct.set(self.M84)
self.correct.config(font=('Arial', 11))
self.correct.bind("<<ComboboxSelected>>", self.on_ketab_5)
self.correct.place(x=1100, y=40,width=160, height=25)
self.dict.place(x=1100, y=70,width=160, height=25)
self.books.place(x=1100, y=100,width=160, height=25)
self.sina.place(x=1100, y=130,width=160, height=25)
self.sher.place(x=1100, y=160,width=160, height=25)
self.internet.place(x=1100, y=190,width=160, height=25)
self.teb.place(x=1100, y=220,width=160, height=25)
self.stopBook=False
except:
pass
def off_ketab(self):
self.end=True
self.search_Active=False
self.separate_search=False
self.internet_aktive=False
self.book_aktive=False
self.dict_aktive=False
self.internet.set(self.M165)
self.dict.set(self.M177)
self.sher.set(self.M227)
self.sina.set(self.M203)
self.books.set(self.M176)
self.teb.set(self.M241)
self.info2('')
return
def on_ketab_1(self,event):
self.internet.set(self.M165)
self.sina.set(self.M203)
self.books.set(self.M176)
self.sher.set(self.M227)
self.teb.set(self.M241)
if not self.dict.get() in [self.M213,self.M177]:
self.spm=False
self.separate_search=False
self.search_Active=True
self.internet_aktive=False
self.book_aktive=False
self.dict_aktive=True
if self.dict.get() != self.M125:
self.info2(self.dict.get())
try:
if self.thread_active==False:
self.separate_search=True
self.ketab_=""
src_book_dic=self.searching_book_options()
if self.spm==True or src_book_dic==True :
self.run_book_search()
elif self.dict.get()in [self.M207] :
self.search_process=self.dict.get()
self.run_book_search()
except:
pass
else: self.info2(self.M125)
else:
self.off_ketab()
def on_ketab_2(self,event):
self.internet.set(self.M165)
self.dict.set(self.M177)
self.sina.set(self.M203)
self.sher.set(self.M227)
self.teb.set(self.M241)
if not self.books.get() in [self.M213,self.M176]:
self.separate_search=False
self.spm=False
self.search_Active=True
self.internet_aktive=False
self.dict_aktive=False
self.book_aktive=True
self.info2(self.books.get())
try:
if self.thread_active==False:
self.separate_search=True
self.ketab_=""
src_book_dic=self.searching_book_options()
if self.spm==True or src_book_dic==True :
self.run_book_search()
except:
pass
else:
self.off_ketab()
def on_ketab_3(self,event):
self.dict.set(self.M177)
self.sina.set(self.M203)
self.books.set(self.M176)
self.sher.set(self.M227)
self.teb.set(self.M241)
self.info2(self.internet.get())
if self.internet.get() in [self.M238]:
self.jamal()
self.internet.set(self.M165)
self.internet_aktive=False
self.update_notification("")
return
if self.internet.get() in [self.M73]:
self.selected_url = ""
self.url = ""
self.download_manager()
self.internet.set(self.M165)
self.internet_aktive=False
self.update_notification("")
return
if not self.internet.get() in [self.M213,self.M165]:
self.search_Active=True
self.book_aktive=False
self.dict_aktive=False
self.separate_search=False
self.internet_aktive=True
self.info2(self.internet.get())
try:
if self.thread_active==False:
self.separate_search=True
self.ketab_=""
self.search_process=self.internet.get()
self.run_book_search()
except:
pass
else:
self.off_ketab()
def on_ketab_4(self,event):
self.internet.set(self.M165)
self.dict.set(self.M177)
self.books.set(self.M176)
self.sher.set(self.M227)
self.teb.set(self.M241)
if not self.sina.get() in [self.M213,self.M203]:
self.info2(self.sina.get())
self.spm=False
self.separate_search=False
self.search_Active=True
self.internet_aktive=False
self.dict_aktive=False
self.book_aktive=True
try:
if self.thread_active==False:
self.separate_search=True
self.ketab_=""
src_book_dic=self.searching_book_options()
if self.spm==True or src_book_dic==True :
self.run_book_search()
except:
pass
else:
self.off_ketab()
def on_ketab_5(self,event):
self.coorrect_aktive=True
self.search_Active=True
self.info2(self.correct.get())
if self.correct.get()==self.M213:
self.coorrect_aktive=False
def aktive_virast(self):
if self.var2.get()==1:
self.coorrect_aktive=True
self.search_Active=True
self.info2(self.M128)
self.virast.set(1)
else:
self.virast.set(0)
self.info2(" ")
def aktive_correction(self):
if self.var.get()==1:
self.coorrect_aktive=True
self.search_Active=True
self.info2(self.M128)
self.correct.set(self.M128)
else:
self.correct.set(self.M133)
self.info2(" ")
self.coorrect_aktive=False
def aktive_space(self):
if self.space.get()==1:
self.space_word__disabled.set(1)
else:
self.space_word__disabled.set(0)
def on_ketab_6(self,event):
self.internet.set(self.M165)
self.dict.set(self.M177)
self.sina.set(self.M203)
self.books.set(self.M176)
self.teb.set(self.M241)
if not self.sher.get() in [self.M213,self.M227]:
self.separate_search=False
self.spm=False
self.search_Active=True
self.internet_aktive=False
self.dict_aktive=False
self.book_aktive=True
self.info2(self.sher.get())
try:
if self.thread_active==False:
self.separate_search=True
self.ketab_=""
src_book_dic=self.searching_book_options()
if self.spm==True or src_book_dic==True :
self.run_book_search()
except:
pass
else:
self.off_ketab()
def on_ketab_7(self,event):
self.internet.set(self.M165)
self.dict.set(self.M177)
self.sina.set(self.M203)
self.sher.set(self.M227)
self.books.set(self.M176)
if not self.teb.get() in [self.M213,self.M241]:
self.info2(self.teb.get())
self.separate_search=False
self.spm=False
self.search_Active=True
self.internet_aktive=False
self.dict_aktive=False
self.book_aktive=True
try:
if self.thread_active==False:
self.separate_search=True
self.ketab_=""
src_book_dic=self.searching_book_options()
if self.spm==True or src_book_dic==True :
self.run_book_search()
except:
pass
else:
self.off_ketab()
def run_book_search(self):
try:
self.stopBook=False
QApplication.exit()
except:
pass
try:
self.cunter=0
self.info2('')
except:
pass
time.sleep(0.66)
threading.Thread(target=self.book_search, args=("", "", "")).start()
def start(self):
self.dir_path = os.path.join(os.path.expanduser('~'), '.local', 'cache', 'argos-translate', 'downloads')
self.base_path = os.path.join(os.path.expanduser('~'), '.local', 'share', 'argos-translate', 'packages')
self.destination_path = os.path.join(os.path.expanduser('~'), '.local', 'cache', 'argos-translate')
self.source_path = os.path.join(self.dir, 'index.json')
self.file_name = os.path.basename(self.source_path)
self.destination_file_path = os.path.join(self.destination_path, self.file_name)
self.special_chars = ['$', '#', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';','«','»' ,'؟','!',
'<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}','،']
self.url_downloads='url_downloads.json'
self.sin = ['~','!','@','#','$','%','^','&','*','(',')','_','-','=','.','/','','+','<',
'>','{','}','?','؟','|','"',"'",
':',';',',','حح"', '"حح', 'حححح',]
self.invalid_languages = {'', 'Exception', 'No features in text', 'id', 'ur', 'ch', 'af', 'sl', 'se', 'sr', 'sk', 'su',
'hy', 'as', 'av', 'ay', 'bn', 'bg', 'ch', 'cv', 'cr', 'cs', 'dv', 'so', 't1', 'ca','lv','lt','pl',
'et', 'ee', 'no', 'ro', 'fy', 'gu', 'ha', 'kn', 'kk', 'km', 'fi','sv','da','hr','t1','tl',
'kj', 'ko', 'ms', 'nn', 'uk', 'nb', 'pa', 'rn', 'tk', 'xh','uz','bo','cy','vi','ro','sw'}
self.time= 0.23
self.info3_console.config(state=tk.NORMAL)
self.info3_console.insert(tk.END, self.M126)
self.info3_console.config(state=tk.DISABLED)
self.MainWindow()
self.create_context_menu(self.input_console)
self.create_context_menu(self.output_console)
self.create_context_menu(self.notif_console)
self.patterns = [
r'\b[a-zA-Z0-9]+\b|\W'
r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', # Email
r'\b\d{5}(?:-\d{4})?\b', # Zip code
r'\b\d{1,16}\b', # ID
r'\b\d+\b', # ID
r'\b00\d{2}\d{7,12}\b',
r'\+\d{2}\d{7,12}\b', # Phone number starting
r'\b0\d{2}\d{7,12}\b', # Phone number starting with '0'
r'\b00\d{2}\d{7,10}\b',
r'\b0\d{2}\d{7,10}\b',
r'^[a-zA-Z]',
r'([a-zA-Z]+)',
r'\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b' # IP address
]
self.email = [
r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', # Email
]
self.patterns_latin = [
r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', # Email
r'\b\d{5}(?:-\d{4})?\b', # Zip code
r'\b\d{1,16}\b', # ID
r'\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b', # IP address
r'\b\d{3}[-.\s]??\d{3}[-.\s]??\d{4}\b', # Phone number
r'\+?\d{1,4}?[-.\s]?\(?(?:\d{1,3}?\)?[-.\s]?)?\d{1,4}[-.\s]?\d{1,9}',
r'\b\d{1,16}\b', # ID
r'\b00\d{2}\d{7,12}\b', # Phone number starting with '00' followed by 2 digits and 7 to 12 more digits
r'\b0\d{2}\d{7,12}\b', # Phone number starting with '0' followed by 2 digits and 7 to 12 more digits
r'\b00\d{2}\d{7,10}\b',
r'\b0\d{2}\d{7,10}\b']
self.start_with=['ب', 'ن', 'می', 'نمی', 'بی', 'نا','ا','ال','الا','ول','پر','داد','آ','جا','محمد','میر',
'با','بال','و','هم','این','به','نی','ل','خو','نیک','پاک','وا','بر','دار','هر','نم','چون',
'در','سر','م','پیش','پس','ان','علی','خان','خواجه','نی','نیا','بار','خوش','بد','الی','فر',
'یک','دوی','سی','چهار','پان','پنج','چهل','پنجاه','شش','شصت','هفت','هفتاد','زشت','والا',
'هشت','هشتاد','نه','نود','هزار','میلیون','ملیارد','ترلیون','بهر','بهره','زیبا','من','ز',
]
self.start_with.sort(key=len, reverse=True)
self.start_with=set(self.start_with)
self.suffixes = [ 'یمایشان', 'هایمان', 'هایشان', 'یمایش', 'ستان', 'طور', 'طوری', 'گاری', 'گذار',
'ستانی','خو','سر','وند', 'انی', 'یمان', 'هایم', 'هایش', 'های', 'آلات','ریز', 'که',
'علی','خان','خواجه','گی','بیک','بیگ','اژ','خور','ار','زاد','راد','سیرت','بار','فر',
'یک','دوی','سی','چهار','پان','پنج','چهل','پنجاه','شش','شصت','هفت','سرشت','یار',
'هفتاد','هشت','هشتاد','نه','نود','هزار','میلیون','ملیارد','ترلیون','شاه','رت',
'دار', 'زا', 'هایت', 'گار', 'مین','بر','فت','افت','فند','تان', 'سرا', 'های','داد',
'یند', 'نامه', 'آموزی', 'آموز', 'وار', 'کار', 'مند', 'گرا','ست','یافت','پیش',
'پس''داری', 'گیری', 'آور', 'ستان', 'گری', 'گاه', 'بین', 'زاده', 'واری', 'منش',
'یان','ییان','دا','بود','خوار', 'آوازه', 'بند', 'بندی', 'نواز', 'انه', 'پذیر',
'ترین', 'پسین', 'یه', 'چه','ک','وه','مان','در','ات', 'یم', 'گر', 'یت', 'یش',
'بندی', 'بند', 'ان', 'ای','نامه', 'بان', 'بانی','ند','اند','شان','سیرت','ین',
'ید', 'نی', 'می','تر' ,'ها', 'ی', 'م', 'ت', 'ه', 'د', 'ا','ش','را','انداز',
]
self.persian_conjunctions = [
# حروف ربط ساده
"و", "یا", "پس", "اگر", "نه", "را", "چون", "چه", "تا", "اما", "باری", "خواه", "زیرا", "که", "لیکن", "نیز", "ولی", "هم",
# حروف ربط مرکب
"بالعکس", "ولو", "به جز", "سپس", "از این گذشته", "همچنین", "چون که", "چندان که", "زیرا که", "همان که", "بلکه", "چنانچه", "تا این که", "تا آن که", "آنگاه که", "از آنجا که", "از این رو", "از بس", "از بهر آن که", "اکنون که", "اگرچه", "اگر", "مگر این که", "با این حال", "با این که", "با وجود این", "بس که", "به شرط آن که",
# حروف ربط گسسته ربطی
"خواه", "چه", "یا", "نه", "هم"
]
self.suffixes.sort(key=len, reverse=True)
self.suffixes=set(self.suffixes)
self.char_groups = [ ['ز', 'ظ'], ['ز', 'ض'], ['ذ', 'ز'], ['ض', 'ظ'], ['ظ', 'ض'], ['ذ', 'ظ'],
['ذ', 'ض'], ['ز', 'ذ'], ['ظ', 'ز'], ['ض', 'ز'], ['ط', 'ت'], ['ت', 'ط'],
['ر', 'ز'], ['ز', 'ر'], ['د', 'ذ'], ['ذ', 'د'], ['ح', 'ه'], ['ه', 'ح'],
['ج', 'چ'], ['چ', 'ج'], ['ح', 'خ'], ['خ', 'ح'], ['ح', 'خ'], ['ح', 'ج'],
['ج', 'ح'], ['ص', 'س'], ['س', 'ص'], ['س', 'ث'], ['ص', 'ث'], ['س', 'ص'],
['ش', 'س'], ['ص', 'ث'], ['ص', 'س'], ['ث', 'ص'], ['ث', 'س'], ['ص', 'س'],
['س', 'ش'], ['ع', 'ا'], ['ا', 'ع'], ['ا', 'ع'],['ا', 'ع'],
['ق', 'غ'], ['غ', 'ق'], ['ق', 'ف'], ['ف', 'ق'],
['ک', 'گ'], ['یی', 'ت'], ['یی', 'ی'], ['یی', ''], ['ک', 'گ'], ['گ', 'ک'], ['خوا', 'خا'], ['خا', 'خوا'] ]
self.chars = set(['','آ','ا','ا','ب', 'پ', 'ت', 'ث', 'ج', 'چ', 'ح', 'خ', 'د', 'ذ', 'ر',
'ز', 'ژ', 'س', 'ش', 'ص', 'ض', 'ط', 'ظ', 'ع', 'غ', 'ف', 'ق', 'ک', 'گ',
'ل', 'م', 'ن', 'و', 'ه', 'ی'])
self.single=set(['ب', 'پ', 'ت', 'ث', 'ج', 'چ', 'ح', 'خ', 'د', 'ذ', 'ر', 'ز', 'ژ', 'س', 'ش', 'ص', 'ض', 'ط', 'ظ', 'ع', 'غ', 'ف', 'ق', 'ک', 'گ', 'ل', 'م', 'ن','ی'])
self.on_off()
def on_off(self):
self.color_code = (0, 0, 0)
self.search_opt='select'
self.file_content = {}
self.reerror_pakages = False
self.reinstalled = False
self.thread_active=False
self.pack_install = False
self.argose_err = False
self.pack_downloaded=False
self.rtl_mode = False
self.packerror=False
self.er=False
self.last_detected_languages ="en"
self.tra=False
self.reerror_pakages=False
self.reinstalled=False
self.new_word=False
self.dfiscancel=False
self.rev=False
self.export_docx_=False
self.sp1=False
self.sp2=False
self.sp3=False
self.sp4=False
self.S5=False
self.S6=False
self.S7=False
self.S8=False
self.S9=False
self.S10=False
self.S11=False
self.S12=False
self.S13=False
self.S14=False
self.S15=False
self.S16=False
self.S17=False
self.S18=False
self.S19=False
self.S20=False
self.S21=False
self.S22=False
self.S23=False
self.S24=False
self.S25=False
self.S26=False
self.S27=False
self.S28=False
self.S29=False
self.S30=False
self.S31=False
self.spm=False
self.S32=False
self.S33=False
self.S34=False
self.S35=False
self.S36=False
self.S37=False
self.S38=False
self.S40=False
self.S41=False
self.S42=False
self.S43=False
self.S44=False
self.S45=False