AbehoM's avatar

Translate big text in Laravel

I have a TOS (terms of use) that I need to translate in two languages, how can I translate a text this big in Laravel? I'm using both language folders for en and pt-BR and also the pt-BR.json for strings as key for things like: "Verify Your Email Address", but now I got to a point where I need to translate a big TOS with several paragraphs, how can I do that?

0 likes
5 replies
Cronix's avatar

You'd really be best off hiring a native speaker to do it if you care about accuracy, especially when it matters like something legal.

AbehoM's avatar

@cronix it's not the case here, I have that written already, I want to know how to display that using the translation feature of Laravel

Snapey's avatar
Snapey
Best Answer
Level 122

Just insert two different views with a blade @if tag wrapping an @include


@if($lang == 'BR')
    @include('_terms_br')
@else
    @include('_terms_en')
@endif

1 like
AbehoM's avatar

@snapey Thank you, I think I will using a library called mcamara/laravel-localization and create a view for each term

rockBalancer's avatar

i know its older but I figured i'd post my idea (it's a bit more dynamic). something along the lines of:

@if(session()->has('lang'))
    @if(view()->exists('locale.includes.'.session()->get('lang').'.terms-of-use'))
	    @include('locale.includes.'.session()->get('lang').'.terms-of-use')
    @else
	    @include('locale.includes.'.config('app.fallback_locale').'.terms-of-use')
    @endif
@else
	@include('locale.includes.'.config('app.fallback_locale').'.terms-of-use')
@endif

and then you just build the availability in your files directory. no need to touch the code again.

Please or to participate in this conversation.