Modularization
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 7s
Build on push / prepare (push) Successful in 10s
Build on push / core (push) Successful in 18s
Build on push / query (push) Successful in 17s
Build on push / dependency (push) Successful in 17s
Build on push / application (push) Successful in 16s
Build on push / mail (push) Successful in 15s
Build on push / database (push) Successful in 15s
Build on push / translation (push) Successful in 18s
Build on push / auth (push) Successful in 23s
Build on push / api (push) Successful in 16s
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 7s
Build on push / prepare (push) Successful in 10s
Build on push / core (push) Successful in 18s
Build on push / query (push) Successful in 17s
Build on push / dependency (push) Successful in 17s
Build on push / application (push) Successful in 16s
Build on push / mail (push) Successful in 15s
Build on push / database (push) Successful in 15s
Build on push / translation (push) Successful in 18s
Build on push / auth (push) Successful in 23s
Build on push / api (push) Successful in 16s
This commit is contained in:
0
example/translation/src/__init__.py
Normal file
0
example/translation/src/__init__.py
Normal file
27
example/translation/src/application.py
Normal file
27
example/translation/src/application.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.core.console import Console
|
||||
from cpl.dependency import ServiceProvider
|
||||
from cpl.translation.translate_pipe import TranslatePipe
|
||||
from cpl.translation.translation_service_abc import TranslationServiceABC
|
||||
from cpl.translation.translation_settings import TranslationSettings
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProvider):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
self._translate: TranslatePipe = services.get_service(TranslatePipe)
|
||||
self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC)
|
||||
self._translation_settings: TranslationSettings = config.get_configuration(TranslationSettings)
|
||||
|
||||
self._translation.load_by_settings(config.get_configuration(TranslationSettings))
|
||||
self._translation.set_default_lang("de")
|
||||
|
||||
def configure(self): ...
|
||||
|
||||
def main(self):
|
||||
Console.write_line(self._translate.transform("main.text.hello_world"))
|
||||
self._translation.set_lang("en")
|
||||
Console.write_line(self._translate.transform("main.text.hello_world"))
|
||||
Console.write_line(self._translate.transform("main.text.hello"))
|
||||
23
example/translation/src/appsettings.json
Normal file
23
example/translation/src/appsettings.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"Logging": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "ERROR",
|
||||
"Level": "WARN"
|
||||
},
|
||||
|
||||
"Translation": {
|
||||
"Languages":[
|
||||
"de",
|
||||
"en"
|
||||
],
|
||||
"DefaultLanguage": "en"
|
||||
}
|
||||
}
|
||||
14
example/translation/src/main.py
Normal file
14
example/translation/src/main.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from translation.application import Application
|
||||
from translation.startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.with_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
17
example/translation/src/startup.py
Normal file
17
example/translation/src/startup.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from cpl.application import StartupABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.dependency import ServiceProvider, ServiceCollection
|
||||
from cpl.core.environment import Environment
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: Environment) -> ConfigurationABC:
|
||||
configuration.add_json_file("appsettings.json")
|
||||
return configuration
|
||||
|
||||
def configure_services(self, services: ServiceCollection, environment: Environment) -> ServiceProvider:
|
||||
services.add_translation()
|
||||
return services.build()
|
||||
44
example/translation/src/translation.json
Normal file
44
example/translation/src/translation.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"Project": {
|
||||
"Name": "translation",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"URL": "",
|
||||
"CopyrightDate": "",
|
||||
"CopyrightName": "",
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=2022.6.0"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli>=2022.6.0"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {},
|
||||
"Classifiers": []
|
||||
},
|
||||
"Build": {
|
||||
"ProjectType": "console",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "translation.main",
|
||||
"EntryPoint": "translation",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
||||
7
example/translation/src/translation/de.json
Normal file
7
example/translation/src/translation/de.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": {
|
||||
"text": {
|
||||
"hello_world": "Hallo Welt"
|
||||
}
|
||||
}
|
||||
}
|
||||
7
example/translation/src/translation/en.json
Normal file
7
example/translation/src/translation/en.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": {
|
||||
"text": {
|
||||
"hello_world": "Hello World"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user