Using accents in forms
I want to create a form in Spanish in Drupal 7. However, whenever I include accents, the #title does not work. For example:
title => t('¿En qué ciudad vive?),
does not print any title at all.
Can someone help please?
Martin.
Gracias por tu ayuda. I guess I had better carry on in English or I'll break some forum rule ;)
I'm not quite sure what you mean by saving them in UTF-8. I'm currently developing in a Windows 7 environment with a view to uploading it on a Debian server. I have found that wrapping the text in htmltentities() does the trick!
I think this is really a PHP issue rather than a Drupal one.
Any further comments?
Martin.
You are right, it might be more of a PHP and file encoding issue...
UTF-8 is one of many character encoding formats that affect how characters are displayed... Depending on which PHP editor you use, it saves files with a default encoding. You should make sure that your editor is saving your files as UTF-8 which supports spanish accents.
For example, i work on Komodo IDE and it allows me to change and save the file with a different encoding if i need to.
If you do this, there won't be a need for you to use htmltentities() as it might give you some problems when you deal with html markup. Best not to depend on that function...
Which editor are you using for PHP?
I too am using Komodo but I am not sure how to change the encoding. I've gone into Preferences - Internationalization and changed from CP1252 to UTF-8 but it appears to have had no effect.
Any ideas?
I have Komodo IDE for Mac. Assuming that the UI is the same in Windows...
At the very bottom of the interface you have the grey status bar, which has some select menus to the right. On one of them you'll see the current encoding allowing you to change it by clicking and selecting UTF-8 from the encoding options and saving the file again.
Let me know if you find it...
Komodo IDE for windows is just as you describe Komodo IDE for Mac. I changed the encoding to UTF-8 and it works perfectly. Now I need to do some reading about encodings so I am up-to-speed. Thank you very much!
I'm sure I'm not meant to ask this in the forum but what is your interest in Spanish? If you want to take this off-line I can be contacted at martin_frost arroba usermail.com.
Thanks again!
Oh, I'm glad that it worked. As for my interest in Spanish. It's my main language as I am from Puerto Rico. But you are right, we shouldn't talk about that in this forum. If you want, you can follow me on twitter as @obrignoni and i'll follow you back...
Nice to see someone write spanish in this forum, jeje. I came across this same problem. Make sure that you save your files as UTF-8.
- Suerte