Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Dutch Language for text clock and locale for leftLabel Clock #40

Merged
merged 1 commit into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion settings_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, oacmode=False):
Ui_Settings.__init__(self)

# available text clock languages
self.textClockLanguages = ["English", "German"]
self.textClockLanguages = ["English", "German", "Dutch"]

# available Weather Widget languages
# self.owmLanguages = {"Arabic": "ar", "Bulgarian": "bg", "Catalan": "ca", "Czech": "cz", "German": "de",
Expand Down
63 changes: 44 additions & 19 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from urllib.parse import unquote

import ntplib
from PyQt5.QtCore import Qt, QSettings, QCoreApplication, QTimer, QVariant, QDate, QThread, pyqtSignal
from PyQt5.QtCore import Qt, QSettings, QCoreApplication, QTimer, QVariant, QDate, QLocale, QThread, pyqtSignal
from PyQt5.QtGui import QCursor, QPalette, QKeySequence, QIcon, QPixmap, QFont
from PyQt5.QtNetwork import QUdpSocket, QNetworkInterface
from PyQt5.QtWidgets import QApplication, QWidget, QShortcut, QDialog, QLineEdit, QVBoxLayout, QLabel
Expand All @@ -60,6 +60,9 @@ class MainScreen(QWidget, Ui_MainScreen):
getTimeWindow: QDialog
ntpHadWarning: bool
ntpWarnMessage: str
textLocale: str # for text language
languages = { "German": 'de_DE',
"Dutch" : 'nl_NL'}

def __init__(self):
QWidget.__init__(self)
Expand Down Expand Up @@ -678,6 +681,7 @@ def restore_settings_from_config(self):

settings.beginGroup("Formatting")
self.clockWidget.setAmPm(settings.value('isAmPm', False, type=bool))
self.textLocale=settings.value('textClockLanguage', 'English')
settings.endGroup()

settings.beginGroup("WeatherWidget")
Expand Down Expand Up @@ -752,7 +756,9 @@ def constant_update(self):
def update_date(self):
settings = QSettings(QSettings.UserScope, "astrastudio", "OnAirScreen")
settings.beginGroup("Formatting")
self.set_left_text(QDate.currentDate().toString(settings.value('dateFormat', 'dddd, dd. MMMM yyyy')))
set_language = settings.value('textClockLanguage', 'English')
lang=QLocale(self.languages[set_language] if set_language in self.languages else 'en_US')
self.set_left_text(lang.toString(QDate.currentDate(),settings.value('dateFormat', 'dddd, dd. MMMM yyyy')))
settings.endGroup()

def update_backtiming_text(self):
Expand Down Expand Up @@ -786,23 +792,42 @@ def update_backtiming_text(self):
string = '%d:00 Uhr' % hour

else:
# english textclock
if is_am_pm:
if hour > 12:
hour -= 12
if minute == 0:
string = "it's %d o'clock" % hour
if (0 < minute < 15) or (16 <= minute <= 29):
string = "it's %d minute%s past %d:00" % (minute, 's' if minute > 1 else '', hour)
if minute == 15:
string = "it's a quarter past %d:00" % hour
if minute == 30:
string = "it's half past %d:00" % hour
if minute == 45:
string = "it's a quarter to %d:00" % hour
if (31 <= minute <= 44) or (46 <= minute <= 59):
string = "it's %d minute%s to %d:00" % (
remain_min, 's' if remain_min > 1 else '', 1 if hour == 12 else hour + 1)
# Dutch textclock
if text_clock_language == "Dutch":
if is_am_pm:
if hour > 12:
hour -= 12
if minute == 0:
string = "Het is %d uur" % hour
if (0 < minute < 15) or (16 <= minute <= 29):
string = "Het is %d minute%s over %d:00" % (minute, 'n' if minute > 1 else '', hour)
if minute == 15:
string = "Het is kwart over %d:00" % hour
if minute == 30:
string = "Het is half %d:00" % (hour + 1)
if minute == 45:
string = "Het is kwart voor %d:00" % hour
if (31 <= minute <= 44) or (46 <= minute <= 59):
string = "Het is %d minute%s voor %d:00" % (
remain_min, 'n' if remain_min > 1 else '', 1 if hour == 12 else hour + 1)
else:
# english textclock
if is_am_pm:
if hour > 12:
hour -= 12
if minute == 0:
string = "it's %d o'clock" % hour
if (0 < minute < 15) or (16 <= minute <= 29):
string = "it's %d minute%s past %d:00" % (minute, 's' if minute > 1 else '', hour)
if minute == 15:
string = "it's a quarter past %d:00" % hour
if minute == 30:
string = "it's half past %d:00" % hour
if minute == 45:
string = "it's a quarter to %d:00" % hour
if (31 <= minute <= 44) or (46 <= minute <= 59):
string = "it's %d minute%s to %d:00" % (
remain_min, 's' if remain_min > 1 else '', 1 if hour == 12 else hour + 1)

self.set_right_text(string)

Expand Down