DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • December 12, 2017, 07:55:16 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1] 2   Go Down
  Print  
Author Topic: Translation Question  (Read 14738 times)
0 Members and 1 Guest are viewing this topic.
lonnyl
Guest
« on: October 13, 2004, 06:47:20 AM »

Ok.... so I have gotten the news and output ready for translation on many of my modules....

I would assume that addnav would also need some similar treatment, however in my experimenting I have yet to get that clear as to how to go about it....

Some clarification on this issue by someone in the know would be greatly appreciated..

I am also not entirely clear on what this would not be acceptable for translation as the value would be passed prior to going to the output funcion. Or so I believe.

Code:
output("This is a test of the value of ".$variable."  for output.");
« Last Edit: October 16, 2004, 12:12:23 PM by Kendaer » Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #1 on: October 13, 2004, 07:01:02 AM »

Code:
output("This is a test of the value of ".$variable."  for output.");
I suppose you could do as usual:
Code:
output("This is a test of the value of %s for output.",$variable);

No hints on your first question  Embarrassed
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
lonnyl
Guest
« Reply #2 on: October 13, 2004, 07:11:12 AM »

Oh... I know the second one works.... not quite getting why my example doesn't as the variable should be processed into the string BEFORE being passed to the output function......
Logged
lonnyl
Guest
« Reply #3 on: October 13, 2004, 07:16:13 AM »

I also was looking at system mail.... as well... is there any translation I need to worry about with that... as in the giftshop module?
Logged
Kendaer
Guest
« Reply #4 on: October 13, 2004, 07:34:10 AM »

for addnav, here's an example (taken from one of saucy's mods)

Code:
addnav(array("C?Chef's Special (`^%s gold`0)",$mealcost), "runmodule.php?module=kitchen&op=meal");

For mail, I'll defer to Anpera for the final reply since he's doing that work.  The answer is, yes, you will need to make changes if you are substituting in values (like say a price or something like that) which shouldn't be translated.

The solution is much like the addnav however, in that you would pass an array as the subject or body.
For example, from being killed in a location, the subject passed to the mail is now

Code:
array("You were killed in %s", $session['user']['location'])
rather than what it used to be of
Code:
"You were killed in " . $session['user']['location']

Hope that gets you on the right track.
The framework for the mail translation stuff will be in pre-9 when I get it out at the end of this week (which means you cannot look at existing code (yet)).

For the addnav, there are many instances in the code which show the use Smiley

Logged
lonnyl
Guest
« Reply #5 on: October 13, 2004, 07:37:16 AM »

Ahhh..... I missed the array thing.... that makes sense now.....

(Lights go on in my head..... )  Grin
Logged
lonnyl
Guest
« Reply #6 on: October 13, 2004, 07:59:51 AM »

Ok.... so would I be right in thinking that the following
Code:
output($row['level']);
Should be
Code:
output("%s",$row['level']);
Logged
lonnyl
Guest
« Reply #7 on: October 13, 2004, 08:12:37 AM »

And here I go with another...... seeing as I want none of the following code translated.. could this be a viable solution...
Code:
output("<tr class='".($i%2?"trlight":"trdark")."'><td><a href='runmodule.php?module=thecell&op=send3&user=".$row['acctid']."'>",true);
changed to this
Code:
$linkcode = "<tr class='".($i%2?"trlight":"trdark")."'><td><a href='runmodule.php?module=thecell&op=send3&user=".$row['acctid']."'>";
output("%s",$linkcode,true);
or
Code:
output(array("%s","<tr class='".($i%2?"trlight":"trdark")."'><td><a href='runmodule.php?module=thecell&op=send3&user=".$row['acctid']."'>"),true);
Logged
lonnyl
Guest
« Reply #8 on: October 13, 2004, 08:50:14 AM »

Well... answered my own questions....

output("%s",$row['level']);
and
$linkcode = "<tr class='".($i%2?"trlight":"trdark")."'><td><a href='runmodule.php?module=thecell&op=send3&user=".$row['acctid']."'>";
output("%s",$linkcode,true);

appear to be the correct answers...
Logged
lonnyl
Guest
« Reply #9 on: October 13, 2004, 08:51:31 AM »

Now I am assuming that the second part of addnav is NOT translated hence this would be ok?

Code:
addnav("","runmodule.php?module=pqgiftshop3&op=send&op2=".get_module_setting($currentgift)."&price=". get_module_setting($currentprice));
Logged
anpera
Guest
« Reply #10 on: October 13, 2004, 08:51:37 AM »

