Skip to content

Commit

Permalink
Changing i18n to gettext (#100)
Browse files Browse the repository at this point in the history
* Changing i18n to gettext
  • Loading branch information
Katzmann1983 authored Jul 17, 2024
1 parent 2993a62 commit adf7671
Show file tree
Hide file tree
Showing 23 changed files with 2,293 additions and 441 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include pytr/locale *.mo *.po
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[build-system]
requires = ["setuptools>=42", "wheel", "babel"]
build-backend = "setuptools.build_meta"

[project]
name = "pytr"
version = "0.2.2"
description = "Use TradeRepublic in terminal"
readme = "README.md"
requires-python = ">=3.8"
license = { text = "MIT" }
authors = [
{ name = "marzzzello", email = "[email protected]" }
]
urls = { "Homepage" = "https://gitlab.com/pytr-org/pytr/" }
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only",
"Operating System :: OS Independent",
"Development Status :: 3 - Alpha",
"Topic :: Office/Business :: Financial",
"Topic :: Office/Business :: Financial :: Investment",
]
dependencies = [
"certifi",
"coloredlogs",
"ecdsa",
"packaging",
"pathvalidate",
"pygments",
"requests_futures",
"shtab",
"websockets>=10.1",
"babel",
]

[project.scripts]
pytr = "pytr.main:main"

[tool.setuptools]
include-package-data = true
packages = ["pytr"]

[tool.setuptools.package-data]
pytr = ["pytr/locale/*/*/*.mo", "pytr/locale/*/*/*.po"]
4 changes: 2 additions & 2 deletions pytr/dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from pathvalidate import sanitize_filepath

from pytr.utils import preview, Timeline, get_logger
from pytr.utils import preview, get_logger
from pytr.api import TradeRepublicError

from pytr.timeline import Timeline

