Exemplo n.º 1
0
 public function testPgettext()
 {
     if (self::$functionExists['pgettext']) {
         $this->markTestSkipped('Function pgettext already defined');
     }
     $translation = pgettext('firstContext', 'untranslated message with context');
     $this->assertEquals('untranslated message with context', $translation);
     $this->setlocaleCs();
     $translation = pgettext('firstContext', 'message with context');
     $this->assertEquals('zpráva s kontextem', $translation);
 }
Exemplo n.º 2
0
 public function domains_recordTest($domainid, $record, $type)
 {
     if (strlen($record) == 0) {
         $this->setResult();
         return;
     }
     if (($record = $this->page->domains->fixRecordName($domainid, $record)) === false) {
         return;
     }
     if (!$this->page->domains->isValidDomainName($record)) {
         $this->setResult(array('domain' => $record, 'type' => $type, 'status' => pgettext('domainRecord', 'Invalid name'), 'invalid' => true));
     } elseif (!$this->page->domains->isFreeDomain($record, $type)) {
         $this->setResult(array('domain' => $record, 'type' => $type, 'status' => pgettext('domainRecord', 'Domain taken by someone else')));
     } else {
         $this->setResult(array('domain' => $record, 'type' => $type, 'status' => pgettext('domainRecord', 'Domain available'), 'free' => true));
     }
 }
Exemplo n.º 3
0
Arquivo: user.php Projeto: rizzel/dns
 public function confirmEmailUpdate($user, $email)
 {
     $set = $this->page->db->query("UPDATE dns_users SET email = ? WHERE username = ?", $email, $user);
     if ($set->rowCount() > 0) {
         $this->page->email->sendTo($email, pgettext("emailUpdate", "password set"), sprintf(_("The password has been successfully changed for user %s."), $user));
         return TRUE;
     }
     return FALSE;
 }
/**
 * Translates the string with respect to the given context and replaces placeholders with supplied arguments.
 * If no translation is found, the original string will be used. Unlimited number of parameters supplied.
 *
 * Example: _x('Message for arg1 "%1$s" and arg2 "%2$s"', 'context', 'arg1Value', 'arg2Value');
 * returns: 'Message for arg1 "arg1Value" and arg2 "arg2Value"'
 *
 * @param string $message   String to translate
 * @param string $context   Context of the string
 *
 * @return string
 */
function _x($message, $context)
{
    $arguments = array_slice(func_get_args(), 2);
    if ($context == '') {
        return vsprintf($message, $arguments);
    } else {
        return vsprintf(pgettext($context, $message), $arguments);
    }
}
<?php

echo _('Welcome to first domain');
echo _('And second domain');
echo pgettext('yearn', 'miss');
echo pgettext('mishit', 'miss');
echo npgettext('device', 'mouse', 'mouses', 1);
echo npgettext('animal', 'mouse', 'mice', 1);
Exemplo n.º 6
0
<?php

include_once "pgettext.php";
$domain = 'messages';
$directory = dirname(__FILE__);
putenv("LANGUAGE=");
$locale = "sv_SE.utf8";
setlocale(LC_MESSAGES, $locale);
bindtextdomain($domain, $directory);
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');
foreach (array(1, 2) as $nbr) {
    printf(npgettext("body", "One heart\n", "%d hearts\n", $nbr), $nbr);
    printf(npgettext("place", "One heart\n", "%d hearts\n", $nbr), $nbr);
}
printf(pgettext("door", "Open\n"));
printf(pgettext("book", "Open\n"));
Exemplo n.º 7
0
function T_pgettext($context, $msgid)
{
    if (_check_locale_and_function('pgettext')) {
        return pgettext($context, $msgid);
    } else {
        return _pgettext($context, $msgid);
    }
}
Exemplo n.º 8
0
Arquivo: u.php Projeto: rizzel/dns
<?php

