Usando la función gettext()

Volver.

Seleccione idioma para esta página

Castellano

Inglés

ninguno


locale actual: es_ES

Indique el código de idioma:


Ella vestía una falda de color azul.

Este archivo


<?php
session_start
();
if (
$_GET['language']) $_SESSION['language'] = $_GET['language'];
if (!
array_key_exists('language',$_SESSION))$_SESSION['language'] = 'es_ES';
$locale setlocale(LC_ALL$_SESSION['language']);
bindtextdomain('ejemplo''./locale');
textdomain('ejemplo');
?>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo _('Usando la función gettext()'); ?></title>
</head><body>
<h1><?php echo _('Usando la función gettext()'?></h1>
<p align="right"><a href="../"><?php echo _('Volver') , '.'?></a></p>
<p><?php echo _('Seleccione idioma para esta página'?></p>
<form method="get" action="index.php">
<p><input type="radio" name="language" value="es_ES" <?php if ($_SESSION['language'] =='es_ES') echo 'checked' ?> /> <?php echo _('Castellano'?></p>
<p><input type="radio" name="language" value="en_US" <?php if ($_SESSION['language'] =='en_US') echo 'checked' ?>/> <?php echo _('Inglés'?></p>
<p><input type="radio" name="language" value="xx" <?php if ($_SESSION['language'] =='xx') echo 'checked' ?>/> <?php echo _('ninguno'?></p>
<input type="submit" name="submit" value="<?php echo _('Aceptar'?>" />
</form>
<hr />
<p><?php echo _('locale actual: '),$locale;?></p>
<form method="get" action="index.php">
<p><?php echo _('Indique el código de idioma: ')?><input type="text" name="language">
<input type="submit" name="submit" value="<?php echo _('Aceptar'?>" /></p>
</form>
<hr />
<?php printf(_('Ella vestía una %1$s de color %2$s.'),_('falda'),_('azul')); ?>
<hr />
<h3><?php echo _('Este archivo'?></h3>
<pre><?php highlight_file('index.php'); ?></pre>
<hr />
<h3><?php echo _('Archivo de traducciones'?></h3>
<pre><?php
$poFile 
='./locale/' $_SESSION['language'] . '/LC_MESSAGES/ejemplo.po';
if (
file_exists($poFile)) readfile($poFile) ; else echo _('no hay'); ?></pre>
</body></html>


Archivo de traducciones

no hay