Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pass param dynamic when Retrieving Translation Strings

I’m doing a upload many file and trying pass param to get message within for loop, how I can send param index to blade {{__()}}

I try do below, input work but label doesn’t work: {{__(‘cha_content.attach1_{{$i}}]’)}}

in blade file:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

@for ($i = 1; $i <= 11; $i++)
    <div class="form-group row">
        <label class="col-sm-3 col-form-label font-weight-bold text-right">{{__('cha_content.attach1_{{$i}}]')}}</label>
        <div class="col-sm-6">
            <input class="form-control" type="file" id="attach1_{{ $i }}" name="attach1_{{ $i }}">
        </div>
    </div>
@endfor

in lang file:

<?php
return [
    'attach1_1'=>'1. Plan report',
    'attach1_2'=>'2. Cancelation report',
    'attach1_3'=>'3. Daily report',
    'attach1_4'=>'4. Process report',
    'attach1_5'=>'5. Site Specific',
    'attach1_6'=>'6. Visitor Log',
    'attach1_7'=>'7. Deployment plan',
    'attach1_8'=>'8. ...',
    'attach1_9'=>'9. ...',
    'attach1_10'=>'10. ...',
    'attach1_11'=>'11. ...',
    ...

my result:
(https://i.stack.imgur.com/Uestc.png)

>Solution :

Takes a string value inside the __($param) expression. It will be enough to specify that string value.

With this way:

{{__('cha_content.attach1_' . $i)}}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading