I am working on one custom module to alter the fields labels of user login form for visitors. I created a module to alter the labels in the user login form. The French language is enabled on the setup.
I am trying to translate the field labels on the user login form to French. I am using the following approach in a module.
I have included the namespace with use DrupalCoreStringTranslation
. After that, I have debugged the $form
variable inside hook_form_alter()
.
From this debugged variable, I am trying to translate the filed label ‘E-mail’ to French.
function hook_form_alter ({here goes all the parameters of alter hooks}){ $form['name']['#title'] = t('E-mail'); }
I am not able to see the translated Email field label on the user login form.
Am I missing anything? What should I do to translate the strings using hook_form_alter()
?