sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)
Sophie ([personal profile] sophie) wrote in [site community profile] dw_dev_training 2009-05-16 10:48 am (UTC)

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. :(]

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting