laravel-localization

How can I use HTML tags in a Laravel localization file?

≯℡__Kan透↙ 提交于 2019-12-18 13:52:32
问题 I'm trying to utilize Laravel's localization feature, but I need to be able to put emphasis or bolden a portion of a phrase. Inserting a HTML tag into the language file causes it to be escaped when outputted to a blade. For example, here is my language file entry: return [ 'nav' => [ 'find' => '<strong>Find</strong> Your Home', ] ]; When I call it from within a blade: (I've tried using triple braces as well.) {{ trans('base.nav.find') }} It outputs: <strong>Find</strong> Your Home I could

Laravel get getCurrentLocale() in AppServiceProvider

故事扮演 提交于 2019-12-11 23:27:33
问题 I'm trying to get the LaravelLocalization::getCurrentLocale() in the boot() method of the Laravel AppServiceProvider class, and although my default locale is pt I always get the en . The package I'm using is mcamara/laravel-localization . Code I have: public function boot() { Schema::defaultStringLength(191); // Twitter view share $twitter = Twitter::getUserTimeline(['screen_name' => env('TWITTER_USER'), 'count' => 3, 'format' => 'object']); view()->share('twitter', $twitter); // Current

Laravel 5 | Interface 'Illuminate\Contracts\Routing\Middleware' not found

我怕爱的太早我们不能终老 提交于 2019-12-10 22:38:32
问题 I use Laravel 5. I try, "use Illuminate\Contracts\Routing\Middleware;" to implement "Middleware" as, class Language implements Middleware { // Some Functions } I Get Error as, Interface 'Illuminate\Contracts\Routing\Middleware' not found Is actually that interface is Missing ? (OR) Mistake in defining ? (OR) Need to Create | Download ? Thank Q ! 回答1: The Illuminate\Contracts\Routing\Middleware contract has been deprecated in 5.2, remove it. And dont use it in class definition. Like this <?php

How to do unit testing with Laravel Localization?

会有一股神秘感。 提交于 2019-12-10 15:53:27
问题 I'm using mcamara/laravel-localization package and I can't figure out how to make it work with my unit tests. Both of the following fail with red: // 1. This one results in "Redirecting to http://myapp.dev/en" $this->get('/')->assertSee('My App Homepage'); // 2. This one results in 404 $this->get('/en')->assertSee('My App Homepage'); In the browser, http://myapp.dev returns 302 with a redirect to http://myapp.dev/en , fair enough. However, http://myapp.dev/en returns 200. So both cases work

Which are good strategies for organizing localization files for trans() in Laravel 5.x?

旧时模样 提交于 2019-12-09 19:10:16
问题 This is a question about methodology and suggested practices. I know it is not strictly attached to the framework and not even PHP, and the answer might be "its up to you". But my concern is about best practices and methodology, as there usually exists a best approach for a certain context. I would like to know which are the best practices for key naming for the trans() function of Laravel 5.1 ? Considering that built-in Laravel translations are stored into an array, my concern is which

Which are good strategies for organizing localization files for trans() in Laravel 5.x?

為{幸葍}努か 提交于 2019-12-04 12:35:40
This is a question about methodology and suggested practices. I know it is not strictly attached to the framework and not even PHP, and the answer might be "its up to you". But my concern is about best practices and methodology, as there usually exists a best approach for a certain context. I would like to know which are the best practices for key naming for the trans() function of Laravel 5.1 ? Considering that built-in Laravel translations are stored into an array, my concern is which hirearchy allows me to achieve the following goals: consistency : So I minimize the possibility of using

How can I use HTML tags in a Laravel localization file?

寵の児 提交于 2019-11-30 10:43:40
I'm trying to utilize Laravel's localization feature, but I need to be able to put emphasis or bolden a portion of a phrase. Inserting a HTML tag into the language file causes it to be escaped when outputted to a blade. For example, here is my language file entry: return [ 'nav' => [ 'find' => '<strong>Find</strong> Your Home', ] ]; When I call it from within a blade: (I've tried using triple braces as well.) {{ trans('base.nav.find') }} It outputs: <strong>Find</strong> Your Home I could potentially split the phrasing up like: return [ 'nav' => [ 'fyh' => [ 'find' => 'Find', 'yh' => 'Your