Brad Fitzpatrick (bradfitz) wrote in lj_dev,
Brad Fitzpatrick
bradfitz
lj_dev

Variables in translation items

tydel just wrote me saying:
I had one question ... You say not to break up sentences, but sometimes it's not possible because there's a perl variable in the middle of a sentence, and that can't be stuck into the language file. Is that alright? You'll see what I mean in the files I'm sending if I didn't explain it clear enough.
And his file contained:
/friends/add.bml.success.text1=User
/friends/add.bml.success.text2=was added to your friend list. You can view your friends page
/friends/add.bml.success.text3=here
That's bad. Not only does it completely kill the context for the translator, but it forces the translator into a word order that's almost certainly impossible or just plain wrong in their language.

I forgot to explain variables.

What you want is:

/friends/add.bml.success.text=User (=LJUSER [[username]] LJUSER=) was added to your friend list. You can view your friends page <a href="[[url]]">here</a>.
(okay, so I added the BML tag around username, but you get my drift)

Anyway, in the BML file then:

$ret .= BML::ml("/friends/add.bml.success.text", { 'username' => $username, 'url' => $some_url });
Cool?

The complete item name is (currently) required when using BML::ml (as opposed to the shortcut you can use with the _ML tags), but I might change that. For now, though, use the long form.

Subscribe

  • cl-journal livejournal client

    Hey everyone, I'd like to present a livejournal client that I wrote to fulfill my needs but maybe there are other people that can find it…

  • SessionGenerate and ljloggedin

    Are there any information after release 86 and changes in cookies scheme to use sessiongenerate? It returns ljsession key, but this key is not enough…

  • Retrieving comments

    Hi, Is there a way to retrieve a list of comments made by user XXX (which may or may be not the currently logged in user) in the journals of users…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 8 comments