homepage Welcome to WebmasterWorld Guest from 54.196.62.132
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Help reg Ajax call (translation problem on e-commerce site)
danepak




msg:4375660
 12:01 am on Oct 18, 2011 (gmt 0)

Hi,
I’ve done an e-commerce website in English and French.
I used the free Transposh plugin for the translation, which does a fantastic job.
For the e-commerce part, I've used WP E-Commerce.
I can switch between English and French by choosing the language in a language widget.
Only two smaller problems:
If I’m in the French version and I buy something, the cart is displayed in English.
Also, when I go to the checkout page, it’s displayed in English.
I can get around both these problems by choosing French (again) as the language (in the language widget), but ideally this shouldn’t be necessary.
I’ve been told that the following has to be done:
‘…this happens because an ajax call happens, which does not take the language into account. you should probably change the params given to the button to include the ?lang=xx param’
So my question is…how do I do this? I know nothing about PHP (yet...).
It's on my 'to-do-list', to learn a bit more about it.
I'm still very new to HTML and CSS, so I take one step at a time.

 

danepak




msg:4375665
 12:16 am on Oct 18, 2011 (gmt 0)

Edit:
As long as I can get the shopping cart widget to be displayed in French, the checkout is also displayed in French.

Leosghost




msg:4375666
 12:29 am on Oct 18, 2011 (gmt 0)

I used the free Transposh plugin for the translation, which does a fantastic job.

Oh no it doesn't..but you'd maybe think so if you don't speak French :)

Their homepage has, for its first paragraph in English..
We are happy to present you all with our newest wordpress plugin release. This is a rolling release that does not include any major changes or something that is too groundbreaking. So we’ll just walk over the changelog and explain the news.



Which they translate to French using their own plugin as..

Nous sommes heureux de vous présenter le tout avec notre communiqué récent plugin WordPress. Ceci est un communiqué de roulement qui ne comprend pas de changements majeurs ou quelque chose qui est trop révolutionnaire. Alors nous allons juste marcher sur le changelog et expliquer les nouvelles.


Which would translate back to English as ( doing it word by word as they do ..which is the wrong way to do translation )..you get the following..

We are happy to present to you the all with our communication recent plugin wordpress, This is a communique of rolling which does not understand the changes major or something which is too revolutionary. So we are just going to walk on the changelog and explain the news.


The "French" is also full of grammatical errors ..which I have ignored as much as possible, otherwise it would have been impossible to re-translate it into anything resembling "English" at all..

But you'll agree that the translation of the original first short paragraph of their own website from English to French makes no sense at at all..the rest of each paragraph of their site is equally badly translated in French and the other languages that I can read..

You are building your site on very very marshy ground ..get a real translation for your texts..not auto trans rubbish..even Google translate does a better job..and a bad translation is worse than no translation at all.

Interestingly their French to English adds the word "communique" as being ( in their system's opinion ..the translation of "release" ..as in "Press release" ) whereas the word "communique" has come into English anyway ..as is ( it means the same thing in both English and French ..a "loan word" )..Neither usage by their system is correct.."nouvelle édition" or simply "édition" ( given that they had already said it was "newest") would be correct for their first use of "release"..and simply "édition" for their second use of "release"..I've "re-translated" their "inaccurate" usage twice, to demonstrate the point .

[edited by: Leosghost at 1:04 am (utc) on Oct 18, 2011]

danepak




msg:4375667
 12:29 am on Oct 18, 2011 (gmt 0)

Would it by any chance be something like this that would need to be added to the CSS?
.wpsc_buy_button_container
?lang=fr

If so, how exactly?

danepak




msg:4375678
 1:00 am on Oct 18, 2011 (gmt 0)

Hi Leosghost,

Sorry, I should have explained myself better:

I'm not using their auto translation.

Instead, on each page I use the following short codes:

[tp not_in="fr"]
English text here
[/tp]

[tp not_in="en"]
French text here
[/tp]

I agree.
I don't trust auto translators either :-)

Leosghost




msg:4375682
 1:07 am on Oct 18, 2011 (gmt 0)

But you said
I used the free Transposh plugin for the translation, which does a fantastic job.
..!

So how are you translating, if not via their awful plugin..?

btw ..I''m definitely not looking for the "gig"..just curious if it isn't via Transposh, as you said it was in your OP :)

danepak




msg:4375690
 1:43 am on Oct 18, 2011 (gmt 0)

Yes, I do use Transposh.
All other translation plugins I've tried, doesn't offer customised translation.
Well, some of them do, but far from all of them works with WP E-Commerce.
Another translation plugin, WPML, does work with WPEC, but for some reason I couldn't get it to work.

So yes, I do use Transposh, but I don't ask it to translate for me.
I already have the correct French wording.

Leosghost




msg:4375700
 2:07 am on Oct 18, 2011 (gmt 0)

You may get more chance of finding someone who uses this plugin in the wordpress forum here [webmasterworld.com...]

btw ..I notice that earlier in the thread, due to eating dinner , listening to French TV news, and posting at the same time ;-) I re-translated "roulement" above as "rolling" ..whereas the word "roulement" translates as "bearing" ..as in "roller bearing"..for "rolling", they should have used "roulant"..or "déroulement"..which can mean "roll out" or "course (of)" etc.. or even "en cours"..although no "word for word" equivalent exists.."word for word" translation is always wrong ..and usually extremely inelegant and incomprehensible..

