Skip to content

Commit

Permalink
Add language support
Browse files Browse the repository at this point in the history
  • Loading branch information
quintenvandamme committed Jun 29, 2024
1 parent a90922f commit f74ac73
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 39 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,6 @@ jobs:
artifacts: "./out/*"
allowUpdates: true
tag: "continious-build"

Linux_aarch64:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build in ARM64 Environment
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker build --platform linux/arm64 -t tv-downloader:latest .
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
check-latest: true

- name: Build TV Downloader
run: docker run --rm -v $(pwd):/workspace -w /workspace tv-downloader:latest python build.py build

- name: Upload Binary
uses: ncipollo/release-action@v1
with:
artifacts: "./out/*"
allowUpdates: true
tag: "continuous-build"

Windows_x86_64:
runs-on: windows-latest
Expand Down
62 changes: 61 additions & 1 deletion gui/lang/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ class Lang:
def __init__(self, lang=None):
loc = locale.getdefaultlocale()[0]

if lang is None:
if lang is None or lang == "":
if loc.startswith("en_"):
self.lang = "en"
elif loc.startswith("nl_"):
self.lang = "nl"
elif loc.startswith("de_"):
self.lang = "de"
elif loc.startswith("fr_"):
self.lang = "fr"
else:
self.lang = "en"
else:
Expand All @@ -19,6 +23,20 @@ def get(self, key):
return en[key]
elif self.lang == "nl":
return nl[key]
elif self.lang == "de":
return de[key]
elif self.lang == "fr":
return fr[key]

def getLanguages(self):
languages = ["en", "nl", "de", "fr"]
return languages

def getLanguage(self):
return self.lang

def setLanguage(self, lang):
self.lang = lang

en = {
"menu": "Menu",
Expand All @@ -35,6 +53,8 @@ def get(self, key):
"version": "Version",
"Ok": "Ok",
"no-description": "No description available",
"save": "Save",
"language": "Language",
}

nl = {
Expand All @@ -52,4 +72,44 @@ def get(self, key):
"version": "Versie",
"Ok": "Ok",
"no-description": "Geen beschrijving beschikbaar",
"save": "Opslaan",
"language": "Taal",
}

de = {
"menu": "Menü",
"settings": "Einstellungen",
"about": "Über",
"search": "Suche",
"download_location": "Download Standort:",
"open": "Öffnen",
"vrt_account": "VRT Konto",
"e-mail": "E-Mail",
"password": "Passwort",
"select-download-location": "Download Standort auswählen",
"about-text": "TV Downloader ist eine Anwendung, die es Ihnen ermöglicht, Videos von verschiedenen Nachrichtenwebsites herunterzuladen.",
"version": "Version",
"Ok": "Ok",
"no-description": "Keine Beschreibung verfügbar",
"save": "Speichern",
"language": "Sprache",
}

fr = {
"menu": "Menu",
"settings": "Paramètres",
"about": "À propos",
"search": "Rechercher",
"download_location": "Emplacement de téléchargement:",
"open": "Ouvrir",
"vrt_account": "Compte VRT",
"e-mail": "E-mail",
"password": "Mot de passe",
"select-download-location": "Sélectionner l'emplacement de téléchargement",
"about-text": "TV Downloader est une application qui vous permet de télécharger des vidéos à partir de différents sites d'actualités.",
"version": "Version",
"Ok": "Ok",
"no-description": "Aucune description disponible",
"save": "Enregistrer",
"language": "Langue",
}
33 changes: 29 additions & 4 deletions gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from lang import Lang

settings = Settings()
lang = Lang()
lang = Lang(settings.get('Settings', 'language'))

def resource_path(relative_path):
if hasattr(sys, '_MEIPASS'):
Expand Down Expand Up @@ -152,6 +152,10 @@ def _create_widgets(self):
def _handle_search(self):
# This function will be called when the search button is clicked
search_query = self.search_input.text()

# Clear the search results
self.search_results.clear()

videos = get_videos(search_query, settings,self.window)
for video in videos:
videoItem(video, self.search_results)
Expand All @@ -165,7 +169,7 @@ def __init__(self, window):
self.window = QDialog(window)
self.window.setWindowTitle(lang.get('settings'))
self.window.setWindowIcon(QIcon(resource_path('data/logo/logo-256x256.png')))
self.window.setMinimumSize(600, 300)
self.window.setMinimumSize(400, 300)
self.window.show()
self._create_widgets()

Expand All @@ -191,6 +195,24 @@ def _create_widgets(self):
download_button.clicked.connect(lambda: self._download_button_action())
download_layout.addWidget(download_button)

# create a language setting
language_layout = QHBoxLayout()

selectedLang = settings.get('Settings', 'language')
if selectedLang == '':
selectedLang = lang.getLanguage()

language_label = QLabel(lang.get('language'))
language_layout.addWidget(language_label)
self.language_combobox = QComboBox()
languages = lang.getLanguages()
languages.remove(selectedLang)
languages.insert(0, selectedLang)
for language in languages:
self.language_combobox.addItem(language)

language_layout.addWidget(self.language_combobox)

# create vrt account settings
vrt_account_layout = QHBoxLayout()
vrt_account_label = QLabel(lang.get('vrt_account'))
Expand All @@ -204,13 +226,14 @@ def _create_widgets(self):
self.vrt_account_input.setEchoMode(QLineEdit.EchoMode.Password)
self.vrt_account_input.width = 250
vrt_account_layout.addWidget(self.vrt_account_input)

# add a save button
save_button = QPushButton('Opslaan')
save_button = QPushButton(lang.get('save'))
save_button.clicked.connect(lambda: self._save_button_action())
save_layout.addWidget(save_button)

layout.addLayout(download_layout)
layout.addLayout(language_layout)
layout.addLayout(vrt_account_layout)
layout.addLayout(save_layout)

Expand All @@ -226,6 +249,8 @@ def _save_button_action(self):
settings.set('Settings', 'download_path', self.download_path_input.text())
settings.set('Vrt', 'email', self.vrt_account_email_input.text())
settings.set('Vrt', 'password', self.vrt_account_input.text())
settings.set('Settings', 'language', self.language_combobox.currentText())
lang.setLanguage(self.language_combobox.currentText())
self.window.close()

class AboutApplication:
Expand Down

0 comments on commit f74ac73

Please sign in to comment.