Don’t worry, Chouby. jQuery is not easy.
WP e-Commerce’s shopping cart widget currently doesn’t update when using cache plugins.
A fix it’s on its way, but in the meantime I had to add to my plugin a plain mini shopping cart placed in the side bar and a small jQuery code snippet to update it.
I hope you do find a way to detect the front end ajax requests. Besides WP e-Commerce, Theme My Login does some requests too, so if you register a new user, the process starts in the correct language but ends asking for the user registration information using the default language because of this. It’s reasonable to think that others plugins would be coded to send translated server responses too.
Regarding the work I’ve done, it has taken me long because even though it started with interfacing Polylang with WP e-Commerce, in the course of doing this I noticed and had to fix WP e-Commerce behavior not related to translations by using its hooks, provided pull requests to fix its USPS and UPS shipping modules, created shipping modules to rate 2 Mexican shipping companies (Estafeta and Redpack), and worked on a partitioning problem/3D bin packing algorithm to reduce shipping costs by combining shipment packages that fit into a shipping box that meets shipper’s restrictions.
Regarding PLL, other improvement opportunity I saw in your plugin is that the server redirect query string is not considered when forming a translated URL. I fixed this by hooking to ‘pll_translation_url’, checking and, if necessary, recreating the URL and appending this string to the end. I need that string appended to the URL because WP e-Commerce handles the customer information in “tabs”, which are identified by the server in this string.
Seeing that you have interacted with Theme My Login before, here’s the code I had to add to my plugin to fix the links translations:
function p4we_my_login_domain() {
global $l10n;
$locale = get_locale();
$mofile = WP_PLUGIN_DIR . '/theme-my-login/language/' . 'theme-my-login-' . $locale . '.mo';
if( file_exists( $mofile ) )
load_textdomain( 'default', $mofile );
}
add_action( 'plugins_loaded', 'p4we_my_login_domain', 9 ); //User links titles are read with a priority of 10 when plugins_loaded actions are applied.
function p4we_tml_user_links( $user_links ) {
foreach( $user_links as $key => $user_link ) {
$user_links[$key]['title'] = __( $user_link['title'] );
}
return $user_links;
}
add_filter( 'tml_user_links', 'p4we_tml_user_links', 11 ); //Fixes user links titles translations before they're picked up by the theme.
function p4we_tml_title( $title ) {
return __( $title );
}
add_filter( 'tml_title', 'p4we_tml_title', 11 ); //Fixes TML //Fixes TML titles translations before they're picked up by the theme.
Thank you, Chouby.