danepak




msg:4375701
 2:14 am on Oct 18, 2011 (gmt 0)

OK, thanks.
I thought it was a PHP thing (the Ajax call).
Anyway, will ask them in there :-)

Leosghost




msg:4375706
 2:27 am on Oct 18, 2011 (gmt 0)

I thought it was a PHP thing (the Ajax call).

:)
AJAX = Asynchronous JavaScript and XML

My bold ;-)

Although wordpress is php based ..it is php for those who need it to "work out of the box", without "getting their hands dirty" with the underlying code.. ;-)

Like the bolognese / bolognaise sauce you can get ready to pour, from a bottle..it isn't the "real deal"..but it "works"..

..for those who don't mind ersatz food..

danepak




msg:4375711
 2:42 am on Oct 18, 2011 (gmt 0)

OK, thanks ;-)
Speaking of food: I actually prefer the powder bearnaise sauce that you can buy, compared to the real deal...

Leosghost




msg:4375732
 3:58 am on Oct 18, 2011 (gmt 0)

you must be a Brit :)

Béarnaise..note the é..

[edited by: Leosghost at 4:04 am (utc) on Oct 18, 2011]

danepak




msg:4375733
 4:03 am on Oct 18, 2011 (gmt 0)

I'm actually from Denmark.
And let's not get in to a discussion about what a Danish should taste like.
Let me just add that if you haven't had a Danish in Denmark yet, you've not had a proper Danish (and we're talking about the pastry here).

Leosghost




msg:4375736
 4:10 am on Oct 18, 2011 (gmt 0)

I actually figured with a nick like "danepak" you'd have to be..or a fan of Danish Dairy Marketing Board products ..:)

but the lack of the é makes one think Brit ...and Brit makes me think of Danish..I had a Danish Britt once..more than once actually..remember her fondly :)

btw..the pastry that the anglophones call Danish..we here, ( Irish in France ), call it Pâtisserie.. [en.wikipedia.org...]

danepak




msg:4375741
 4:18 am on Oct 18, 2011 (gmt 0)

Actually, I'm half Danish, half Pakistani.
And yes, you get the best take away curries in the UK, I have to admit :-)
Never tried a curry in Paris though.
(I can't believe that I'm discussing food on a web programming discussion board)

