29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Package Development 301<br />

Translations<br />

If your package contains translation files, you may use the loadTranslationsFrom method to inform<br />

Laravel how to load them. For example, if your package is named “courier”, you should add the<br />

following to your service provider’s boot method:<br />

.<br />

1 /**<br />

2 * Perform post-registration booting of services.<br />

3 *<br />

4 * @return void<br />

5 */<br />

6 public function boot()<br />

7 {<br />

8 $this->loadTranslationsFrom(__DIR__.'/path/to/translations', 'courier');<br />

9 }<br />

Package translations are referenced using a double-colon package::file.line syntax. So, you may<br />

load the courier package’s welcome line from the messages file like so:<br />

.<br />

1 echo trans('courier::messages.welcome');<br />

Configuration<br />

Typically, you will want to publish your package’s configuration file to the application’s own config<br />

directory. This will allow users of your package to easily override your default configuration options.<br />

To publish a configuration file, just use the publishes method from the boot method of your service<br />

provider:<br />

.<br />

1 /**<br />

2 * Perform post-registration booting of services.<br />

3 *<br />

4 * @return void<br />

5 */<br />

6 public function boot()<br />

7 {<br />

8 $this->publishes([<br />

9 __DIR__.'/path/to/config/courier.php' => config_path('courier.php'),<br />

10 ]);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!