DragonPrime - LoGD Resource Community

LotGD Around the World - Language and Translation Support => Translation Assistance => Topic started by: lonnyl on October 13, 2004, 06:47:20 AM



Title: Translation Question
Post by: lonnyl 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.");


Title: Re:Translation Question
Post by: Excalibur 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  :-[


Title: Re:Translation Question
Post by: lonnyl 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......


Title: Re:Translation Question
Post by: lonnyl 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?


Title: Re:Translation Question
Post by: Kendaer 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 :)



Title: Re:Translation Question
Post by: lonnyl on October 13, 2004, 07:37:16 AM
Ahhh..... I missed the array thing.... that makes sense now.....

(Lights go on in my head..... )  ;D


Title: Re:Translation Question
Post by: lonnyl 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']);


Title: Re:Translation Question
Post by: lonnyl 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);


Title: Re:Translation Question
Post by: lonnyl 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...


Title: Re:Translation Question
Post by: lonnyl 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));


Title: Re:Translation Question
Post by: anpera 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. :)


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.
;)


Title: Re:Translation Question
Post by: Excalibur 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 :o)
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


Title: Re:Translation Question
Post by: anpera 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. :)


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.


Title: Re:Translation Question
Post by: Hooptel 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"));


Title: Re:Translation Question
Post by: Kendaer 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.


Title: Re:Translation Question
Post by: Kendaer on October 13, 2004, 07:30:47 PM
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...

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

Since that neither needs translation NOR to be run through the internal color/newline/bold filters.


Title: Re:Translation Question
Post by: Kendaer on October 13, 2004, 07:44:48 PM
Obviously I should have read through Anpera's replies before posting my own as he said pretty much the same things as I did :)

As to the
output("%s is a %s", $session['user']['name'], $session['user']['sex']?translate_inline("female"):translate_inline("male"));

There are two ways to do that.  One is as you saw above.  This works well for languages which don't carry the gender throughout the entire sentance.  However, it's possible that there are languages which do, or languages which have similar problems for prepositions.

For those, you will often have to run through the scripts twice because we haven't been perfectly consistant.  The way to do it so that ALL of it would be able to be translated at one go would be.
(I'm going to use an example with a pronoun below because those often do cause endings to change to be gender specific)

Code:
$male = translate_inline("%s is a male and his class is %s");
$female = translate_inline("%s is a female and her class is %s");
if ($session['user']['sex']) {
     output_notl($female, $session['user']['name'], $session['user']['race']);
} else {
     output_notl($male, $session['user']['name'], $session['user']['race']);
}

Doing it this way would result in two translator icons when you hit the page as either gender character.  Unfortunately that's not possible to do throughout the code, specifically in dealing with taunts and the substitute function, so a lot of the code actually looks more like
Code:
if ($session['user']['sex']) {
     output("%s is a female and her class is %s", $session['user']['name'], $session['user']['race']);
} else {
     output("%s is a male and his class is %s", $session['user']['name'], $session['user']['race']);
}
which will only output either the male or female translation.

Yes, this is a pain in the ass.

However! there is light at the end of the tunnel.

We intend at some point to have any non-translated string added to a table of 'to be translated' strings the first time it's encountered.  That means that you can have a bunch of players just go through and hit various pages during a 'beta' phase and you can then go through and translate anything they happen to hit which wasn't translated EVEN if the person who hit it wasn't a translator.

Basically, the translate function will just add the string to a table if it finds a string that it doesn't have a mapping for.  Very simple and clean.

However, this hasn't been written yet, so while it's coming, it's not there yet, and I don't know when it will be.


Title: Re:Translation Question
Post by: Excalibur on October 14, 2004, 12:51:39 AM
Thank you all for the enlightning you made upon the translation  :)


Title: Re:Translation Question
Post by: sixf00t4 on October 14, 2004, 04:30:31 AM
good stuff in this thread.


