|
|
@@ -0,0 +1,37 @@
|
|
|
+class translation:
|
|
|
+ def __init__(self, content: str, success: bool = True) -> None:
|
|
|
+ self.__success = success
|
|
|
+ self.__content = content
|
|
|
+
|
|
|
+ def __str__(self) -> str:
|
|
|
+ return self.__content
|
|
|
+
|
|
|
+ @property
|
|
|
+ def text(self) -> str:
|
|
|
+ return self.__content
|
|
|
+
|
|
|
+ @property
|
|
|
+ def valid(self) -> bool:
|
|
|
+ return self.__success
|
|
|
+
|
|
|
+ def format(self, params: dict) -> str:
|
|
|
+ parts = self.__content.split("#{")
|
|
|
+ results = parts.pop(0)
|
|
|
+
|
|
|
+ for count in parts:
|
|
|
+ elements = count.split("}")
|
|
|
+
|
|
|
+ if len(elements) == 1:
|
|
|
+ results.append(count)
|
|
|
+ continue
|
|
|
+
|
|
|
+ name = elements.pop(0).strip()
|
|
|
+ rest = str("}").join(elements)
|
|
|
+
|
|
|
+ if not name in params:
|
|
|
+ results = results + rest
|
|
|
+ continue
|
|
|
+
|
|
|
+ results = results + str(params[name]) + rest
|
|
|
+
|
|
|
+ return results
|