lean/meta/definitions/language.php

38 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2024-06-07 00:01:43 +00:00
use Tell\I18n;
use Psr\Container\ContainerInterface;
use Notes\Tell\LanguageHandler;
2024-06-07 00:01:43 +00:00
use function DI\autowire, DI\create, DI\get, DI\add;
return [
2024-06-07 00:01:43 +00:00
I18n::class => function(ContainerInterface $container) {
$i18n = new I18n($container->get(Tell\Reader\JsonReader::class), $container->get(Tell\Reader\PhpReader::class), $container->get('tell.fallback'));
$i18n->locale(getenv('DEFAULT_LOCAL'));
$i18n->initialize(! getenv("DEBUG"));
return $i18n;
},
'tell.fallback' => function(ContainerInterface $container) {
$i18n = new Tell\I18n( $container->get(Tell\Reader\JsonReader::class), $container->get(Tell\Reader\PhpReader::class), new Tell\PrintMissingKey() );
$i18n->locale(getenv('DEFAULT_LOCAL_FALLBACK') ?: "en_US");
$i18n->initialize(true);
return $i18n;
},
2024-06-07 00:01:43 +00:00
Tell\Reader\PhpReader::class => function(ContainerInterface $container) {
return new Tell\Reader\PhpReader($container->get(Lean\Lean::class)->getI18n('php'), false);
},
2024-06-07 00:01:43 +00:00
Tell\Reader\JsonReader::class => function(ContainerInterface $container) {
return new Tell\Reader\JsonReader($container->get(Lean\Lean::class)->getI18n('json'), true, \JSON_PRETTY_PRINT);
},
2024-06-07 00:01:43 +00:00
'lean.autoload' => add([
I18n::class,
]),
];