class DL:
def __init__(
Expand Down
88 changes: 88 additions & 0 deletions pytr/event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from datetime import datetime


tr_eventType_to_pp_type = {
"CREDIT": "DIVIDENDS",
"ssp_corporate_action_invoice_cash": "DIVIDENDS",
"TRADE_INVOICE": "TRADE_INVOICE",
"SAVINGS_PLAN_EXECUTED": "TRADE_INVOICE",
"ORDER_EXECUTED": "TRADE_INVOICE",
"PAYMENT_INBOUND": "DEPOSIT",
"PAYMENT_INBOUND_SEPA_DIRECT_DEBIT": "DEPOSIT",
"PAYMENT_OUTBOUND": "REMOVAL",
"INTEREST_PAYOUT_CREATED": "INTEREST",
"card_successful_transaction": "REMOVAL",
"card_successful_atm_withdrawal": "REMOVAL",
"card_order_billed": "REMOVAL",
"card_refund": "DEPOSIT",
}


class Event:
def __init__(self, event_json):
self.event = event_json
self.shares = ""
self.isin = ""

self.pp_type = tr_eventType_to_pp_type.get(self.event["eventType"], "")
self.body = self.event.get("body", "")
self.process_event()

@property
def date(self):
dateTime = datetime.fromisoformat(self.event["timestamp"][:19])
return dateTime.strftime("%Y-%m-%d")

@property
def is_pp_relevant(self):
return self.pp_type != ""

@property
def amount(self):
return str(self.event["amount"]["value"])

@property
def note(self):
if self.event["eventType"].find("card_") == 0:
return self.event["eventType"]
else:
return ""

@property
def title(self):
return self.event["title"]

def determine_pp_type(self):
if self.pp_type == "TRADE_INVOICE":
if self.event["amount"]["value"] < 0:
self.pp_type = "BUY"
else:
self.pp_type = "SELL"

def determine_shares(self):
if self.pp_type == "TRADE_INVOICE":
sections = self.event.get("details", {}).get("sections", [{}])
for section in sections:
if section.get("title") == "Transaktion":
self.shares = section.get("data", [{}])[0]["detail"][
"text"
].replace(",", ".")

def determine_isin(self):
if self.pp_type in ("DIVIDENDS", "TRADE_INVOICE"):
sections = self.event.get("details", {}).get("sections", [{}])
self.isin = self.event.get("icon", "")
self.isin = self.isin[self.isin.find("/") + 1 :]
self.isin = self.isin[: self.isin.find("/")]
isin2 = self.isin
for section in sections:
action = section.get("action", None)
if action and action.get("type", {}) == "instrumentDetail":
isin2 = section.get("action", {}).get("payload")
if self.isin != isin2:
self.isin = isin2

def process_event(self):
self.determine_shares()
self.determine_isin()
self.determine_pp_type()
143 changes: 143 additions & 0 deletions pytr/locale/cs/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Language: cs\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "BUY"
msgstr "Koupit"

msgid "DEPOSIT"
msgstr "Vklad"

msgid "DIVIDENDS"
msgstr "Dividendy"

msgid "FEES"
msgstr "Poplatky"

msgid "FEES_REFUND"
msgstr "Vratka poplatku"

msgid "INTEREST"
msgstr "Úrok"

msgid "INTEREST_CHARGE"
msgstr "Úrokový poplatek"

msgid "REMOVAL"
msgstr "Výběr"

msgid "SELL"
msgstr "Prodat"

msgid "TAXES"
msgstr "Daně"

msgid "TAX_REFUND"
msgstr "Daňová vratka"

msgid "TRANSFER_IN"
msgstr "Převod (příchozí)"

msgid "TRANSFER_OUT"
msgstr "Převod (odchozí)"

msgid "CSVColumn_AccountName"
msgstr "Peněžní účet"

msgid "CSVColumn_AccountName2nd"
msgstr "Vyrovnávací účet"

msgid "CSVColumn_CumulatedPerformanceInPercent"
msgstr "Kumulovaná výkonnost v %"

msgid "CSVColumn_Currency"
msgstr "Měna"

msgid "CSVColumn_CurrencyGrossAmount"
msgstr "Měna v hrubé výši"

msgid "CSVColumn_Date"
msgstr "Datum"

msgid "CSVColumn_DateQuote"
msgstr "Datum kurzu"

msgid "CSVColumn_DateValue"
msgstr "Datum vypořádání"

msgid "CSVColumn_DeltaInPercent"
msgstr "Delta v %"

msgid "CSVColumn_ExchangeRate"
msgstr "Směnný kurz"

msgid "CSVColumn_Fees"
msgstr "Poplatky"

msgid "CSVColumn_GrossAmount"
msgstr "Hrubá výše"

msgid "CSVColumn_ISIN"
msgstr "ISIN"

msgid "CSVColumn_InboundTransferals"
msgstr "Příchozí převod"

msgid "CSVColumn_Name"
msgstr "Jméno"

msgid "CSVColumn_Note"
msgstr "Poznámka"

msgid "CSVColumn_OutboundTransferals"
msgstr "Odchozí převod"

msgid "CSVColumn_PortfolioName"
msgstr "Účet cenných papírů"

msgid "CSVColumn_PortfolioName2nd"
msgstr "vyrovnávací účet cenných papírů"

msgid "CSVColumn_Quote"
msgstr "Kurz"

msgid "CSVColumn_SecurityName"
msgstr "Jméno cenného papíru"

msgid "CSVColumn_Shares"
msgstr "Akcie"

msgid "CSVColumn_Taxes"
msgstr "Daně"

msgid "CSVColumn_TickerSymbol"
msgstr "Označení tickeru"

msgid "CSVColumn_Time"
msgstr "Čas"

msgid "CSVColumn_TransactionCurrency"
msgstr "Transakční měna"

msgid "CSVColumn_Type"
msgstr "Typ"

msgid "CSVColumn_Value"
msgstr "Hodnota"

msgid "CSVColumn_WKN"
msgstr "WKN"

msgid "card_successful_transaction"
msgstr "Platba kartou"

msgid "card_successful_atm_withdrawal"
msgstr "Výběr hotovosti"

msgid "card_order_billed"
msgstr "Poplatek za kartu"

msgid "card_refund"
msgstr "Vrácení peněz na kartu"
Loading

0 comments on commit adf7671

Please sign in to comment.