Title: Re:Translation Question
Post by: lonnyl on October 14, 2004, 05:45:27 AM
Very  good stuff... however means that I still have to work to do on translation readiness....


Title: Re:Translation Question
Post by: lonnyl on October 14, 2004, 09:12:39 AM
Ok and a summary of what we have learned here... excluding the mail parts as they are not released yet (pre-9)

output for simple variables
Code:
output("This is a test of the value of %s for output.",$variable);

output for multiple simple variables
Code:
output("This is a test of the value of %s and %s and %s for output.",$variable,$variable2,$variable3);

output of only a variable
Code:
output_notl($variable);

outputing he/she variable switches
Code:
output("%s is a %s character.",$session['user']['name'],translate_inline($session['user']['sex']?"female":"male"));
or
Code:
$male = translate_inline("male");
$female = translate_inline("female");
output("%s is a %s character.",$session['user']['name'],($session['user']['sex']?$female:$male));
or
Code:
if ($session['user']['sex']) {
    output("%s is a female and her class is %s", $session['user']['name'], $session['user']['race']);
} else {
    output("%s is a male and his class is %s", $session['user']['name'], $session['user']['race']);
}

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

output of mixed html and color codes etc....
Code:
$linkcode="<a href=\"runmodule.php?module=pqgiftshop&op=send&op2=".get_module_setting($currentgift)."&price=". get_module_setting($currentprice)."\"><span style=\"color: rgb(0, 204, 204);\">`3".get_module_setting($currentgift)." - ".get_module_setting($currentprice)." gold</span></a><br>";
output("%s",$linkcode,true);

addnav with variable
Code:
addnav(array("%s's Gift Shop",get_module_setting('gsowner')), "runmodule.php?module=pqgiftshop");

The link part of addnav is not translated hence can be done as in the past...

addnews works same as output with the exception that HTML will now work....

Hopefully I have hit on everything.....


Title: Re:Translation Question
Post by: lonnyl on October 16, 2004, 05:21:03 AM
Ok... Page Header???  Translation???? I am assuming yes.. and if so then I suppose I have some further translation work to do....


Title: Re:Translation Question
Post by: Kendaer on October 16, 2004, 12:14:39 PM
The page_header() function works just like the output function

Example from bio.php
Code:
page_header("Character Biography: %s", full_sanitize($row['name']));


Title: Re:Translation Question
Post by: Excalibur on October 31, 2004, 04:17:32 PM
Another question  ;D
How could I make this translation ready, avoiding all the js text ?
The lone of code is:
Code:
output("<form action='forest.php?op=number6bis' method='POST'><input name='number' value='0'><input type='submit' class='button' value='Choose Number'>",true);
I've tried this:
Code:
rawoutput("<form action='forest.php?op=number6bis' method='POST'><input name='number' value='0'><input type='submit' class='button' value='"):

output("Choose Number");

rawoutput("'>");
but it doesn't work properly (it messes up all the box/text)
I've tried also with output_notl in place of rawoutput but it's worst  ;D

Any suggestion ?

Thanks Excalibur


Title: Re:Translation Question
Post by: Kendaer on October 31, 2004, 09:50:22 PM
Here is how it's typically done in the current code

Code:
$choosenum = translate_inline("Choose Number");
rawoutput(<form action='forest.php?op=number6bis' method='POST'><input name='number' value='0'><input type='submit' class='button' value='$choosenumber'>");


Title: Re:Translation Question
Post by: Excalibur on November 01, 2004, 01:35:47 AM
As usual, thanks Kendaer  :D

© 2017 DragonPrime - LoGD Resource Community
Email Talisman: talisman -at- gmail.com
&oeXs)2U7=V BmܲV.U e=;p\}eG )Jj} C5EH7ˤH=j } mo|*Ŋw{drV_@IV>/- TFQJ׀̀Ve}l1,V O iNYx͘$e$;
Forums: Powered by SMF 1.1.21 | SMF © 2006-2007, Simple Machines