We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

how to do translation through forms

Hi i am using translation in my project and i have two language files but in case of forms labels and placeholders, how to do translation? form code is this:

        $name = new Text("name",array(
        'class' => 'mi_field',
        'placeholder' => '顧客名'));

    $name->setLabel('顧客名');

    $name->addValidators(array(
        new PresenceOf(array(
            'message' => 'The name is required'
        ))
    ));
    $this->add($name);

my existing way of doing translation is using this :

            <th  height="36" class="mi_table_head"><?php echo $t["name"] ?></th>
                    <th  class="mi_table_head"><?php echo $t["compname"] ?></th>
                    <th  class="mi_table_head"><?php echo $t["search"] ?></th>

Pls help me



11.6k

you can use js/jquery once the page is loaded to modify element's attributes values depending on the current langage

Hi, Thank you for the reply, can you pls explain me how to do that, iam a newbie.

since you already do translation in your view, I assume that you're passing your translation function to the view. To translate your placeholders, messages or any other text in your backend, just call your translation function and use it in similar way.