CodeIgniter Forums
An input field translated in to many languages in the same form view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: An input field translated in to many languages in the same form view (/showthread.php?tid=79020)



An input field translated in to many languages in the same form view - sdiri - 04-09-2021

Hello,

I want to provide a translation of three labels but I can't find how to do it in the same form:



Code:
<form>
     <h2><?= lang('forms.SERVICE_FORM_TITLE'); ?></h2> <--- no problem with the default translation based on the app lang

    <label><?= lang('forms.en.SERVICE') ?> <span class="text-danger">*</span></label>
    <input name="serv_en" class="form-control" value="" type="text">

    <label><?= lang('forms.fr.SERVICE') ?> <span class="text-danger">*</span></label>
    <input name="serv_fr" class="form-control" value="" type="text">

    <label><?= lang('forms.es.SERVICE') ?> <span class="text-danger">*</span></label>
    <input name="serv_es" class="form-control" value="" type="text">
</form>

Thank you


RE: An input field translated in to many languages in the same form view - sdiri - 04-09-2021

(04-09-2021, 10:22 AM)sdiri Wrote: Hello,

I want to provide a translation of three labels but I can't find how to do it in the same form:



Code:
<form>
     <h2><?= lang('forms.SERVICE_FORM_TITLE'); ?></h2> <--- no problem with the default translation based on the app lang

    <label><?= lang('forms.en.SERVICE') ?> <span class="text-danger">*</span></label>
    <input name="serv_en" class="form-control" value="" type="text">

    <label><?= lang('forms.fr.SERVICE') ?> <span class="text-danger">*</span></label>
    <input name="serv_fr" class="form-control" value="" type="text">

    <label><?= lang('forms.es.SERVICE') ?> <span class="text-danger">*</span></label>
    <input name="serv_es" class="form-control" value="" type="text">
</form>

Thank you


After serveral attempts i finalu got it:

If some one face the same problem here's the solution 
Code:
<h2><?= lang('forms.SERVICE_FORM_TITLE'); ?></h2>


    <label><?= lang("forms.SERVICE", [], 'en'); ?> <span class="text-danger">*</span></label>
    <input name="serv_en" class="form-control" value="" type="text">

    <label><?= lang("forms.SERVICE", [], 'fr'); ?>.fr.SERVICE') ?> <span class="text-danger">*</span></label>
    <input name="serv_fr" class="form-control" value="" type="text">

    <label><?= lang("forms.SERVICE", [], 'es'); ?> <span class="text-danger">*</span></label>
    <input name="serv_es" class="form-control" value="" type="text">