By hackmetal on
Hello !
I'm still a noob in drupal development. And here I don't understand why my form element "select" don't work properly :
$array1=array(
t('Activité physique et sportive'),
t('Agriculture production végétale'),
t('Agroalimentaire')
);
$form['advanced']['keywords']['domaine'] = array(
'#type' => 'select',
'#title' => t('Domaine d\'activité'),
'#options' => $array1,
);
the options with accents are not displayed at all..
How can I fix this ?
Thank's a lot ! =)
Comments
Put English terms inside t('')
When developing, you must put everything inside t('') in English.
Later, to localize the strings, use Drupal's own translation interface to translate all your English strings into French. Make sure the Locale module is enabled on you site.
Later, if you want to publish your module, usually you provide a .pot file and try to provide as many language files (.po) as possible. You might start by offering the French .po file with your module.
Creating .pot and .po files is not included with Drupal, though. But some contributed modules will help you create them.
/*_*/
http://www.xmacinfo.com
I see but the problem is
I see but the problem is that if I want to insert accents in a t() function, the select display an option empty. As if the accents make troubles..
So could we insert accents in select or not ? Is the translation required ?
Thank's again ;)
I've not tried this but
Did you try using HTML entities? Try converting é to é and è to è and do the same conversion for all text.
Usually development is in English. Translation is applied later though the locale module.
/*_*/
http://www.xmacinfo.com
yes i tried, but no
yes i tried, but no changes
I will try the translation file..
Invalid UTF-8
You need to save PHP files in the encoding UTF-8 without BOM. The current encoding of your files results in passing invalid UTF-8 bytes to check_plain (far downstream in FAPI), which results in empty strings.
Also, it's best to give explicit keys to your options array.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.
Thank you! I just seen that,
Thank you! I just seen that, when i printed the array, i could saw "?" replacing my "é".
Thank's again ;)
UTF-8 : very important
Hi !
I had a problem with my file encode.
And not only it didn't print any accentuated text, but it made common.inc crash with "Unsupported operand types" errors !
So, take care !
It was a custom and very personnal module, so I choose to write it only in french.
Calexo