latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Changing Words/Phrases in Generated JS

Home Forums Community Forum Changing Words/Phrases in Generated JS

This topic contains 4 replies, has 3 voices. Last updated by  Jason (Lead Developer) 3 years, 11 months ago.

Topic Author Topic
Posted: Saturday Jan 26th, 2013 at 3:26 pm #39704
terimbo
Username: scarab

Hmmm, Jason’s post about “Changing Words/Phrases In s2Member” is useful, but…

https://www.s2member.com/kb/changing-words-phrase/

As far as I can tell, s2Member wraps boatloads of text inside _x() that will never actually get translated. This occurs when the text is part of JavaScript delivered to the browser in a way that appears to suggest it is being prepped on the fly by PHP (but maybe it isn’t?).

For example, I’d like to change the JavaScript validation code’s standard error header of “— Oops, you missed something: —”. (Personally, I find this quite rude to be saying to someone who has just paid money to access a site.) Unfortunately, even though this apparently translatable text is peppered through authnet.js, paypal.js, s2member.js, etc., and even though files like these appear to be prepared and output generated on the fly by s2member-o.php, as far as I can tell none of this text ever gets translated.

(At least, filtering using the example given in Jason’s article appears to have no effect. In fact, placing a filter on gettext_with_context and var_dump-ing anything that comes through with the word ‘oops’ in it yields nothing.)

Am I wrong about this? I hope so!

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Tuesday Jan 29th, 2013 at 7:19 pm #39944
Bruce
Username: Bruce
Staff Member

Thank-you for your inquiry.

This post details how to change this text.

Please let us know if problems persist.

Posted: Wednesday Jan 30th, 2013 at 5:06 am #39997
terimbo
Username: scarab

Hi Bruce,

Yes, I’m aware of how to do it — if you’ve had a look, you’ll know that the post I mentioned and the post you mentioned are talking about the exact same technique.

However, what I am saying is that it appears that the relevant bits of JavaScript responsible for the “oops” message are not being translated at all.

In case you still don’t believe me, let me spell it out further…

The relevant JavaScript for the user profile form is delivered by /s2member/s2member-o.php. Visit the user profile page, look in the page headers, and grab the exact URL being used to retrieve the JS via s2member-o.php for that specific page. (There are two references to that file, one for CSS and one for JS; you want the JS.) Paste that URL into your browser’s address bar and look at the code which is returned: “oops” is everywhere. Now if you think that the filtering technique is doing anything whatsoever when this JS is being retrieved, just place a big fat die() right at the start of the function you’re doing the gettext_with_context filtering with: that will stop WordPress dead in its tracks the moment it reaches that code. But guess what? WordPress does not stop dead in its tracks, because the relevant code is never being executed.

Note that when s2member-o.php is called directly, no WordPress code is even executing; there are no filters, no plugins, no nothing, because WordPress is not running. The file s2member-o.php chooses which bits of WordPress to fire up when it starts executing.

So, as I said in the original post, it appears that the relevant bits of JavaScript responsible for the “oops” message are not being translated at all.

  • This reply was modified 3 years, 11 months ago by  terimbo.
Posted: Saturday Feb 2nd, 2013 at 4:07 am #40337
Staff Member

Thanks for the heads up on this thread :-)

I can confirm that the following hack works properly.

Please create this directory and file:
/wp-content/mu-plugins/s2-o.php
(NOTE: these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins)
(See also: http://www.s2member.com/kb/hacking-s2member/)

/s2member/s2member-o.php handler. Other MU plugins are excluded, because s2Member is in fact in s2Member-only mode. If you need to create exceptions to this rule, please use one of these special file names.

Please let us know if problems persist :-)

Posted: Saturday Feb 2nd, 2013 at 4:09 am #40338
Staff Member
Updating this post so that it’s compatible with JS/CSS translations too — by default.
https://www.s2member.com/kb/changing-words-phrase/
Viewing 4 replies - 1 through 4 (of 4 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.