Charset settings works for template content but not for product descriptions.
I am new to ZenCart and relatively new to php/MySQL. I have installed ZenCart ( www.sunriseledlight.com/shop ) with English, Norwegian, German and Spanish languages. My ZenCart version is 1.3.9d, and I am using the template ZenCartJquery Silver. The MySQL collation is UTF8_general_ci and I have been studying for two days now without finding any solution to my problem. :(
I also have to say that I am keeping one "Development" server at home, as well as one "production" server at a public host, so that I have been able to do a lot of trial and error in my localhost environment. Ok, Here we go:
The original installation was with english language, and in iso8859-1 which in plain text is called latin1, I have later come to understand. This was problem free. I configured the whole shop with categories, products, the whole lot, before I started installing more language packs. Norwegian language pack was installed, no problem. I could translate the text from english to Norwegian, and all the special characters worked. But then I got to Spanish and German, and that really ruined the whole day... The menus, the text around the buttons, the headline text in the boxes all translated perfectly to all the accented signs, no problems there. But the text that I entered, like product descriptions and the like, turned to strange unreadable signs. So I started to check for possible solutions.
One of the things I learned was that ideally, the MySQL database should be in UTF8, since this is more universal than iso8859-1. So I set about to convert my database to utf8. This was easier said than done, but since I have my little localhost here that I can blow up without anyone suffering any damage, I simply dumped all the tables to a textfile, ran it through some search and replace procedures until i managed to get a file that I could import back in, that now was in the utf8 format. The shop looked the same, all the articles are there, everything works, so I guess the operation was a resounding success. Well, except for one thing: The characters in Spanish and German were still exactly the same!
New angle on the problem: The http header. Set the language in the browser, is a proper fix, I found out after some more google - ing. Ok here we go, change the main language definition files: spanish.php and german.php . The CHARSET definition there was utf8, so just for fun I tried to change them to latin1. And guess what? IT WORKED! Now the product description text had all the special signs and characters, and I was just thrilled to have solved the problem.
But hey, wait.... eh... what is that strange sign there in the headline of the side box? InformaciĆ3n? now what? It turns out that now I have turned the whole problem upside down. Now the text that I myself have entered - like the product descriptions - are ok, but everything else is not! Somehow this halfway solution looks better, because the errors are more numerous in the product texts, but I suspect that this is not really a solution, quite the contrary in fact.
I have a sneaking suspicion that this all has something to do with the initial installation having been in iso8859-1 and the database having been converted to utf8 later, perhaps not even converted, it can be that my method of "converting" just converted the description of the tables from Latin1 to utf8, perhaps the data in there is still latin1. But if this is true, how can I explain that now, if I go in and erase a text, and then type it back in, the same errors are still there? Even so, according to most people, even the latin1 collation should give the correct results in ZenCart because of the charset definitions in the html header set in the "your_language.php" files. I even tried to import an old backup of the database with all the tables in latin1 - same difference. Absolutely the same result.
I am sort of knocking my head against a wall here, and it is kind of starting to hurt a bit. I feel that I am SO close to solving this, I have also learned a lot about the CHARSET issues out there (I have read many of your posts Vger) Does anyone out there have a clue? Please?
Re: Charset settings works for template content but not for product descriptions.
I have the exact same problem here.... I have spanish language pack installed - only the product descriptions show little squares instead of special/accented characters. Read a lot of charset info here and its making my head swim now :wacko:
anyone found a solution yet to this?
Re: Charset settings works for template content but not for product descriptions.
Quote:
Originally Posted by
bootz69
I have the exact same problem here.... I have spanish language pack installed - only the product descriptions show little squares instead of special/accented characters. Read a lot of charset info here and its making my head swim now :wacko:
anyone found a solution yet to this?
Bootz69:
I may be able to shed some light on the situation myself. What I finally did, and what seems to work, is to do a completely new, clean install of ZenCart, and configure it to run in utf8 to begin with. I found a guide to doing it somewhere here on this forum, the link is here: http://www.zen-cart.com/forum/showthread.php?t=93439
Follow these steps carefully, they did work for me, after a fashion. I also found out that when the Zen Cart was installed, I could import the database that I had converted to utf8 via the export to text file dump and run search and replace on the collation values, actually worked, when I imported the database, so that saved me a whole lot of work.
The only thing that is now giving me problems in my site is the Norwegian charset, and not from the database, but from the php files. The german, english and spanish all live happily together, both in the database and in the php files.
There is one little - rather obvious for seasoned programmers - factor I would like to call your attention to: If you - as you would do if you are sensible - are on ZenCart 1.3.9, you have to see this link here: http://www.zen-cart.com/forum/showthread.php?t=153582 . It tells you to NOT modufy the query_factory.php, but instead to create a separate file... well, read the thread. At first I did this, and simply couldn't make it work, the whole website stopped working. For a non- programmer like me, it was not so obvious that the php code needed a php closing tag, since the closing tag was omitted in the example! :lamo:
Good luck! :smile:
Re: Charset settings works for template content but not for product descriptions.
:clap:
Thankyou sjur.hemma!
I created my_db_charset.php files (being careful to put the closing php tags in!) and it works like a dream!
saved me a lot of work :P
check it out at spanishartisan
its a work in progress :blush:
Re: Charset settings works for template content but not for product descriptions.
Quote:
Originally Posted by
sjur.hemma
Bootz69:
There is one little - rather obvious for seasoned programmers - factor I would like to call your attention to: If you - as you would do if you are sensible - are on ZenCart 1.3.9, you have to see this link here:
http://www.zen-cart.com/forum/showthread.php?t=153582 . It tells you to NOT modufy the query_factory.php, but instead to create a separate file... well, read the thread. At first I did this, and simply couldn't make it work, the whole website stopped working. For a non- programmer like me, it was not so obvious that the php code needed a php closing tag, since the closing tag was omitted in the example! :lamo:
Good luck! :smile:
And I thank you too sjur.hemma for the link - putting utf8 in as your_charset_here also worked perfectly for German
regards
Jack
Re: Charset settings works for template content but not for product descriptions.
Quote:
Originally Posted by
sjur.hemma
For a non- programmer like me, it was not so obvious that the php code needed a php closing tag, since the closing tag was omitted in the example!
The closing php tag is NOT required:
https://www.zen-cart.com/tutorials/i...hp?article=313