Added logic to load translations and to translate texts

This commit is contained in:
2022-06-29 20:03:13 +02:00
parent 39b6ca790c
commit e4f843829f
22 changed files with 204 additions and 30 deletions

View File

@@ -0,0 +1,16 @@
from cpl_core.console import Console
from cpl_core.pipes.pipe_abc import PipeABC
from cpl_translation.translation_service_abc import TranslationServiceABC
class TranslatePipe(PipeABC):
def __init__(self, translation: TranslationServiceABC):
self._translation = translation
def transform(self, value: any, *args):
try:
return self._translation.translate(value)
except KeyError as e:
Console.error(f'Translation {value} not found')
return ''