I’m working on a multilanguage wp ecommerce shop. Many translations work out of the box with qtranslate and the content from the .mo and .po files.
Unfortunately there are some small problems:
shopping cart
Product name
In the shopping cart widget as well as in the fancy notification I had a product name in both languages.
I found this post: http://getshopped.org/forums/topic/how-to-create-a-multilingual-shop-with-qtranslate/#post-150551
It’s out of date, but it gave me the right hint.
Add this to your themes function.php or to your plugin:
function translateCartitemName($name,$id){ return htmlentities(stripslashes(__($name)), ENT_QUOTES, "UTF-8"); } add_filter('wpsc_cart_item_name','translateCartitemName',10,2);
Product links
The product links in the cart widget and also the cart page still point to the default language.
You can either surround each link with qtrans_convertURL() or solve the problem in general.
To fix this problem for all internal links add this to your functions.php:
add_filter('clean_url','translateUrl',20,3); function translateUrl($url, $original_url, $_context){ return qtrans_convertURL($url); }
Fancy notifications
The small popup notification as well as the sliding notification on the top of the cart widget still show all languages:
You just added "Product Name German" to your cart.
I tried to use the filters in cart.class.php in function get_title() but they have been ignored, so I used an ugly solution here:
I had to modify one of the wpsc core files.
Search the line containing the string “You just added” in wp-e-commerce/wpsc-includes/ajax.functions.php (in version 3.8.9.2 it’s line 91)
Add __() around $cart_item->get_title()
$cart_messages[] = str_replace( "[product_name]", __($cart_item->get_title()), __( 'You just added "[product_name]" to your cart.', 'wpsc' ) );
Checkout and Clear cart links
At the bottom of the cart widgets are two links, one to clear the cart, and one to the checkout page.
Both of them point to the default language, so you have to wrap them in qtrans_convertURL()
yourtheme/wpsc-cart_widget.php line 44 <td id='cart-widget-links' colspan="5"> <a target="_parent" href="<?php echo qtrans_convertURL(esc_url( get_option( 'shopping_cart_url' ) )); ?>" title="<?php esc_html_e('Checkout', 'wpsc'); ?>" class="gocheckout"><?php esc_html_e('Checkout', 'wpsc'); ?></a> <form action="" method="post" class="wpsc_empty_the_cart"> <input type="hidden" name="wpsc_ajax_action" value="empty_cart" /> <a target="_parent" href="<?php echo qtrans_convertURL(esc_url( add_query_arg( 'wpsc_ajax_action', 'empty_cart', remove_query_arg( 'ajax' ) ) )); ?>" class="emptycart" title="<?php esc_html_e('Empty Your Cart', 'wpsc'); ?>"><?php esc_html_e('Clear cart', 'wpsc'); ?></a> </form> </td>
.
Deutscher Text .
The first email immediately after the purchase is sent in the users session, so it still has the same language as selected in the shop, but if the admin changes the order state (for example after a manual payment) another email is sent to the customer and this email is in the preferred language of the admin(!!).
So the result of my tests: IT DOESN’T WORK! (Shop Styling 1.9.1)
Thanks to Daniele for pointing me the right direction. I hope to find some time to fix this in the next weeks.
Please add any issues in the comments below.
This post is a development documentation of the qtranslate integrations for WP E-commerce Shop Styling.
I’m working on a multilanguage wp ecommerce shop. Many translations work out of the box with qtranslate and the content from the .mo and .po files.
Unfortunately there are some small problems.
shopping cart
Product name
In the shopping cart widget as well as in the fancy notification I had a product name in both languages.
I found this post: http://getshopped.org/forums/topic/how-to-create-a-multilingual-shop-with-qtranslate/#post-150551
It’s out of date, but it gave me the right hint.
Add this to your themes function.php or to your plugin:
function translateCartitemName($name,$id){ return htmlentities(stripslashes(__($name)), ENT_QUOTES, "UTF-8"); } add_filter('wpsc_cart_item_name','translateCartitemName',10,2);
If you’re using the shop styling plugin you do not need this, function, because it’s already included in the plugin.
Product links
The product links in the cart widget and also the cart page still point to the default language.
You can either surround each link with qtrans_convertURL() or solve the problem in general.
To fix this problem for all internal links add this to your functions.php:
add_filter('clean_url','translateUrl',20,3); function translateUrl($url, $original_url, $_context){ return qtrans_convertURL($url); }
If you’re using the shop styling plugin you do not need this, function, because it’s already included in the plugin.
Checkout and Clear cart links
At the bottom of the cart widgets are two links, one to clear the cart, and one to the checkout page.
Both of them point to the default language, so you have to wrap them in qtrans_convertURL()
yourtheme/wpsc-cart_widget.php line 44
Emails
This part is especially for the shop styling plugin.
You can add the different languages to the email content fields using the HTML comment syntax English Text .
The first email immediately after the purchase is sent in the users session, so it still has the same language as selected in the shop, but if the admin changes the order state (for example after a manual payment) another email is sent to the customer and this email is in the preferred language of the admin(!!).
So the result of my tests: IT DOESN’T WORK! (Shop Styling 1.9.1)
Thanks to Daniele for pointing me the right direction. I hope to find some time to fix this in the next weeks.
UPDATE 2013-05-12:
I added a few improvements in the last days.
The column titles of the products table as well as the email subjects can be translated now very comfortable using the qtranslate extension plugin.
A great plugin with really simple integration.
All other texts, especially the formatted contents can be translated using shortcodes.
e. g. [ :en ]english text [ :de ]german text [ :nl ]dutch text…
There was another tricky modification:
When a user submitted his order all mails, pages and the invoice were already translated correctly, but when the admin changed the payment status an email was sent in the language of the admin.
So I had to save the user locale on order submission to the database (shown as a flag in the sales log table ) and translate the mail to this language.
Hi Hannes,
Thanks for posting this!
Did you check if the translation codes are also working for the “products table” provided by your plugin?
I spoke with Hannes, latest version of the plugin (1.9.2) translates the “product table” correctly!
THANKS
Hi Daniele,
I added a link to the development version above and I hope you can give me some feedback.
br, Hannes
Very helpful post. Your solution to Fancy Notifications no longer works, unfortunately. I can’t find where the Fancy Notifications are ANYWHERE to edit. The code is no longer in ajax.functions.php
I have searched the entire wp-e-commerce folder for “You just added”, no matches. I have searched for the ID of fancy_notification_content etc, to no avail.
Any advice?
Hi John,
I haven’t used qtranslate with wp-e-commerce for month. Sorry, I can’t help you.