require_once __DIR__ . "/inc/page.php";
$page = new Page();
$page->setTitle(pgettext("PageTitle", "DNS - Update Response"));
$page->renderHeader();
$page->renderTemplate('sites/update.php', array());
$page->renderFooter();
Exemplo n.º 9
0
/**
 * Smarty block function, provides gettext support for smarty.
 *
 * The block content is the text that should be translated.
 *
 * Any parameter that is sent to the function will be represented as %n in the translation text,
 * where n is 1 for the first parameter. The following parameters are reserved:
 *   - escape - sets escape mode:
 *       - 'html' for HTML escaping, this is the default.
 *       - 'js' for javascript escaping.
 *       - 'url' for url escaping.
 *       - 'no'/'off'/0 - turns off escaping
 *   - plural - The plural version of the text (2nd parameter of ngettext())
 *   - count - The item count for plural mode (3rd parameter of ngettext())
 *   - domain - Textdomain to be used, default if skipped (dgettext() instead of gettext())
 *   - context - gettext context. reserved for future use.
 *
 * @param array $params
 * @param string $text
 * @link http://www.smarty.net/docs/en/plugins.block.functions.tpl
 * @return string
 */
function smarty_block_t($params, $text)
{
    if (!isset($text)) {
        return $text;
    }
    // set escape mode, default html escape
    if (isset($params['escape'])) {
        $escape = $params['escape'];
        unset($params['escape']);
    } else {
        $escape = 'html';
    }
    // set plural parameters 'plural' and 'count'.
    if (isset($params['plural'])) {
        $plural = $params['plural'];
        unset($params['plural']);
        // set count
        if (isset($params['count'])) {
            $count = $params['count'];
            unset($params['count']);
        }
    }
    // get domain param
    if (isset($params['domain'])) {
        $domain = $params['domain'];
        unset($params['domain']);
    } else {
        $domain = null;
    }
    // get context param
    if (isset($params['context'])) {
        $context = $params['context'];
        unset($params['context']);
    } else {
        $context = null;
    }
    // use plural if required parameters are set
    if (isset($count) && isset($plural)) {
        // use specified textdomain if available
        if (isset($domain) && isset($context)) {
            $text = dnpgettext($domain, $context, $text, $plural, $count);
        } elseif (isset($domain)) {
            $text = dngettext($domain, $text, $plural, $count);
        } elseif (isset($context)) {
            $text = npgettext($context, $text, $plural, $count);
        } else {
            $text = ngettext($text, $plural, $count);
        }
    } else {
        // use specified textdomain if available
        if (isset($domain) && isset($context)) {
            $text = dpgettext($domain, $context, $text);
        } elseif (isset($domain)) {
            $text = dgettext($domain, $text);
        } elseif (isset($context)) {
            $text = pgettext($context, $text);
        } else {
            $text = gettext($text);
        }
    }
    // run strarg if there are parameters
    if (count($params)) {
        $text = smarty_gettext_strarg($text, $params);
    }
    switch ($escape) {
        case 'html':
            $text = nl2br(htmlspecialchars($text));
            break;
        case 'javascript':
        case 'js':
            // javascript escape
            $text = strtr($text, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\\/'));
            break;
        case 'url':
            // url escape
            $text = urlencode($text);
            break;
    }
    return $text;
}
Exemplo n.º 10
0
Arquivo: admin.php Projeto: rizzel/dns
echo pgettext("ReferenceToDocumentationLink", "here");
?>
</a>
            <?php 
echo pgettext("ReferenceToDocumentationSuffix", ".");
?>
        </span>
        <br/>
        <label for="domainsListRecordContent"><?php 
echo pgettext("RecordAdd", "Content");
?>
:</label>
        <input type="text" id="domainsListRecordContent" size="32"/>
        <br/>
        <label for="domainsListRecordTTL"><?php 
echo pgettext("RecordAdd", "TTL");
?>
:</label>
        <input type="number" min="5" id="domainsListRecordTTL"/>
        <br/>
        <input type="button" id="domainsListRecordSubmit" value="<?php 
echo _("OK");
?>
"/>
        <input type="button" class="popupAbort" value="<?php 
echo _("Abort");
?>
"/>
    </div>
</div>
Exemplo n.º 11
0
<div>
    <h3><?php 
echo pgettext("TokenUpdate", "Update verification");
?>
</h3>

    <?php 
if ($update) {
    ?>
        <p>
            <?php 
    echo pgettext("TokenUpdate", "Update successful.");
    ?>
        </p>
    <?php 
} else {
    ?>
        <p>
            <?php 
    echo pgettext("TokenUpdate", "Update no successful.");
    ?>
        </p>
    <?php 
}
?>
    <a href="/"><?php 
echo pgettext("TokenUpdate", "Back to Home");
?>
</a>
</div>
Exemplo n.º 12
0
?>
		<br />
		<?php 
echo pgettext("PasswordResetInfo", "Please insert the token from the email and your new password:");
?>
	</p>
	<div>
		<label for="forgotten2_token"><?php 
echo pgettext("PasswordReset", "Token");
?>
:</label>
		<input type="text" id="forgotten2_token" size="64" />
		<br />
		<label for="forgotten2_password1"><?php 
echo pgettext("PasswordReset", "Password");
?>
:</label>
		<input type="password" id="forgotten2_password1" size="32" />
		<input type="password" id="forgotten2_password2" size="32" />
		<span id="user_add_nomatch" style="display: none"><?php 
echo pgettext("PasswordDiffer", "Passwords differ");
?>
</span>
		<br />
		<input type="button" id="forgotten2_submit" value="<?php 
echo pgettext("PasswordResetConfirm", "Set password");
?>
" />
	</div>
</div>
Exemplo n.º 13
0
Arquivo: user.php Projeto: rizzel/dns
<?php

// powerdns hat db backend
// tinydns
require_once __DIR__ . "/inc/page.php";
$page = new Page();
$page->setTitle(pgettext("PageTitle", "DNS - Settings"));
$page->addScript('js/dns.user.js');
$page->renderHeader();
$page->renderTemplate('sites/user.php', array());
$page->renderFooter();
Exemplo n.º 14
0
Arquivo: index.php Projeto: rizzel/dns
<?php

// powerdns hat db backend
// tinydns
require_once __DIR__ . "/inc/page.php";
$page = new Page();
$page->setTitle(pgettext("PageTitle", "DNS"));
$page->addScript('js/dns.main.js');
$page->renderHeader();
$page->renderTemplate('sites/main.php', array());
$page->renderFooter();
Exemplo n.º 15
0
Arquivo: main.php Projeto: rizzel/dns
    ?>
:</label>
		<input type="text" id="recordListPassword" size="64" />
		<br />
		<input type="button" id="recordListPasswordSubmit" value="<?php 
    echo _("OK");
    ?>
" />
		<input type="button" class="popupAbort" value="<?php 
    echo _("Abort");
    ?>
" />
	</div>
	<div id="recordListTTLPopup" class="popup" style="display: none">
		<label for="recordListTTL"><?php 
    echo pgettext("RecordModify", "TTL (s)");
    ?>
:</label>
		<input type="number" id="recordListTTL" min="5" />
		<br />
		<input type="button" id="recordListTTLSubmit" value="<?php 
    echo _("OK");
    ?>
" />
		<input type="button" class="popupAbort" value="<?php 
    echo _("Abort");
    ?>
" />
	</div>

    <?php 
Exemplo n.º 16
0
Arquivo: admin.php Projeto: rizzel/dns
<?php

// powerdns hat db backend
// tinydns
require_once __DIR__ . "/inc/page.php";
$page = new Page();
if ($page->currentUser->getLevel() != 'admin') {
    $page->redirectIndex();
}
$page->setTitle(pgettext("PageTitle", "DNS - Administration"));
$page->addScript('js/dns.admin.js');
$page->renderHeader();
$page->renderTemplate('sites/admin.php', array('ips' => $page->currentUser->getIPs()));
$page->renderFooter();
Exemplo n.º 17
0
/**
 * Translates the string with respect to the given context and replaces placeholders with supplied arguments.
 * If no translation is found, the original string will be used. Unlimited number of parameters supplied.
 * Parameter placeholders must be defined as %1$s, %2$s etc.
 *
 * Example: _x('Message for arg1 "%1$s" and arg2 "%2$s"', 'context', 'arg1Value', 'arg2Value');
 * returns: 'Message for arg1 "arg1Value" and arg2 "arg2Value"'
 *
 * @param string $message		string to translate
 * @param string $context		context of the string
 * @param string $param			parameter to be replace the first placeholder
 * @param string $param,... 	unlimited number of optional parameters
 *
 * @return string
 */
function _x($message, $context)
{
    $arguments = array_slice(func_get_args(), 2);
    return $context == '' ? _params($message, $arguments) : _params(pgettext($context, $message), $arguments);
}
Exemplo n.º 18
0
<?php

//This comment won't appear in the .pot file
echo gettext("Me too");
$apples = 2;
echo ngettext("I have %d apple", "I have %d apples", $apples);
//Example of a gettext function supporting context
echo pgettext("Noun", "Post");
echo pgettext("Verb", "Post");
/// TRANSLATORS: This should be translated as a shorthand for YEAR-MONTH-DAY using 4, 2 and 2 digits.
echo gettext("yyyy-mm-dd");
Exemplo n.º 19
0
Arquivo: user.php Projeto: rizzel/dns
	<h4>
		<?php 
    echo pgettext("DescriptionTokensHeader", "Tokens");
    ?>
	</h4>
	<p>
		<?php 
    echo pgettext("DescriptionTokens", "Changing the password or the email address requires a confirmation via a token\n            sent to your current email address.");
    ?>
		<br/>
		<?php 
    echo pgettext("DescriptionTokens", sprintf("You can either click the link in the email to verify your request or\n            copy the containing token in the field \"%s\" on this page.", _("Token to verify")));
    ?>
		<br />
		<?php 
    echo pgettext("DescriptionTokens", "The token is valid for at least one day.");
    ?>
	</p>
<?php 
} else {
    ?>
	<p>
		<?php 
    echo _("Log in, please.");
    ?>
	</p>
<?php 
}
?>
</div>
Exemplo n.º 20
0
/**
 * Alias for pgettext.
 *
 * \param $ctx
 * \param $str
 * \see pgettext
 */
function C_($ctx, $str)
{
    return pgettext($ctx, $str);
}
Exemplo n.º 21
0
Arquivo: login.php Projeto: rizzel/dns
<?php 
} else {
    ?>
    <div id="login">
        <div>
            <label for="login_name"><?php 
    echo pgettext("LoginHeading", "Login");
    ?>
:</label>
            <input type="text" id="login_name" placeholder="<?php 
    echo pgettext("LoginField", "Name / Email");
    ?>
"/>
            <input type="password" id="login_password" placeholder="<?php 
    echo pgettext("LoginField", "Password");
    ?>
"/>
            <input type="button" id="login_submit" value="<?php 
    echo pgettext("LoginField", "Login");
    ?>
"/>
        </div>
        <div>
            <a href="/vergessen.php" id="vergessen"><?php 
    echo pgettext("Menu", "Forgot password");
    ?>
</a>
        </div>
    </div>
<?php 
}
Exemplo n.º 22
0
<?php

require_once __DIR__ . "/inc/page.php";
$page = new Page();
$page->setTitle(pgettext("PageTitle", "DNS - Forgot password"));
$page->addScript('js/dns.forgotten.js');
$page->renderHeader();
$page->renderTemplate('sites/vergessen.php', array());
$page->renderFooter();