如何扩展laravel Illuminate \ Translation \ Translator类

I want to extend this class Illuminate\Translation\Translator which extends \Illuminate\Support\NamespacedItemResolver

<?php

namespace Illuminate\Translation;

use Countable;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Support\NamespacedItemResolver;
use Illuminate\Contracts\Translation\Translator as TranslatorContract;

class Translator extends NamespacedItemResolver implements TranslatorContract
{
    use Macroable;
}

I extended \Illuminate\Support\NamespacedItemResolver into my own class

but when I call Translator its still taking the base class's functions. which is \Illuminate\Support\NamespacedItemResolver.

<?php

namespace App\Repositories;

class NamespaceParser extends \Illuminate\Support\NamespacedItemResolver
{
}

UPDATE

created a new Translator class and tried to extend it in the AppServiceProvider and the below WORKED

public function register()
   {
         $loader = $this->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 = $this->app['config']['app.locale'];

       $this->app->extend('translator', function () {
             new \App\Repositories\Translator($loader, $locale);
       });
   }

What you try to achieve is kind of advanced and is described here:

https://laravel.com/docs/5.7/container#extending-bindings

An example of a package that does this very thing can be found here:

https://github.com/onlinepets/laravel-conditional-migrations/blob/master/src/ServiceProvider.php

You have to tell Laravel to use your custom class from now on, instead of the default one.

Summary

You have to tell the Laravel Service Container to use another class than normal. You do this by calling $this->app->extend in the register function of a Service Provider.