title: How to override JSON translations for a Laravel package?
body: <p>I've built <a href="https://github.com/alariva/laravel-email-domain-blacklist" rel="nofollow noreferrer">a validation package</a> for Laravel >= 5.4 and it uses JSON translation files for the <em>validation message</em>.</p>
  
  <p>I want to let the application to override that message translations.</p>
  
  <p><a href="https://laravel.com/docs/5.6/localization#overriding-package-language-files" rel="nofollow noreferrer">Laravel provides <em>namespacing</em></a> for <code>trans()</code>. However, It looks like only the regular <code>.php</code> translations allow namespacing.</p>
  
  <p>I haven't been able to achieve this with JSON translations.</p>
  
  <p>Currently, <a href="https://github.com/alariva/laravel-email-domain-blacklist/blob/master/src/Alariva/EmailDomainBlacklist/Validator.php#L68" rel="nofollow noreferrer">this is how I'm returning the validation message</a>:</p>
  
  <pre><code>public function message($message, $attribute, $rule, $parameters)
  {
      return __('The domain for :attribute is not allowed. Please use another email address.', ['attribute' =&gt; $attribute]);
  }
  </code></pre>
  
  <p>This is how I'm <a href="https://github.com/alariva/laravel-email-domain-blacklist/blob/master/src/Alariva/EmailDomainBlacklist/EmailDomainBlacklistServiceProvider.php#L18" rel="nofollow noreferrer">loading the translation files in Service Provider</a>:</p>
  
  <pre><code>public function boot()
  {
      $this-&gt;loadJSONTranslationsFrom(__DIR__.'/../../../lang', 'email-domain-blacklist');
      $this-&gt;publishes([
          __DIR__.'/../../../lang' =&gt; resource_path('lang/vendor/email-domain-blacklist'),
      ]);
      $this-&gt;publishConfig();
      // Add custom validation rules
      Validator::extend('blacklist', "Alariva\EmailDomainBlacklist\Validator@validate");
      // Add custom validation messages
      Validator::replacer('blacklist', "Alariva\EmailDomainBlacklist\Validator@message");
  }
  </code></pre>
  
  <p>If I publish the translation files and alter them under <code>resources/lang/vendor/email-domain-blacklist/*.json</code> I will see no changes, since the package will load the translation from the package directory inside <code>vendor/</code>.</p>
  
  <p>If I loaded the translations from the app level, I would require the application to always publish the translation files in order to correctly load them. I want to avoid this extra step.</p>
  
  <p>Which would be an elegant way to go around this?</p>
  
  <hr>
  
  <p>I will edit accordingly to provide as much clear info as possible.</p>
  
  <p>Thanks in advance.</p>