示例#1
0
<p>Example showing how to use PHP-gettext as a dropin replacement for the native gettext library.</p>
<?php 
print "<p>";
foreach ($supported_locales as $l) {
    print "[<a href=\"?lang={$l}\">{$l}</a>] ";
}
print "</p>\n";
if (!locale_emulation()) {
    print "<p>locale '{$locale}' is supported by your system, using native gettext implementation.</p>\n";
} else {
    print "<p>locale '{$locale}' is _not_ supported on your system, using the default locale '" . DEFAULT_LOCALE . "'.</p>\n";
}
?>

<hr />

<?php 
// using PHP-gettext
print "<pre>";
print _("This is how the story goes.\n\n");
for ($number = 6; $number >= 0; $number--) {
    print sprintf(T_n__("%d pig went to the market\n", "%d pigs went to the market\n", $number), $number);
}
print "</pre>\n";
?>

<hr />
<p>&laquo; <a href="./">back</a></p>
</body>
</html>
示例#2
0
<?php 
print "<p>";
foreach ($supported_locales as $l) {
    print "[<a href=\"?lang={$l}\">{$l}</a>] ";
}
print "</p>\n";
if (!locale_emulation()) {
    print "<p>locale '{$locale}' is supported by your system, using native gettext implementation.</p>\n";
} else {
    print "<p>locale '{$locale}' is <strong>not</strong> supported on your system, using custom gettext implementation.</p>\n";
}
?>

<hr />

<?php 
// using PHP-gettext
print "<pre>";
print T_("This is how the story goes.\n\n");
for ($number = 6; $number >= 0; $number--) {
    print sprintf(__("Address Name"));
    print sprintf(T_n__("%d  Address Name", "%d pigs went to the market\n", $number), $number);
}
print "</pre>\n";
?>

<hr />
<p>&laquo; <a href="./">back</a></p>
</body>
</html>