sh_cpl/src/cpl_translation/__init__.py

57 lines
1.4 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""
2023-02-20 15:55:20 +01:00
cpl-translation CPL Translation
~~~~~~~~~~~~~~~~~~~
2023-02-20 15:55:20 +01:00
CPL translation extension
2022-12-25 12:04:25 +01:00
:copyright: (c) 2022 - 2023 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
2023-02-20 15:55:20 +01:00
__title__ = "cpl_translation"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "2023.2.0"
from collections import namedtuple
2022-07-10 18:08:44 +02:00
# imports:
2022-07-10 17:56:38 +02:00
from .translate_pipe import TranslatePipe
from .translation_service import TranslationService
from .translation_service_abc import TranslationServiceABC
from .translation_settings import TranslationSettings
2023-02-20 15:55:20 +01:00
# build-ignore
def add_translation(self):
from cpl_core.console import Console
from cpl_core.pipes import PipeABC
from cpl_translation.translate_pipe import TranslatePipe
from cpl_translation.translation_service import TranslationService
from cpl_translation.translation_service_abc import TranslationServiceABC
try:
self.add_singleton(TranslationServiceABC, TranslationService)
self.add_transient(PipeABC, TranslatePipe)
except ImportError as e:
2023-02-20 15:55:20 +01:00
Console.error("cpl-translation is not installed", str(e))
def init():
from cpl_core.dependency_injection import ServiceCollection
2023-02-20 15:55:20 +01:00
ServiceCollection.add_translation = add_translation
init()
# build-ignore-end
2023-02-20 15:55:20 +01:00
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="2023", minor="2", micro="0")