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);
 }
Example #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));
     }
 }
Example #3
0
File: user.php Project: 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);
Example #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"));
function T_pgettext($context, $msgid)
{
    if (_check_locale_and_function('pgettext')) {
        return pgettext($context, $msgid);
    } else {
        return _pgettext($context, $msgid);
    }
}
Example #8
0
File: u.php Project: 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();
/**
 * 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;
}
Example #10
0
File: admin.php Project: 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>
Example #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>
Example #12
0
?>
		<br />
		<?php 
echo pgettext("PasswordResetInfo", "Please insert the token from the email and your new password:"******"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>
Example #13
0
File: user.php Project: 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();
Example #14
0
File: index.php Project: 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();
Example #15
0
File: main.php Project: 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 
Example #16
0
File: admin.php Project: 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();
/**
 * 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);
}
Example #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");
Example #19
0
File: user.php Project: 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>
Example #20
0
/**
 * Alias for pgettext.
 *
 * \param $ctx
 * \param $str
 * \see pgettext
 */
function C_($ctx, $str)
{
    return pgettext($ctx, $str);
}
Example #21
0
File: login.php Project: 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 
}
Example #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();