1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-25 23:24:19 +00:00

Add language switcher

This commit is contained in:
Darren 2020-02-04 15:13:14 +02:00
parent 2d8c36fdca
commit 49cc2b8036
6 changed files with 17 additions and 6 deletions

View file

@ -8,6 +8,8 @@
version = 13 version = 13
; Set this to no when you are done editing the file ; Set this to no when you are done editing the file
is_template = yes is_template = yes
; Language code for string file
language = it_IT
# Telegram bot parameters # Telegram bot parameters
[Telegram] [Telegram]

View file

@ -1,11 +1,13 @@
import sys import sys
import telegram import telegram
import strings
import worker import worker
import configloader import configloader
import utils import utils
import threading import threading
import importlib
language = configloader.config["Config"]["language"]
strings = importlib.import_module("strings." + language)
def main(): def main():
"""The core code of the program. Should be run only in the main process!""" """The core code of the program. Should be run only in the main process!"""

View file

@ -5,9 +5,12 @@ from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
import configloader import configloader
import telegram import telegram
import strings
import requests import requests
import utils import utils
import importlib
language = configloader.config["Config"]["language"]
strings = importlib.import_module("strings." + language)
# Create a (lazy) database engine # Create a (lazy) database engine
engine = create_engine(configloader.config["Database"]["engine"]) engine = create_engine(configloader.config["Database"]["engine"])

View file

@ -2,11 +2,13 @@ import telegram
import telegram.error import telegram.error
import time import time
from configloader import config from configloader import config
from strings import currency_format_string, currency_symbol
import typing import typing
import os import os
import sys import sys
import strings import importlib
language = config["Config"]["language"]
strings = importlib.import_module("strings." + language)
if config["Error Reporting"]["sentry_token"] != \ if config["Error Reporting"]["sentry_token"] != \
"https://00000000000000000000000000000000:00000000000000000000000000000000@sentry.io/0000000": "https://00000000000000000000000000000000:00000000000000000000000000000000@sentry.io/0000000":
@ -40,7 +42,7 @@ class Price:
return f"<Price of value {self.value}>" return f"<Price of value {self.value}>"
def __str__(self): def __str__(self):
return currency_format_string.format(symbol=currency_symbol, return strings.currency_format_string.format(symbol=strings.currency_symbol,
value="{0:.2f}".format( value="{0:.2f}".format(
self.value / (10 ** int(config["Payments"]["currency_exp"])))) self.value / (10 ** int(config["Payments"]["currency_exp"]))))

View file

@ -3,7 +3,6 @@ import typing
import uuid import uuid
import datetime import datetime
import telegram import telegram
import strings
import configloader import configloader
import sys import sys
import queue as queuem import queue as queuem
@ -13,7 +12,10 @@ import utils
import os import os
from html import escape from html import escape
import requests import requests
import importlib
language = configloader.config["Config"]["language"]
strings = importlib.import_module("strings." + language)
class StopSignal: class StopSignal:
"""A data class that should be sent to the worker when the conversation has to be stopped abnormally.""" """A data class that should be sent to the worker when the conversation has to be stopped abnormally."""