add utility fucntions to query texts from locales

This commit is contained in:
Thomas Rubini 2023-03-25 20:16:48 +01:00
parent e64bd422c6
commit 55018c90bb
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373

View File

@ -50,6 +50,27 @@ class Locale(Base):
def __repr__(self) -> str:
return self.__str__()
def get_texts(self, lang):
texts = []
for text in self.TEXTS:
if text.LANG == lang:
texts.append(text)
return texts
def get_text(self, lang, auto_create):
for text in self.TEXTS:
if text.LANG == lang:
return text
if auto_create:
text = Text(None, None, lang, None)
self.TEXTS.append(text)
return text
else:
return None
class Place(Base):
"""