mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
401e1842ee
Our locale directories are named things like 'en-US'. But the pluralization code used by Laravel (through Symfony) requires locale names to be in the format en_US. This change introduces a new Translator, SnipeTranslator, which is a tiny set of changes against the built-in one. It additionally adds a SnipeTranslationServiceProvider, which loads up the new Translator.
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Services\SnipeTranslator;
|
|
use Illuminate\Translation\TranslationServiceProvider;
|
|
|
|
class SnipeTranslationServiceProvider extends TranslationServiceProvider
|
|
{
|
|
/**
|
|
* Register services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
//This is almost an *EXACT* carbon-copy of the TranslationServiceProvider, except with a modified Translator
|
|
$this->registerLoader();
|
|
|
|
$this->app->singleton('translator', function ($app) {
|
|
$loader = $app['translation.loader'];
|
|
|
|
// When registering the translator component, we'll need to set the default
|
|
// locale as well as the fallback locale. So, we'll grab the application
|
|
// configuration so we can easily get both of these values from there.
|
|
$locale = $app['config']['app.locale'];
|
|
|
|
$trans = new SnipeTranslator($loader, $locale); //the ONLY changed line
|
|
|
|
$trans->setFallback($app['config']['app.fallback_locale']);
|
|
|
|
return $trans;
|
|
});
|
|
}
|
|
}
|