-
UTF-8 Zen-Cart Tutorial for v1.3.x
I posted a tutorial as to how to transition zen-cart over to UTF-8 encoding also having the database encoded in UTF-8 too. This was made for carts using Japanese, but it could be used for many other languages.
Here is the link
UTF-8 Zen-Cart
I hope people find this helpful.
Regards,
CKD
-
Re: UTF-8 Zen-Cart Tutorial
Excellent tutorial.. thanks for taking time
to create and share
:clap:
-
Re: UTF-8 Zen-Cart Tutorial
Its always good to give back. I wish, I had more to give.
-
Re: UTF-8 Zen-Cart Tutorial
Thanks for the tip. It would be something great to have as a standard feature in a next version of Zencart.
-
Re: UTF-8 Zen-Cart Tutorial
I wish it was UTF-8 from the get go too, but I understand that when they started zen-cart, UTF-8 wasnt really a good option then. So to change everyone over, would be a huge pain I am sure. I would like to make a way to take an existing cart and change it over to UTF-8, database and all.
Maybe when I get more time, I will look into that.
-
Re: UTF-8 Zen-Cart Tutorial
if i already installed my zen cart, would i need to re-install after i finished everything in the tutorial
-
Re: UTF-8 Zen-Cart Tutorial
@bmpt
This is aimed at starting with a fresh install. If you are running your cart already and you apply this to a current cart, there could be problems. What languages are you running?
I would recomend you install on a backup store first. But let me know your setup and maybe I can offer some suggestions.
Regards,
CKD
-
Re: UTF-8 Zen-Cart Tutorial
I kind of thought that, Im only running English right now & most likely i will only offer English, My Sister lives in japan & i wanted to see how accurate the translation is. Thanks for the advise
-
Re: UTF-8 Zen-Cart Tutorial
I am sorry, i might be wrong, but it seems Zen-cart install creates databases in other collation, the should be some touches in install directory as well (correct me if i am wrong)
-
Re: UTF-8 Zen-Cart Tutorial
@lazy_666
Wow, thats name you got there, anyways. Did it not work for you? It should work as is no problem, but please let me know if you do encounter a problem.
Regards,
CKD
-
Re: UTF-8 Zen-Cart Tutorial
I did converted my website for UTF-8 before i found your thread :( but i did basicaly most of the things described.
So we can accept that "yes it did work for me", actually, i converted my files from Windows-1251 to UTF-8 as an aditional work, because if you use old encoding, you end up with a mess, or as i like to say MESS.
Actually it is very nice article, even short - full of information.
-
Re: UTF-8 Zen-Cart Tutorial
If not UTF8 encoded, can I use Japanese pack correctly? If yes, there is known problem with that?
##############################___
MiuMiu Handbags
-
Re: UTF-8 Zen-Cart Tutorial
Never tried Japanese, but with my experience with Bulgarian (completely different character set) u cant. At least not without heavy modifications...
-
Re: UTF-8 Zen-Cart Tutorial
@alvalong
You can, but if you don't already have a cart going, there really is not reason not to. You will have less problems running it in UTF-8.
You can, just run the Japanese side in UTF-8 though.
Good Luck
CKD
ps. I am busy until next week, so I can't test the checkout pages just right yet, for anyone that is having problems with this. If you are having problems, let me know if you setup a custom template for it, and if you are doing the zone drop down in both languages.
-
Re: UTF-8 Zen-Cart Tutorial
Hello,
I have a strange problem with building a UTF8 Zencart.
Now I am trying to move my Zencart shop from my old server to a new one. I built the shop by using UTF8 code and it works fine on my old server. But after I moved the shop, I am facing some character code issue.
When I restored my backup copy to the new server, it could display correct characters on both MySql(PHPMyAdmin) and my Zencart shop, but when I input some data from my web shop(for instance, input personal data when signing up for a new account or add a new product from admin page), the characters will become a mess. Besides, if I insert the data from PHPMyAdmin, everything will be fine.
I followed the directions of this post to install a fresh Zencart with UTF8 in my new server but still have the same problem.
Does any one know what could be the reason of this issue? Thank you for your advice in advance.
-
Re: UTF-8 Zen-Cart Tutorial
have you changed query_factory.php ?
-
Re: UTF-8 Zen-Cart Tutorial
-
Re: UTF-8 Zen-Cart Tutorial
Whats your Collation settings in phpMyAdmin?
Did you do this?
Go to phpMyAdmin->Operations. From there go to Collation and change it to "utf8_general_ci", then hit "Go".
Quote:
Originally Posted by
nurapipi
Hello,
I have a strange problem with building a UTF8 Zencart.
Now I am trying to move my Zencart shop from my old server to a new one. I built the shop by using UTF8 code and it works fine on my old server. But after I moved the shop, I am facing some character code issue.
When I restored my backup copy to the new server, it could display correct characters on both MySql(PHPMyAdmin) and my Zencart shop, but when I input some data from my web shop(for instance, input personal data when signing up for a new account or add a new product from admin page), the characters will become a mess. Besides, if I insert the data from PHPMyAdmin, everything will be fine.
I followed the directions of this post to install a fresh Zencart with UTF8 in my new server but still have the same problem.
Does any one know what could be the reason of this issue? Thank you for your advice in advance.
-
Re: UTF-8 Zen-Cart Tutorial
Actually that shouldn't be your problem...I would go over the steps again and check your code. Check it anyways, the collation.
Maybe start with a fresh cart on your new server and start form scratch there and see if you get the same results. Not fun, I know, but its a good way to learn.
Good luck,
CKD
-
Re: UTF-8 Zen-Cart Tutorial
narupipi,
You didn't say from which server to which server you transfered your zencart?
it could be a collation trouble as it is platform dependent.
Look at your language files and try different collation...
@setlocale(LC_TIME, 'ja_JP.utf8'); this one for example will work perfectly on a Unix system but not on Windows server where this is better:
@setlocale(LC_TIME, 'ja');
-
Re: UTF-8 Zen-Cart Tutorial
I forgot this one is important too, check it please:
define('CHARSET', 'utf-8');
-
Re: UTF-8 Zen-Cart Tutorial
Hi,
Thank you all for your response.
I did things suggested but it doesn't work.
@lazy_666
I changed query_factory.php as I posted previously, is there any other code should be changed?
@CrystalKoi
I installed a fresh Zencart but the problem is still there.
My collation settings is utf8_general_ci. I changed collation to "utf8_general_ci" from phpMyAdmin->Operations befrore I install a fresh Zencart.
@pilou2
I transferred my cart from UNIX system to another UNIX so it should be OK. And "define('CHARSET', 'utf-8');" is OK, too.
As I mentioned, if I insert data from phpMyAdmin, it can be dispalyed correctly both on phpMyAdmin and Zencart, but if I input data from Zencart, it cannot be displayed correctly.
It seems that phpMyAdmin(or MySQL!?) can pass the correct character code to Zencart, but Zencart cannot pass correct character code to phpMyAdmin(or MySQL!?).
phpMyAdmin(send) -> (receive)Zencart (O)
Zencart(send) -> (receive)phpMyAdmin (X)
so the problem happens only when Zentcart tries to insert data into MySQL. Is that possible problem of my new server's setting? Thanks again.
-
Re: UTF-8 Zen-Cart Tutorial
I have a problem with french language.
In phpMyAdmin, the collation is : utf8_unicode_ci
Jeu de caractères pour MySQL: UTF-8 Unicode (utf8)
In includes/languages/french.php :
Code:
@setlocale(LC_TIME, 'fr', 'french', 'fra', 'fr_FR', 'fr_FR@euro');
define('HTML_PARAMS','dir="ltr" lang="fr"');
define('CHARSET', 'utf-8');
In admin/includes/languages/french.php :
Code:
@setlocale(LC_TIME, 'fr', 'french', 'fra', 'fr_FR', 'fr_FR@euro');
define('HTML_PARAMS','dir="ltr" lang="fr"');
define('CHARSET', 'utf-8');
In page source of index.php :
Character Encoding-> UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
In page source of admin/index.php :
Character Encoding-> iso-8859-1
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
Does any one know what could be the reason of this issue?
-
Re: UTF-8 Zen-Cart Tutorial
Hello,
Try this:
Go to your Zencart admin page,
Tools -> Developer Tool Kit
and search "iso-8859-1" from "look-up in all files" and check did you change all "iso-8859-1" to "UTF-8".
Good luck.
Quote:
Originally Posted by
Mikado
I have a problem with french language.
In phpMyAdmin, the collation is : utf8_unicode_ci
Jeu de caractères pour MySQL: UTF-8 Unicode (utf8)
In includes/languages/french.php :
Code:
@setlocale(LC_TIME, 'fr', 'french', 'fra', 'fr_FR', 'fr_FR@euro');
define('HTML_PARAMS','dir="ltr" lang="fr"');
define('CHARSET', 'utf-8');
In admin/includes/languages/french.php :
Code:
@setlocale(LC_TIME, 'fr', 'french', 'fra', 'fr_FR', 'fr_FR@euro');
define('HTML_PARAMS','dir="ltr" lang="fr"');
define('CHARSET', 'utf-8');
In page source of index.php :
Character Encoding-> UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
In page source of admin/index.php :
Character Encoding->
iso-8859-1
<meta http-equiv="Content-Type" content="text/html; charset=
iso-8859-1">
Does any one know what could be the reason of this issue?
-
Re: UTF-8 Zen-Cart Tutorial
I just did an install of this. I had to update one thing on the instructions. Changed the location of the language file for the Admin. I'm sure most people got that anyways.
I fallowed my instructions to see if I would get any problems, and all is fine.
Sorry and Good luck,
CKD
-
Re: UTF-8 Zen-Cart Tutorial
Hi
I resolved my problem by changing my server provider. So my issue was nothing to do with Zencart or MySQL. Sorry to confuse you all and thanks for your advices.
-
Re: UTF-8 Zen-Cart Tutorial
I think I have a couple of issues related to language encoding.. this seems the proper thread to ask.
I have English Zen Cart installed and then added the Simplified Chinese language pack, GB2312. Adding/viewing Chinese thru web browser is fine (product desc, categories etc)
But found a couple of issues :
1. The order confirmation (Chinese) text-email sent out can't display the product name (the line with the quantity /product name / product code). It shows something like:
1 x Ĉ 21; 421;Ŏ 57;È 04; 359;# 033; (AA3319) = $25.00
Other parts of the email shows chinese just fine.
2. The search function doesn't return any results if I search with chinese words (in chinese mode)
Bcos the database is in ISO-8859??
Is there anyway to rectify without reinstalling. Just by changing the encoding of the database?
Thanks.
-
UTF-8 problems with google search
Hello! I need help please. I use ZC in two languages English and Russian. I've defined the charsets in both english.php and russian.php as UTF-8. I have converted all Rusian PHP files from ANSI to UTF-8 without BOM. I have then changed all database tables colladion to utf_general_ci. I have no problems with characters displaing but when I perform search in search engine in Russian it comes with no result. The search browser doesn't see anuthing in Russian. Can anybody help me please? Where is the problem?
-
Re: UTF-8 Zen-Cart Tutorial
Hi, I have a problem with the search in my zen-car when I use UTF-8 encoding
My database is in collation utf8, charset in bulgarian.php and in english.php is utf-8 too.My DB/tables are utf8 but I can make search when type cyrillic words. It shows no results. With English word everything is OK:)
Can somebody help me?!
-
Re: UTF-8 Zen-Cart Tutorial
See forums.oscommerce.com/index.php?showtopic=262287 for a possible solution?
-
Re: UTF-8 Zen-Cart Tutorial
Hi,
Some notes about my experience with this.
I am rebuilding a site that developed a (non-encoding-related) problem I could not solve so I started again and since I have an english-spanish site it seemed a good idea to go UTF-8 from this new start.
I followed the tutorial and all seemed to work ok.
Now I am gradually adding in the template mods I did previously.
(I’m using Notepad++ which shows the encoding of the file and can convert between different encodings and UTF-8, it reports the file encoding on the bottom right of the status bar.)
1) Adding spanish language files (from an old contribution which I have updated to 1.38a).
Firstly I found that any accented character was wrongly reproduced in the shop.
Notepad++ reported the relevant language file as being ANSI encoded.
I converted this to UTF-8, the accented characters in the file changed to unrecognised characters which once corrected displayed correctly in the shop.
2) Next I started getting blank screens on certain places in the shop.
I found that this was due to now having the spanish.php (or english.php) encoded as “UTF-8” instead of “UTF-8 without BOM”.
Things seem ok now.
So, I don’t know whether I now have to convert every file in the shop whether pure php or only the language files to have things as they ”should be”?
Regards
Steve
-
Re: UTF-8 Zen-Cart Tutorial
Language files: all should be UTF-8 without BOM.
Template files and other PHP files: any file that contains special characters should also be converted to UTF-8 without BOM. However, if you've used language constants properly, you should never need to touch any other files.
SQL files: the files in the zc_install folder are only used during installation or upgrade. As such, if your site is already installed, there's no need to convert them.
-
Re: UTF-8 Zen-Cart Tutorial
Thanks for that confirmation,
I just found it strange that no-one else had mentioned similar symptoms regarding the encoding of language files.
In practice Notepad++ does not "convert" a file from ANSI to UTF-8 if there are no accented chars in the file (such as in a pure php file): on reopening the file it is reported as being still ANSI.
Anyway everything seems to be working UTF-fine now so full marks to CrystalKoi,
regards
Steve
-
Re: UTF-8 Zen-Cart Tutorial
Dear Friends,
Many thanks for this thread and the information converting the site to UTF-8.
I have done everything as written and it works fine on both the web site and Admin side. Language is Hebrew on GoDaddy shared hosting with MySql 5.
The issue we having is when we insert information from the website/admin we have everythig ok on the web/admin side but on the MySql PHP Admin we get unreadable characters.
If we key information in the MySql PHP Admin we get unreadable characters on the site/admin.
Here is sample of characters we get on the MySql PHP Admin:
Quote:
'מרכזיות'
The MySql is set to
Code:
COLLATE utf8_general_ci
Site is www.addvant.co.il
Thanks
AddVant
-
Re: UTF-8 Zen-Cart Tutorial
@AddVant
1st, you did the database Collation before you installed Zen-Cart?
Also, you did this too?:
The next change is to query_factory.php.
NOTE:
With v1.3.9 you don't have to touch the query_factory.php file.
You should use this method instead: http://www.zen-cart.com/forum/showthread.php?t=153582
For v1.3.8 and OLDER, use the following:
Find it in: includes/classes/db/mysql/query_factory.php
1-> Find this (line 33):
PHP Code:
// pconnect disabled ... leaving it as "connect" here instead of "pconnect"
$this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
}
if ($this->link) {
if (@mysql_select_db($zf_database, $this->link)) {
$this->db_connected = true;
return true;
} else {
$this->set_error(mysql_errno(),mysql_error(), $zp_real);
return false;
}
} else {
$this->set_error(mysql_errno(),mysql_error(), $zp_real);
return false;
}
}
2-> Change to this (this will not work as an override):
PHP Code:
// pconnect disabled ... leaving it as "connect" here instead of "pconnect"
$this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
}
if ($this->link) {
if (@mysql_select_db($zf_database, $this->link)) {
//BOF changed for utf-8
mysql_query('SET NAMES "utf8"', $this->link);
//EOF changed for utf-8
$this->db_connected = true;
return true;
} else {
$this->set_error(mysql_errno(),mysql_error(), $zp_real);
return false;
}
} else {
$this->set_error(mysql_errno(),mysql_error(), $zp_real);
return false;
}
}
-
Re: UTF-8 Zen-Cart Tutorial
I would change all my zencart to UTF-8, for full compatibility with all browser. But I've to change into UTF-8 all my db tables?
-
Re: UTF-8 Zen-Cart Tutorial
Before you install Zen-Cart you need to change the database Collation. That should take care of the database.
-
Re: UTF-8 Zen-Cart Tutorial
I've already zencart 1.3.7 installed, and the collation into db is already set to utf-8
-
Re: UTF-8 Zen-Cart Tutorial
HI,'
There is an add-on for UTF-8 fro Zen Cart 1.3.8a
UTF-8 Support for ZenCart 1.3.8a
Author: Markos Kyriacou
I am in process of installing a fresh Zen Cart 1.3.8a. After reading through the posts in this thread, I am still a little confused.
1. Should I install a fresh copy of Zen Cart 1.3.8a and after that install the UTF-8 add-on?
2. Should I follow the instructions of this thread and Configure the database first and follow the steps as recommended in www.srw2d.com/content/utf-8-zen-cart? Do I still need to install the UTF-8 add-on?
Please advise for Zen Cart newbie!
Thank You!!!!
:smile:
-
Re: UTF-8 Zen-Cart Tutorial
They should both work, I kind of like the one on srw2d.com :wink::cool:
-
Re: UTF-8 Zen-Cart Tutorial
-
Re: UTF-8 Zen-Cart Tutorial
I set UTF-8 end i have o.k. character. But in Opera end IE the font is different (bigger) in Firefox font is good.
Hay it's possible!
-
Re: UTF-8 Zen-Cart Tutorial
Quote:
Originally Posted by
kobra8
I set UTF-8 end i have o.k. character. But in Opera end IE the font is different (bigger) in Firefox font is good.
Hay it's possible!
With http://validator.w3.org while checking this document as XHTML 1.0 Transitional faund:
The Unicode Byte-Order Mark (BOM) in UTF-8 encoded files is known to cause
problems for some text editors and older browsers. You may want to consider
avoiding its use until it is better supported.
Is thet problem with font in IE, Opera end Firefox?
-
Re: UTF-8 Zen-Cart Tutorial
Font size is part of css. Note the part where it says, Older text editors and browsers. Anything above IE6, you will have no problem with UTF-8.
With font, you need to adjust your css.
Regards,
CKD
-
Re: UTF-8 Zen-Cart Tutorial
Thanks for the instructions. I have followed the steps (modify the php files) except that I use MySQL Administrator UI to change the default collation to utf8_general_ci. Restart the MySQL Service, create the database.
When trying to install Zen Cart, I got this error:
Code:
Installation In Progress...
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
1366 Incorrect string value: '\xA3:&eur...' for column 'configuration_value' at row 1
in:
[INSERT INTO szc_configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Convert currencies for Text emails', 'CURRENCIES_TRANSLATIONS', '£,£:€,€', 'What currency conversions do you need for Text emails?
Default = £,£:€,€', 12, 120, NULL, '2003-11-21 00:00:00', NULL, 'zen_cfg_textarea_small(');]
I am not sure what I am missing here. Could you give a hint?
Thanks!
-
Re: UTF-8 Zen-Cart Tutorial
That's because the .sql file containing the initial database load in v1.3.x contains several non-UTF-8 characters in it, and you've set your database to be UTF8.
-
Re: UTF-8 Zen-Cart Tutorial
Hi everyone,
I've installed a 1.3.8a ZC recently, and am having trouble with the UTF8. This is not the 1st time I work on Chinese ZC stores, but it's been years since the last install so I can't remember what I did to get the other stores working...
I've followed the instructions here : http://www.srw2d.com/content/utf-8-zen-cart
But when I tried to edit the query_factory.php file I ran into a problem.
Here is a rundown of what happened :
1. Installed ZC 1.3.8a and the traditional Chinese language pack (I forgot to do the recommended changes before installation).
2. After the store and Chinese language are both installed and working, I went ahead and did the changes as per instructions at srw2d.com.
3. After I edited query_factory.php I got a blank page at my store.
Current store settings :
1. MySQL connection collation is utf8_unicode_ci
2. My ZC database collation is utf8_general_ci
3. Everything looks fine at the shop and admin
4. All Chinese characters became "aliens" in the database
5. If I edit the database fields directly, I can read the Chinese characters in the database but they become "aliens" at the front end
I hope I don't have to start the whole thing over... any help would be much appreciated ! Thanks in advance ! :)
Shirley
-
Re: UTF-8 Zen-Cart Tutorial
Quote:
Originally Posted by
shirster
3. After I edited query_factory.php I got a blank page at my store.
Using the Debug Log utility from this article should help you find what's causing the blank page: https://www.zen-cart.com/tutorials/index.php?article=82
-
Re: UTF-8 Zen-Cart Tutorial
I will try and post the file on my site so that you can download it and use it.
I have seen this issue before with people. But can never work out why. On Monday, here in Japan, I will post a file to the srw2d.com site and put a link here to download it. You can try that file and see if you still have the same problem.
Regards,
CKD
-
Re: UTF-8 Zen-Cart Tutorial
Thanks Dr. Byte and Koi. I haven't tried the debug utility yet, I'd just like to report that if I edit the query_factory.php file BEFORE installation, I couldn't even install, I simply got stuck at the install page.
But if I proceed to install without editing the query_factory.php file, I got alien characters in the database again.
:SIGH:
-
1 Attachment(s)
Re: UTF-8 Zen-Cart Tutorial
I attached one file that I know works here:
Attachment 6324
Upload this one to includes/classes/db/mysql/
This overwrites the core file.
Let me know if you still get the error after this,
Regards,
Shaun
NOTE:
With v1.3.9 you don't have to touch the query_factory.php file.
You should use this method instead: http://www.zen-cart.com/forum/showthread.php?t=153582
-
Re: UTF-8 Zen-Cart Tutorial
Shaun... YOU SAVE MY LIFE !!!!!!!!!!!! It works now ! (Though I used BBEdit to compare the documents and still don't know what went wrong ^^)
Arigato !!!!!!!!!!!!!!! \(^o^)/
-
Re: UTF-8 Zen-Cart Tutorial
Nice to hear.
Wonder what the problem is? Maybe you can attach your file and I can look at it, or the Dr. if he has time.
-
Re: UTF-8 Zen-Cart Tutorial
Hi,
After installed, when I switch from English to Japanese in Admin, I got this message on the top of the page:
Warning: Cannot modify header information - headers already sent by (output started at /homepages/24/d293486072/htdocs/GooGooNY/includes/languages/japanese.php:2) in /homepages/24/d293486072/htdocs/GooGooNY/includes/init_includes/init_templates.php on line 36
Also, everything I input in Japanese for product or EZ Pages, they all come out like this: "????????"
What have I done wrong? I'm pretty sure I followed every step correctly..
Please help! Thanks.
-
Re: UTF-8 Zen-Cart Tutorial
Hello,
Everything is good now; I've found the reason why the Japanese wasn't displayed correctly.
But I still have problem with the admin panel. Everytime when I switch from English to Japanese, it doesn't pick up that it is UTF-8 even though it IS UTF-8 according to the source code. It always uses other language coding and of course, the text just cannot be read. What's more annoying is that every page you go (in admin area), I have to change the code to UTF-8 manually everytime...
What should I do?
-
Re: UTF-8 Zen-Cart Tutorial
@CrystalKoi: I have written a script that will automatically convert all appropriate zen table fields to utf8. If this works with no problem it would be great for running stores. I will keep you updated.
-
Re: UTF-8 Zen-Cart Tutorial
Quote:
Originally Posted by
e81ny
Hello,
Everything is good now; I've found the reason why the Japanese wasn't displayed correctly.
But I still have problem with the admin panel. Everytime when I switch from English to Japanese, it doesn't pick up that it is UTF-8 even though it IS UTF-8 according to the source code. It always uses other language coding and of course, the text just cannot be read. What's more annoying is that every page you go (in admin area), I have to change the code to UTF-8 manually everytime...
What should I do?
Sorry for the late reply here. Go into your admin language file. admin/includes/japanese.php and look for where it says
PHP Code:
define('CHARSET', 'utf8');
change that to :
PHP Code:
define('CHARSET', 'utf-8');
Sorry about that, its a known issue. FF handles it fine, but IE does not.
-
Re: UTF-8 Zen-Cart Tutorial
@yellow1912 - you might want to contact Dr. Byte as I know he is trying to work this into the install for 2.0. Maybe it could be some help to him. It would be a great tool for the community!
-
Re: UTF-8 Zen-Cart Tutorial
Hi there..
I'm having problems with my site..
I followed steps from CrystalKoi, but characters are not ok..
But there is one thing I must say...
I'm switching server for my store!
After fresh install of new one I made a collation in database to utf8_general_ci, then I import SQL database backup from old store.
And then collation changes to latin1_swedish_ci, I don't know why..
In my language pack is everything changed to utf-8.
When I change query_factory file is result even worser..
Can anyone help me please...
Here is my site..
www.pilica.si
-
Re: UTF-8 Zen-Cart Tutorial
Hi Spiritus,
The database you importing, that data is stored in latin1_swedish_ci I am guessing, no?
And if you change the collation, yes it will get worse if you don't have your information in UTF-8.
Check the database you are importing.
Regards,
CKD
-
Re: UTF-8 Zen-Cart Tutorial
you're right.. old database is in latin1.. Because I've made site on test server and there I didn't need utf-8..
Now I use english and Slovenian language pack and I need utf-8 for that new site.
What can I do now? I have problem with collation, I must somehow change older database to utf-8 and than import it to new one.
Am I right?
Please help..
tnx for reply
-
Re: UTF-8 Zen-Cart Tutorial
Converting them is not fun. I think someone did something like this, but off the top of my head, I can't remember.
You might be able to use easy populate module and pull all the data you need from one and put it in the other one. That would be easier I would think.
Good luck and just know that its always better to start with UTF-8.
Wish I had a better answer,
CKD
-
Re: UTF-8 Zen-Cart Tutorial
I found one great thread. I think it will help to everyone with this problems..
Collation change for SQL databases
It works ..
-
Re: UTF-8 Zen-Cart Tutorial
Cool, I will have to test this.
-
Re: UTF-8 Zen-Cart - checkout_payment CSS problem
Hello CrystalKoi
Thanks so much for your utf-8 files and tutorial. I have my shop set up and all works fine except for one small problem. When checking out in IE8 in Japanese, the checkout_payment page is not using the CSS stylesheet and is coming out in v large type. All other checkout pages display correctly. All pages display correctly in Firefox. Originally I thought it was because I was using Worldpay pages in English, but disabling Worldpay did not help.
I did look at the source and the page is calling for the correct stylesheet.
Also if I enable Paypal website payments, both the checkout_payment and payment_confirmation pages display wrongly when the customer chooses Paypal. Please, can you suggest where the problem may be arising.
Thanks
-
Re: UTF-8 Zen-Cart Tutorial
I've followed the instructions on CrystalKoi's site, for my JustHost.com ZenCart installation (it's ZenCart 1.3.8a [patched]). The DB seems set for uft8_general_ci collation beforehand, and then I update the english.php and query_factory.php pages as described in the UTF-8 Zen-Cart tutorial. After this, FireFox does display the page as utf-8.
I then proceeded with the Zen-Cart 1.3.8 Japanese Pack Install tutorial, but the Japanese language site goes to a blank page when I click the 'add to cart' button. The product gets added to the cart, but the redirect doesn't bring back a page (it's just blank). In english, this works just fine.
Is there something I can do to find out what's the problem?
I've done the tutorials twice now, each time with a fresh install, so I'm confident that I'm performing the steps OK. I do have a template that I'm using (apple_zen).
I've tried using the debug_log utility, but it doesn't place any log files in the /cache/ directory. Also, I've tried replacing the query_factory.php file from earlier in this thread, but it didn't do anything for me.
Thanks,
Alex
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Yaay, I figured this out.
I must have not refreshed the /cache directory yesterday, because this morning it was filled with log files. Using those, I tracked down two problems.
1st. The /includes/languages/japanese.php file had extra spaces and a carriage return after the closing ?>
2nd. That file was not saved as UTF-8 without BOM. It was simply UTF-8. Using Notepad++ you have the option of saving without BOM (Byte Order Mark).
This page explains the issue:
https://www.zen-cart.com/tutorials/i...hp?article=396
So, long story short, the answers were all here in my case, I just didn't know what questions to ask (because I didn't check the logs).
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Sorry to bump this off but I'm having a problem. My "product was added on date" displays in gibbrish. I'm using hebrew. Which file do I have to convert to UTF8 to make it work properly? Or is it SQL related? I fresh installed Zencart with UTF-8 support already built in.
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Is your language file settings, example: english.php, is this set to utf-8 in the settings, not the file itself, which should also be utf-8, but what sets the source code to utf-8.
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
I saved my hebrew.php in dreamweaver with UTF-8 encoding (w/o bom of course) and inside the file it has utf-8 defined properly.
Code:
// charset for web pages and emails
define('CHARSET', 'utf-8');
Thing is, I don't know what generates the days and dates on Zen Cart...
This is the template I'm working on (hope you're using firefox):
http://www.hilapc.co.il/index.php?ma...&products_id=5
If you can see the characters properly (I mean, the hebrew stuff) then, you'll notice the culprit down below on the product info page, it's the last line in the middle box.
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
does this text look right?
ЧћЧ•Ч¦ЧЁ Ч–Ч” Ч”ЧЄЧ•Ч•ЧЎЧЈ Ч‘Ч™Ч•Чќ щбъ, 13 Ч‘ошх, 2010
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
If that is right, just do a search of the files with dreamweaver for part of that language, shouldn't be too hard to track down. Give it a go!
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
I use Total Commander since it can track down text strings within files. Thing is, I did a simple test. In the english version you'd expect the days to be "sunday, monday" etc'. So I looked for "sunday" and it didn't catch anything, meaning ZC somehow generates this on the fly.
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
No, I don't think this is true, as it would not generate Hebrew on the fly. You need to do a search for a part of the hebrew with whatever file search tool you have. Once you find the file, you need to change the encoding of that file. Good luck
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Hmm, I checked my SQL database and few tables have "latin1_swedish_ci" in the collation column instead of utf8, does that pose any problem?
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
I suspect your DATE_FORMAT_LONG definition is wrong, or your server is not generating the date "words" properly when the strftime() function is called. You may have to resolve the matter with your hosting company by confirming that they've got a valid hebrew language config set in their PHP.
NOTE: All the date "words" are generated by the PHP configuration on your server. Zen Cart DOES NOT spell out all the days of the week and months of the year in a language file.
files involved in english to display the "date added" content:
/includes/languages/english/YOUR_TEMPLATE/product_info.php (and other product types too):
Code:
define('TEXT_DATE_ADDED', 'This product was added to our catalog on %s.');
/includes/languages/YOUR_TEMPLATE/english.php:
Code:
define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()
/includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php (and other product types too):
Code:
<p id="productDateAdded" class="productGeneral centeredContent"><?php echo sprintf(TEXT_DATE_ADDED, zen_date_long($products_date_added)); ?></p>
/includes/functions/functions_general.php in the zen_date_long() function:
Code:
return strftime(DATE_FORMAT_LONG, mktime($hour,$minute,$second,$month,$day,$year));
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Hmm, I've already converted these files to UTF-8 :) But...I think I may have found the problem. I didn't convert the admin hebrew language (it's basically the old english language files) files so I get this error in the admin aswell. I'm going to convert them and then check again, hoping this will resolve the problem. The server settings should be good. If this doesn't work I'll check deeper into it. Thanks a lot Dr.Byte, I'm afraid this forum is huge so I posted in few places to make sure it gets attention. Didn't mean to upset anyone.
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Hmm...I noticed that if I change the encoding back to windows-1255 on the browser it displays fine. Hmmm..................this doesn't relate to the SQL anywayn, does it?
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
No connection to SQL.
I suspect maybe the server's language file may not be properly encoded?
Just a guess
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
I understand. How is that file named? php.ini perhaps? I'm also wondering, if another cart is installed on the server and uses charset windows-1255, will it be badly affected from changing the encoding of the server language file?
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Sorry, I'm not an expert on configuring for Hebrew language.
Maybe this will help? http://www.zen-cart.com/forum/showthread.php?p=584302
If it's a server issue with your PHP configuration, then it's something your hosting company will have to fix. It's NOT in php.ini.
-
date and time formats
Regarding the date format and day and month names outputted by php, you may find this thread of use regarding the available locales on your server, which may be related to your problem.
http://www.zen-cart.com/forum/showthread.php?t=133111
regards
Steve
-
Re: date and time formats
Thanks Steve. I knew there was another discussion around here about that.
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Thank you Crystal Koi for your great article! I have tried to read it very carefully, but I'm afraid I don't totally understand. (I never had to work with charsets before).
First I will explain the problem. I am maintaining a few zen cart stores for my boss. Within these stores we have german language installed. German language contains a lot of umlaut characters, which are not displayed well in the product information or in the product titles in the menu.
My boss is not happy with it (I can't blame him) and wants me to change it. But I don't know how to change it on a working store. Will your fix work on a running store? And can I convert the db tables to utf-8 without problems? If so, how should I proceed?
Thank you in advance!
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
I see lots of talk about changing query_factory.php to accommodate UTF-8, but for admin there is also query_factory.php
I see no mention of modding this as well. I did and all seems to work there fine now too.
Also for changing your database after the fact, instead of going in and changing each field in each table, the following script works nicely. It will output a rather large list of alter table sql that you can copy and paste into phpmyadmin and change all at once. I didn't write this, but have used it and my confidence is high. It will also pickup and generate sql for any tables your other mods have added.
Use at your own risk.
Code:
<?php
// this script will output the queries need to change all fields/tables to a different collation
// it is HIGHLY suggested you take a MySQL dump prior to running any of the generated
// this code is provided as is and without any warranty
die("Make a backup of your MySQL database then remove this line");
set_time_limit(0);
// collation you want to change:
$convert_from = 'latin1_swedish_ci';
// collation you want to change it to:
$convert_to = 'utf8_general_ci';
// character set of new collation:
$character_set= 'utf8';
$show_alter_table = true;
$show_alter_field = true;
// DB login information
$username = 'user';
$password = 'pass';
$database = 'dbname';
$host = 'localhost';
mysql_connect($host, $username, $password);
mysql_select_db($database);
$rs_tables = mysql_query(" SHOW TABLES ") or die(mysql_error());
print '<pre>';
while ($row_tables = mysql_fetch_row($rs_tables)) {
$table = mysql_real_escape_string($row_tables[0]);
// Alter table collation
// ALTER TABLE `account` DEFAULT CHARACTER SET utf8
if ($show_alter_table) {
echo("ALTER TABLE `$table` DEFAULT CHARACTER SET $character_set;\r\n");
}
$rs = mysql_query(" SHOW FULL FIELDS FROM `$table` ") or die(mysql_error());
while ($row=mysql_fetch_assoc($rs)) {
if ($row['Collation']!=$convert_from)
continue;
// Is the field allowed to be null?
if ($row['Null']=='YES') {
$nullable = ' NULL ';
} else {
$nullable = ' NOT NULL';
}
// Does the field default to null, a string, or nothing?
if ($row['Default']=='NULL') {
$default = " DEFAULT NULL";
} else if ($row['Default']!='') {
$default = " DEFAULT '".mysql_real_escape_string($row['Default'])."'";
} else {
$default = '';
}
// Alter field collation:
// ALTER TABLE `account` CHANGE `email` `email` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
if ($show_alter_field) {
$field = mysql_real_escape_string($row['Field']);
echo "ALTER TABLE `$table` CHANGE `$field` `$field` $row[Type] CHARACTER SET $character_set COLLATE $convert_to $nullable $default; \r\n";
}
}
}
?>
Make sure to edit in your proper username and passwd and stuff and do a backup before running the output of this script.
Kudos to whoever wrote this, it has saved me much time.
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
I have installed recently Zen Cart and follow the instructions for installing the Japanese Pack given on srw2d.com and made the utf8 encoding conversions. The only thing I might have made wrong is that I have overwritten the files: admin/index.php, admin/invoice.php, includes/modules/payment/paypal.php, includes/functions/functions_general.php, includes/classes/order.php after installing Zen cart in English. I don't know if the order is important?
Every things seems to work fine except the Japanese informations in the admin customers panel (next to modules). The characteres are strange, for example 田中 (Tanaka) become 縺輔→縺ソ . In my SQL Data base the names and address are written correctly in Japanese and I hope that there would not be any problem during the payment?
Any suggestion to correct that problem? I have read all this thread to find a solution but I couldn't find it.
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
@ kiddo:
Sorry for my late response, I was on holiday so hadn't checked back for a while.
Thank you very much for the script! I will use it later on the week and report back on how it went!
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Quote:
Originally Posted by
jvanree
I am maintaining a few zen cart stores for my boss. Within these stores we have german language installed. German language contains a lot of umlaut characters, which are not displayed well in the product information or in the product titles in the menu.
I solved the same problem with this thread's help.
As my database was already online I followed these steps to convert it to UTF-8:
- Complete export of database from phpmyadmin (including Add DROP TABLE / VIEW / PROCEDURE / FUNCTION setting)
- Then export file editing to change every instances of CHARSET=latin1 to CHARSET=utf8
- Import of modified file to recreate database from scratch with every previous content (but in utf8)
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
@ moosesoom.. Thank you very much for your answer!!
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Quote:
Originally Posted by
moosesoom
I solved the same problem with this thread's help.
As my database was already online I followed these steps to convert it to UTF-8:
- Complete export of database from phpmyadmin (including Add DROP TABLE / VIEW / PROCEDURE / FUNCTION setting)
- Then export file editing to change every instances of CHARSET=latin1 to CHARSET=utf8
- Import of modified file to recreate database from scratch with every previous content (but in utf8)
Hello Moosemoon,
Could you write of resume of the steps to follow for an already installed Zen-Cart 1.38 shop.
Thank you.
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Having 1.3.9a installed and you code don't work for me maybe my file are never could you help me to fix it..to utf8 thanks to every body..
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
NOTE:
With v1.3.9 you don't have to touch the query_factory.php file.
You should use this method instead: http://www.zen-cart.com/forum/showthread.php?t=153582
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Hi DrByte,
Sorry, I have been busy. We just put out our own open source project, http://mediafront.org/ . I am going to try and update my site with the correct info this coming week. The whole site actually.
Thanks for taking over the thread there Dr.
-Shaun
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Hi Everyone,
I am new to ZenCart, i am looking to install Japanese to the site, can anyone comment on which of the two JP Language Pack is the best to use?
CrystalKoi or the one from the Japanese ZenCart page?
japanese_localization_pack_based_on_zencarv_zencartv1-3-0-2l10njp1
Or should i donwload direct from the Japanese website?
PS...does the latest version of Zen-Cart need to be configured for UTF8 still?
Thanks,
Richard
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Quote:
Originally Posted by
DrByte
Thank you Dr Byte!
There is also a note in that post:
Quote:
NOTES:
- This is only applicable to v1.3.9x. It will NOT work in older versions, and is not applicable to the future version v2.x.
Future v2.x. will support utf8 won't it? Probably using another method...
Anyway, these are the steps I have followed to make zen-cart-1.3.9e work with utf8 characters:
- 1->I created my database and user.
2->From phpMyAdmin->Operations.
I changed Collation to "utf8_general_ci", and then I hit "Go".
Optionally, "perfection maniacs" can try the following guide:
http://journal.suteki.nu/2008/12/25/...configuration/
- zc_install/includes/installer_params.php
* Before installing *
I adjusted the relevant entry
Code:
// optionally set this to 'utf8':
define('DB_CHARSET', 'utf8');
- includes/extra_configures/my_db_charset.php
admin/includes/extra_configures/my_db_charset.php
I created the above mentioned directories and files that contain the following code:
Code:
<?php define('DB_CHARSET', 'utf8');
- I followed the renowned guide except for the part regarding the query_factory.php file :
http://www.srw2d.com/content/databas...tion-important
- For Greek language, I downloaded the "Greek language pack"
http://www.zen-cart.com/index.php?ma...oducts_id=1316
I adjusted the relevant files according to the above mentioned guide but I also had to convert the .php files using the following command adjusted in a small bash script:
(I am using Linux, preferably Gentoo)
Code:
iconv --from-code=ISO-8859-7 –to-code=UTF-8 "iso.file" > "utf.file"
Code:
n=1
find ./ -name '*.php' -type f | sort | {
while read files; do
echo "$files"
fullpath=`dirname "$files"`
filename=`basename "$files"`
new_filename=utf__encoded_$filename
echo $fullpath/utf_$filename
iconv --from-code=ISO-8859-7 --to-code=UTF-8 $files > $fullpath/$new_filename
mv $fullpath/$new_filename $fullpath/$filename
echo "$n"
let "n += 1"
done
}
:clap: Now, everything seems to be working great! :clap:
Thank you for your help converting to utf8!
Kind regards,
orange_juice
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Hi. I keep having "cold feet" about what seems to be a straightforward process of converting a database. I thought I had selected all the options to set up a database using UTF8, but after the database was created and I had configured my cart, I saw that most of the files were in latin1_swedish_ci. It appears that changing the collation and entering UTF8 in the boxes that appear in PHPMyAdmin does not actually change the underlying type of the file in PHPMyAdmin.
I find this not adequately explained, even though processes have been detailed on this thread for changing the latin1 to UTF8. I keep puzzling about whether every single latin1 instance is actually detrimental to the smooth operation of the cart, and am concerned that latin1 is 1/3 the size of a UTF8 character and is a space-saver that would in theory speed up a cart.
While I have not fully digested the below, I feel others who are puzzling over this conversion may find these articles of interest. I would be interested in any comments from persons who actually do understand these articles fully, as to (1) why latin1 would not be fine for -- say -- the latin languages, and (2) why some tables could not easily be in latin 1, for example, if one did not need Admin files to be in another language.
This quoted section is from a discussion of the mysql group at [email protected], which came my way in an email from the mysql group on 8/10/10:
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Your post sounds like you're not actually *needing* UTF8 support. So, why are you dabbling?
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Dr. Byte,
Thanks for your comment. Please remove my off-topic post.
I hope to add a Spanish Language Pack to my site. I guess I had better just roll up my sleeves and follow the instructions here and stop worrying about my lack of understanding of MySql.
Believe it or not, your comment helps quite a lot.
Notageek
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
I followed the steps in Post 88 posted by moosesoom in this thread, since my cart was already set up, and the procedure worked beautifully.
Moosesoom stated:
Quote:
I solved the same problem with this thread's help.
As my database was already online I followed these steps to convert it to UTF-8:
1. Complete export of database from phpmyadmin (including Add DROP TABLE / VIEW / PROCEDURE / FUNCTION setting)
2. Then export file editing to change every instances of CHARSET=latin1 to CHARSET=utf8
3. Import of modified file to recreate database from scratch with every previous content (but in utf8)
The instruction to check DROP TABLE/VIEW/PROCEDURE/FUNCTION as well as keep the other items which are checked by default in the PHPMyAdmin Export procedure was a critical instruction.
COLLATE=latin1 and COLLATE latin1 also needed to be replaced, but a global search and replace in Notepad++ replaced all of the latin1 occurrences with utf8. My latin1 version was latin1_general_ci (not latin1_swedish_ci), so that fit in with just a replacement of latin with utf8.
I accepted the default name _DB_ on export, selected "save as file" and then after the search and replace named the file to import the same name as the exported file, having been reminded recently that was necessary for the import to succeed.
To be sure the prior table would not interfere with the new table, I dropped the tables, all of which had remained in the database, before importing the changed file.
I mention the above extra detail because someone asked moosesoom to describe the steps in more detail. People more familiar with PHPMyAdmin would automatically know the above.
My site is FASTER now, really noticeably faster.
Thanks to moosesoom and also to Dr. Byte who is always so "on target."
I really thought changing the latin1 would be a fundamental change in the database that would slow my site down, but this is a simple word-replacement procedure that improved the site's speed.
Notageek
-
Re: UTF-8 Zen-Cart Tutorial for v1.3.x
Your speed improvements are likely a result of deleting and restoring your data, more than changing the collation method. Similar performance gains could be accomplished using the Optimize Tables approach to tidy the database.