<?php

namespace Openguru\OpenCartFramework\Translator;

use Openguru\OpenCartFramework\Container\Container;
use Openguru\OpenCartFramework\Container\ServiceProvider;

class TranslatorServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->container->singleton(TranslatorInterface::class, function (Container $container) {
            $language = $container->getConfigValue('lang', 1);
            $translator = new Translator($language);
            $translator->loadTranslationsFromFolder(resources_path('/translations'));
            return $translator;
        });
    }
}
