mirror of
https://github.com/nichkara/InfinitumBotty.git
synced 2026-06-11 06:36:24 +02:00
Initalize repo
This commit is contained in:
23
FaustBot/Model/i18n.py
Normal file
23
FaustBot/Model/i18n.py
Normal 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
|
||||
Reference in New Issue
Block a user