We want all systemmails and emails to appear in the language of the recipient and not in the language of the sender.

Therefor systemmails are using arrays for subject and body now and can be translated by the recipients in their inbox. Like Kendaer said, a typical translatable systemmail call in Pre.9 would be
Code:
systemmail($recipientsacctid,array("Mail subject"),array("Mail body from %s",$sendername));

for example.
Note that we don't allow the translation of non-array subjects and bodies, to keep people (and the engine of course) from trying to translate private YoMs, so you'll have to use an array even if there is no real need for it. (See subject of example.)



To send translated email we have a new function called "translate_mail". It allows translation into the language of the recipient and is used like translate_inline(). The only difference is that you'll have to give the acctid of the recipient so that the function can find the right language. (If no acctid is given, translate_mail translates into default language.) A typical call for sending translation ready email would be:
Code:
$subject = translate_mail("This is the subject",$recipientsacctid);
$body = translate_mail(array("This is the body for %s from %s",$recipientname,$sendername),$recipientsacctid);
mail($to,$subject,$body,"From: ".getsetting("gameadminemail","postmaster@localhost");

For email notifications of systemmails you don't have to care about translate_mail(). systemmail() handles this part.

Of course the recipient can't just click on little Ts in his email to translate it, so he has to cause it himself. The sender of the mail (the person who causes the mail) is able to translate the mail text into his own language via translator tool.


All files in Pre.9 that handle systemmails and email right, will have the 'flag'
// mail ready
on top of them.



To answer the question, why
Code:
output("This is a test of the value of ".$variable."  for output.");
is not translatable:

Lets assume $variable contains "dinner".
Then the text would appear as "This is a test of the value of dinner for output." in tranlator tool. So you would have to enter a new translation for every possible value of $variable.
With
Code:
output("This is a test of the value of %s for output.",$variable);
you only have to translate "This is a test of the value of %s for output." once. Smiley


Code:
output($row['level']);

should be
Code:
output_notl($row['level']);

(no need need to send a single variable without any text through the translation engine behind "output()" at all.)
and

Code:
output("<tr class='".($i%2?"trlight":"trdark")."'><td><a href='runmodule.php?module=thecell&op=send3&user=".$row['acctid']."'>",true);

should be

Code:
rawoutput("<tr class='".($i%2?"trlight":"trdark")."'><td><a href='runmodule.php?module=thecell&op=send3&user=".$row['acctid']."'>");

for it's pure HTML-code.
Wink
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #11 on: October 13, 2004, 01:58:25 PM »

Ok guys, another question about translation.
Given this line of code:
Code:
output($session['user']['name']." is a ".($session['user']['sex']?"female":"male")." character.");
The first part (username) is easy to to do:
Code:
output("%s bla bla bla",$session['user']['name']);
but how to make available both istance of the second variable ? (I know that it has only 2 instance, but it's quite annoying when you're the only one translating everything changing sex and running again through all scripts with a female char Shocked)
I bet it could't be solved this way:
Code:
output("%s is a %s character.",$session['user']['name'],$session['user']['sex']?"female":"male"));
So what is the solution, if there's any ? Or should I go through all scripts with a female char ?

thanks
Excalibur
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
anpera
Guest
« Reply #12 on: October 13, 2004, 04:24:56 PM »

Quote
Now I am assuming that the second part of addnav is NOT translated hence this would be ok?
Right. Smiley


Code:
output($session['user']['name']." is a ".($session['user']['sex']?"female":"male")." character.");

The best way I can think of would be:

Code:
$male = translate_inline("male");
$female = translate_inline("female");
output("%s is a %s character.",$session['user']['name'],($session['user']['sex']?$female:$male));
This way you get three Ts for two possible texts on one screen for the translation.
Logged
Hooptel
Guest
« Reply #13 on: October 13, 2004, 05:51:15 PM »

To keep such things as short as possible, isn't this an alternative?

Code:
output("%s is a %s character.",$session['user']['name'],translate_inline($session['user']['sex']?"female":"male"));
Logged
Kendaer
Guest
« Reply #14 on: October 13, 2004, 07:28:29 PM »

Ok.... so would I be right in thinking that the following
Code:
output($row['level']);
Should be
Code:
output("%s",$row['level']);

Actually, this would be better as output_notl($row['level']);

It doesn't need translation at all.
Logged
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Version 1.1.2 is the current supported version and is available for download.

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
19 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search