wyntarvox: (Default)
wyntarvox ([personal profile] wyntarvox) wrote in [site community profile] dw_dev_training2009-05-16 04:44 pm
Entry tags:

English Stripping and JavaScript

I've seen this come up a couple times in comments on Bugzilla, so I figured I'd ask here.

On a few pages that I know of, there's user-facing text that gets printed by included JavaScript files rather than in the BML files, so (unless I'm mistaken) they can't be English-stripped. Is the general procedure here to leave the copy un-stripped, but update it to be DW-consistent?

For example, manage/tags.bml uses "friends" under "counts and security" which should obviously be updated to "trusted". This would be easy to do just to manually change it, but is there perhaps a way to English strip these kinds of things?
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2009-05-16 10:48 am (UTC)(link)
I had this problem when it came to the logged-out homepage. My solution was to code it such that there was JavaScript on the page to populate some variables, and then those variables would be used in the actual script.

To show what I mean: If you look at the homepage while logged out, you'll notice this code in the source:

<script type="text/javascript">
    var ml = new Object();

    ml.joinheading = "Join Dreamwidth";
    ml.entercode   = "Enter your invite code:";
    ml.usecode     = "Use Code";
    ml.cancel      = "Cancel";


In the actual JavaScript file, I can then refer to these strings as ml.usecode and such. In the original BML, I print it like this:

        $headextra .= <<HEAD;
<script type="text/javascript">
    var ml = new Object();

HEAD
        $headextra .= "    ml.joinheading = \"" . BML::ml( ".create.join_dreamwidth",  { sitename => $LJ::SITENAMESHORT } ) . "\";\n";
        $headextra .= <<HEAD;
    ml.entercode   = "$ML{'.create.enter_code'}";
    ml.usecode     = "$ML{'.create.use_code'}";
    ml.cancel      = "$ML{'.create.cancel'}";

HEAD


Of course, you need to know how to code it this way, which limits it, really. I don't think anybody would expect someone to English-strip *this* much if they didn't know how, so it might just work to change the words. May want to ask about that though.

[edited multiple times to fix stuff. So sorry about the edit spam. :(]
Edited 2009-05-16 10:51 (UTC)
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2009-05-16 01:29 pm (UTC)(link)
Speaking just for myself, I would rather do it properly (ie, strip the javascript too, using sophie's method, which is IIRC the same way it's done in a few other places). rho and ivorygates, you want to pipe up on that?