Page 1 of 1

A doubt about translating with gettext

Posted: Sun Jul 31, 2011 10:54 am
by Ignatius881
Hello.

Well, I've a doubt. I know that, when you put a sentence in gettext, you can translate it into every language you want. But look at this example:

Code: Select all

echo "<B>"; echo _("Partido político creado correctamente."); echo "</B>";
echo '  '; echo _('Click'); echo ' <a href="user.php?mod=partidos">'; echo _("aquí"); echo '</a> '; echo _('para volver.'); echo '';
The text is in Spanish. Now, with this code, how should I be able to translate it into Japanese, for example? Mi doubt is related to the word order, etc.

Re: A doubt about translating with gettext

Posted: Sun Jul 31, 2011 9:33 pm
by Christopher
gettext does not translate the text. If only looks up and returns a translation related to an exiting string it knows. If it has a translation into Japanese for 'aqui' then it will return that text. If you are trying to build sentences with translated words you will have word order problems. You need to have translations of complete phrases or sentences.

Re: A doubt about translating with gettext

Posted: Tue Aug 02, 2011 5:41 pm
by Ignatius881
Well, I've found another solution. It's:

Code: Select all

echo ' <a href="user.php?mod=partidos">'._("Click aquí para volver.").'</a>'
:D

Now, I've another problem. Here is another piece of code:

Code: Select all

function duration($t) {

            if($t > 10713600)  { $d = round($t / 5356800) . ' years'; }
        elseif($t > 5356800)  { $d = '1 year'; }
        elseif ($t > 2626560) { $d = round($t / 2626560) . ' months'; }
        elseif ($t > 129600) { $d = round($t / 86400) . ' days'; }
        elseif ($t > 86400) { $d = '1 day'; }
        elseif ($t > 7200) { $d = round($t / 3600) . ' hours'; }
        elseif ($t > 3600) { $d = '1 hour'; }
        elseif ($t > 60) { $d = round($t / 60) . ' min'; }
        else { $d = $t . ' sec'; }
        return $d;
}
Well, I want to do something like this: http://www.gnu.org/s/hello/manual/gette ... forms.html

But I don't know how. Can you help me?