Britt...yes, typical Danish name. And a lot of Danish girls ARE very pretty.
I do miss them now and again (I've emigrated to Melbourne, Australia)

astupidname




msg:4375857
 10:11 am on Oct 18, 2011 (gmt 0)

Well, I think I found your site, apparently you've been looking to fix this for about a month or so now... :) I do not speak or understand a lick of french, being an ignorant American and all that :) So, that's out of the way, let me take a stab at a few observations I made visiting your site.
I clicked the button for french and then went blindly shopping, winding up on /summer-apparel-2/apparel/st-tropez-silk/?lang=fr where I did a quick look at source code and first noted the form's action attribute: action="http://www.{{{NAME_OF_SITE_WITHELD}}}/summer-apparel-2/apparel/st-tropez-silk/" which does not contain a "?lang=fr" url variable which may be appropriate being that the current page does. This would need fixing in the server-side code I believe. (As I write this, I have not clicked through to the next page or added to cart or anything, so just making quick observations here). Then I went hunting for javascripts and believe I found a possible trouble spot, in your "wp-e-commerce.js?ver=3.8.6.419073" javascript file, the following is found:

        // Submit the product form using AJAX
jQuery("form.product_form, .wpsc-add-to-cart-button-form").live('submit', function() {
// we cannot submit a file through AJAX, so this needs to return true to submit the form normally if a file formfield is present
file_upload_elements = jQuery.makeArray(jQuery('input[type="file"]', jQuery(this)));
if(file_upload_elements.length > 0) {
return true;
} else {
form_values = jQuery(this).serialize();
// Sometimes jQuery returns an object instead of (blah blah blah...)
if(jQuery('#fancy_notification').length == 0) {
jQuery('div.wpsc_loading_animation',this).css('visibility', 'visible');
}
jQuery.post( 'index.php?ajax=true', form_values, function(returned_data) {
eval(returned_data);
jQuery('div.wpsc_loading_animation').css('visibility', 'hidden');

if(jQuery('#fancy_notification') != null) {
jQuery('#loading_animation').css("display", 'none');
//jQuery('#fancy_notificationimage').css("display", 'none');
}

});
wpsc_fancy_notification(this);
return false;
}
});


Note the part about "jQuery.post( 'index.php?ajax=true', form_values," I am wondering if you may need to have a "lang=fr" value in there on the url being posted to, if the person is currently on a page in french? I believe you could try changing that to "jQuery.post( 'index.php?ajax=true' + ((/lang=fr/.test(window.location.search)) ? '&lang=fr' : ''), form_values,"

Although I believe the above may be most likely suspects, I also note in your "user.js?ver=3.8.6419073" javascript file you also have a "submitform" function with an ajax.post() call with a hard coded url which may need the above &lang=fr addition done to it too perhaps? Don't know for sure if you even are using that function or the above one, above one seeming the most likely suspect.
So, those are my stabs in the dark for now, hope it helps get you on track.

Damn, now I'm hungry. (gonna have me some chili!)

[All characters appearing in this work are fictitious. Any resemblance to real persons, living or dead, is purely coincidental]

danepak




msg:4375862
 10:47 am on Oct 18, 2011 (gmt 0)

Hi,

Thanks for your reply!
I really really appreciate it (trust me, I do!)

Yes, you're dead right.
I've been looking for a solution to this problem for quite a while.

I've posted this question on the WPEC forum (getshopped.org), but no one seems to know the answer (or maybe no one can be bothered answering me, ha)

I actually don't speak French either (I do kiss that way though - copied from Leslie Nielsen in Naked Gun).
However, I've done this website for a client and although she's happy with it, I still would like to fix this problem, so it's 100% perfect.

<i>I clicked the button for french and then went blindly shopping, winding up on /summer-apparel-2/apparel/st-tropez-silk/?lang=fr where I did a quick look at source code and first noted the form's action attribute: action="http://www.{{{NAME_OF_SITE_WITHELD}}}/summer-apparel-2/apparel/st-tropez-silk/" which does not contain a "?lang=fr" url variable which may be appropriate being that the current page does. This would need fixing in the server-side code I believe.</i>

There's (as far as I know) no need to add anything to the source code. It works perfectly well, when you add a product. It stays French, if French has been selected.

Your fix actually does work, but not 100%.

Please see the attached screenshots.
This one is before I added the code:
[tinypic.com...]

Not that everything is still in English (cart and the box).

Then I added your code:
[tinypic.com...]

Now it looks much better.
However, the product name itself is still in English.
So is 'Total' and 'Excludes shipping'.
And in the other box, 'Continue shopping' is also still in English.

And if I go to checkout, it takes me to the English checkout page.

If I could get it to automatically add
/checkout/?lang=fr
when I click checkout (French version), the problem would be sorted.

Enjoy the chilli!
I'm going to flick open a cold beer.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved