Skip to content

Commit

Permalink
feat: add Hungarian translation
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Apr 9, 2022
1 parent 8ba3c21 commit 5cd6892
Show file tree
Hide file tree
Showing 8 changed files with 91,765 additions and 90,001 deletions.
36 changes: 34 additions & 2 deletions gridplayer/dialogs/about.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import NamedTuple
from typing import List, NamedTuple

from pydantic.version import VERSION as PYDANTIC_VERSION
from PyQt5.Qt import PYQT_VERSION_STR
Expand All @@ -26,6 +26,12 @@ class Attribution(NamedTuple):
url: str


class AttributionTranslation(NamedTuple):
language: str
author: str
author_url: str


class AboutDialog(QDialog, Ui_AboutDialog):
def __init__(self, parent):
super().__init__(parent)
Expand Down Expand Up @@ -131,18 +137,28 @@ def __init__(self, parent):
),
]

attributions_translation = [
AttributionTranslation(
"Hungarian",
"samu112",
"https://crowdin.com/profile/samu112",
),
]

attributions_txt = [
"<style>p, h3 {text-align: center;}</style>",
self.generate_attributions(attributions_general),
"<h3>{0}</h3>".format(self.tr("Python packages")),
self.generate_attributions(attributions_python),
"<h3>{0}</h3>".format(self.tr("Graphics")),
self.generate_attributions(attributions_gui),
"<h3>{0}</h3>".format(self.tr("Translations")),
self.generate_attributions_translations(attributions_translation),
]

self.attributionsBox.setText("\n".join(attributions_txt))

def generate_attributions(self, attributions):
def generate_attributions(self, attributions: List[Attribution]):
attributions_txt = []
for a in attributions:
app_title = "{0} {1}".format(a.title, a.version or "").strip()
Expand All @@ -160,3 +176,19 @@ def generate_attributions(self, attributions):
attributions_txt.append(attribution_txt)

return "\n".join(attributions_txt)

def generate_attributions_translations(
self, attributions: List[AttributionTranslation]
):
attributions_txt = []
for a in attributions:
author_url = f'<a href="{a.author_url}">{a.author}</a>'

attribution_txt = self.tr("<p><b>{LANGUAGE}</b> by {AUTHOR_URL}</p>")

attribution_txt = attribution_txt.replace("{LANGUAGE}", a.language)
attribution_txt = attribution_txt.replace("{AUTHOR_URL}", author_url)

attributions_txt.append(attribution_txt)

return "\n".join(attributions_txt)
1 change: 1 addition & 0 deletions gridplayer/params_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class WindowState(NamedTuple):

SUPPORTED_LANGUAGES = (
"en_US",
"hu_HU",
"ru_RU",
)

Expand Down
180,641 changes: 90,788 additions & 89,853 deletions gridplayer/resources_bin.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resources/resources.csv
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ icon-symbolic,icons/custom/037-loop dir.svg,loop-dir
icon-symbolic,icons/custom/038-loop dir shuffle.svg,loop-dir-shuffle
icon-symbolic,icons/custom/039-information.svg,information
translation,translations/ru_RU.ts,ru_RU
translation,translations/hu_HU.ts,hu_HU
Loading

0 comments on commit 5cd6892

Please sign in to comment.