55from PyQt6 .QtCore import *
66from PyQt6 .QtGui import *
77import configparser
8+ import json
89
910
1011
11- tab_name = "Yeni Sekme"
12- history = "./public/browser/history.txt"
1312config_path = "./config/config.conf"
13+ config = configparser .ConfigParser ()
14+ config .read (config_path )
15+
16+ language = config ["Language" ]["language" ]
17+
18+ with open (f"./public/browser/languages/{ language } .json" , "r" , encoding = "UTF-8" ) as jsonn :
19+ texts = json .load (jsonn )
20+
21+ tab_name = texts ["tab-name" ]
22+ history = "./public/browser/history.txt"
1423bookmarks = "./public/browser/bookmarks.txt"
1524
1625if not os .path .exists (history ):
2837 with open (bookmarks , 'x' ) as bf :
2938 pass
3039
31- config = configparser .ConfigParser ()
32- config .read (config_path )
40+
3341
3442search_engine = config ['Settings' ]['search_engine' ]
3543tab_color = config ['Appearance' ]['tab_color' ]
@@ -68,7 +76,7 @@ def __init__(self):
6876
6977 self .url_bar = QLineEdit ()
7078 self .url_bar .returnPressed .connect (self .load_url )
71- self .url_bar .setPlaceholderText ("URL ya da metin girin..." )
79+ self .url_bar .setPlaceholderText (texts [ "url_bar_placeholder" ] )
7280 self .url_bar .setFont (QFont ("Lexend" ))
7381 self .url_bar .setFixedHeight (25 )
7482 self .url_bar .setStyleSheet ("white-space: nowrap;" )
@@ -229,12 +237,12 @@ def browser_reload(self):
229237 def show_context_menu (self , position ):
230238 context_menu = QMenu (self )
231239
232- context_menu .addAction ("Kopyala" , self .browser_copy )
233- context_menu .addAction ("Yapıştır" , self .browser_paste )
234- context_menu .addAction ("Kaydet" , self .browser_save )
235- context_menu .addAction ("Geri" , self .browser_back )
236- context_menu .addAction ("İleri" , self .browser_forward )
237- context_menu .addAction ("Yeniden Yükle" , self .browser_reload )
240+ context_menu .addAction (texts [ "right-click-copy" ] , self .browser_copy )
241+ context_menu .addAction (texts [ "right-click-paste" ] , self .browser_paste )
242+ context_menu .addAction (texts [ "right-click-save" ] , self .browser_save )
243+ context_menu .addAction (texts [ "right-click-back" ] , self .browser_back )
244+ context_menu .addAction (texts [ "right-click-forward" ] , self .browser_forward )
245+ context_menu .addAction (texts [ "right-click-reload" ] , self .browser_reload )
238246
239247
240248 context_menu .exec (self .tabs .currentWidget ().mapToGlobal (position ))
@@ -296,13 +304,13 @@ def load_bookmarks(self, top_layout):
296304class AnkaBrowserSettings (QDialog ):
297305 def __init__ (self , parent = None ):
298306 super ().__init__ (parent )
299- self .setWindowTitle ("Anka | Ayarlar" )
300- self .setFixedSize (QSize (500 ,225 ))
307+ self .setWindowTitle (texts [ "settings-title" ] )
308+ self .setFixedSize (QSize (500 ,300 ))
301309
302310
303311 layout = QVBoxLayout ()
304312
305- self .search_engine_label = QLabel ("Arama Motoru: " )
313+ self .search_engine_label = QLabel (texts [ "settings-search-engine" ] )
306314 layout .addWidget (self .search_engine_label )
307315
308316 self .search_engine = QComboBox ()
@@ -312,6 +320,9 @@ def __init__(self, parent=None):
312320 self .search_engine .addItem ("Bing" )
313321 self .search_engine .addItem ("Brave" )
314322 self .search_engine .addItem ("Startpage" )
323+
324+ self .language_label = QLabel ("Dil / Language" )
325+ layout .addWidget (self .language_label )
315326
316327 if search_engine == "https://google.com" :
317328 self .search_engine .setCurrentIndex (0 )
@@ -326,26 +337,38 @@ def __init__(self, parent=None):
326337
327338 layout .addWidget (self .search_engine )
328339
329- self .tab_color_button_label = QLabel ("Sekme rengi seçin: " )
340+ self .language = QComboBox ()
341+ self .language .setFixedSize (450 ,25 )
342+ self .language .addItem ("tr-TR" )
343+ self .language .addItem ("en-EN" )
344+
345+ if language == "tr-TR" :
346+ self .language .setCurrentIndex (0 )
347+ else :
348+ self .language .setCurrentIndex (1 )
349+
350+ layout .addWidget (self .language )
351+
352+ self .tab_color_button_label = QLabel (texts ["settings-tab-color-label" ])
330353 layout .addWidget (self .tab_color_button_label )
331354
332- self .tab_color_button = QPushButton ("Sekme Rengi" )
355+ self .tab_color_button = QPushButton (texts [ "settings-tab-color-button" ] )
333356 self .tab_color_button .setFixedSize (QSize (450 ,25 ))
334357 self .tab_color_button .clicked .connect (self .open_tab_color_dialog )
335358 layout .addWidget (self .tab_color_button )
336359
337- self .delete_history_button = QPushButton ("Geçmişi Sil" )
360+ self .delete_history_button = QPushButton (texts [ "settings-history" ] )
338361 self .delete_history_button .setFixedSize (QSize (450 ,25 ))
339362 self .delete_history_button .clicked .connect (self .delete_history )
340363 layout .addWidget (self .delete_history_button )
341364
342- self .note_label = QLabel ("Ayarları yapılandırmak için lütfen tarayıcıyı yeniden başlatın." )
365+ self .note_label = QLabel (texts [ "settings-info-msg" ] )
343366 self .note_label .setStyleSheet ("padding-top: 5px;" )
344367 layout .addWidget (self .note_label )
345368
346369 self .buttons = QDialogButtonBox (QDialogButtonBox .StandardButton .Ok | QDialogButtonBox .StandardButton .Cancel )
347- self .buttons .button (QDialogButtonBox .StandardButton .Cancel ).setText ("İptal" )
348- self .buttons .button (QDialogButtonBox .StandardButton .Ok ).setText ("Tamam" )
370+ self .buttons .button (QDialogButtonBox .StandardButton .Cancel ).setText (texts [ "settings-button-cancel" ] )
371+ self .buttons .button (QDialogButtonBox .StandardButton .Ok ).setText (texts [ "settings-button-ok" ] )
349372 self .buttons .accepted .connect (self .ok )
350373 self .buttons .rejected .connect (self .cancel )
351374 layout .addWidget (self .buttons )
@@ -363,6 +386,13 @@ def ok(self):
363386 config ["Settings" ]["search_engine" ] = "https://search.brave.com"
364387 elif s_engine == "StartPage" :
365388 config ["Settings" ]["search_engine" ] = "https://startpage.com"
389+
390+ lan = self .language .currentText ()
391+ match lan :
392+ case "tr-TR" :
393+ config ["Language" ]["language" ] = "tr-TR"
394+ case "en-EN" :
395+ config ["Language" ]["language" ] = "en-EN"
366396
367397 with open ('config/config.conf' , 'w' ) as configfile :
368398 config .write (configfile )
@@ -383,7 +413,7 @@ def delete_history(self):
383413class Tab_Color_Dialog (QColorDialog ):
384414 def __init__ (self , parent = None ):
385415 super ().__init__ (parent )
386- self .setWindowTitle ("Anka | Renk Seçin" )
416+ self .setWindowTitle (texts [ "tab-color-dialog-title" ] )
387417 self .setFixedSize (QSize (500 ,159 ))
388418
389419 tabColor = Tab_Color_Dialog .getColor ()
0 commit comments