Initalize repo

This commit is contained in:
BaerbelBox
2022-03-31 15:21:47 +02:00
parent 557f3e9b31
commit 7cf65ef092
98 changed files with 15860 additions and 0 deletions

23
FaustBot/Model/i18n.py Normal file
View File

@@ -0,0 +1,23 @@
import sqlite3
class i18n(object):
def get_text(self, name, replacements=None, lang='de-DE'):
"""
:param replacements:
:param name: name of text
:param lang: language to get text in
:return: the text
"""
if replacements is None:
replacements = {}
database_connection = sqlite3.connect('faust_bot.db')
cursor = database_connection.cursor()
ltext = ""
print(replacements)
for longText in cursor.execute("SELECT longText FROM i18n WHERE lang = ? AND ident = ?", (lang, name,)):
ltext = longText[0]
for (key, value) in replacements.items():
ltext = ltext.replace('$' + key, value)
return ltext