本文整理汇总了PHP中Translation::buildHashFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::buildHashFile方法的具体用法?PHP Translation::buildHashFile怎么用?PHP Translation::buildHashFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation::buildHashFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _build
//.........这里部分代码省略.........
if ($code != 200)
$this->stderr->write($lang . ": Unable to fetch Redactor language file\n");
// JQuery UI Datepicker
// http://jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-de.js
foreach ($langs as $l) {
list($code, $js) = $this->_http_get(
'http://jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-'
.str_replace('_','-',$l).'.js');
// If locale-specific version is not available, use the base
// language version (de if de_CH is not available)
if ($code == 200)
break;
}
if ($code == 200)
$phar->addFromString('js/jquery.ui.datepicker.js', $js);
else
$this->stderr->write(str_replace('_','-',$lang)
.": Unable to fetch jQuery UI Datepicker locale file\n");
// True type fonts for PDF printing
$langs = (include I18N_DIR . 'langs.php');
$info = $langs[$lang];
if (isset($info['fonts'])) {
foreach ($info['fonts'] as $name => $types) {
foreach ($types as $code => $fullname) {
list($ttf, $url) = $fullname;
if (!$url)
continue;
list($code, $file) = $this->_http_get($url);
if ($code == 200)
$phar->addFromString('fonts/'.$ttf, $file);
else
$this->stderr->write(
"*** Unable to fetch $url\n");
}
}
}
// Add in the messages.mo.php file
if ($po_file) {
$pipes = array();
$msgfmt = proc_open('msgfmt -o- -',
array(0=>array('pipe','r'), 1=>array('pipe','w')),
$pipes);
if (is_resource($msgfmt)) {
fwrite($pipes[0], $po_file);
fclose($pipes[0]);
$mo_input = fopen('php://temp', 'r+b');
fwrite($mo_input, stream_get_contents($pipes[1]));
rewind($mo_input);
require_once INCLUDE_DIR . 'class.translation.php';
$mo = Translation::buildHashFile($mo_input, false, true);
$phar->addFromString('LC_MESSAGES/messages.mo.php', $mo);
fclose($mo_input);
}
}
// Add in translation of javascript strings
$phrases = array();
if ($mo && ($js = $this->__getAllJsPhrases())) {
$mo = (eval (substr($mo, 5))); # Chop off <?php
foreach ($js as $c) {
foreach ($c['forms'] as $f) {
$phrases[$f] = @$mo[$f] ?: $f;
}
}
$phar->addFromString(
'js/osticket-strings.js',
sprintf('(function($){$.oststrings=%s;})(jQuery);',
JsonDataEncoder::encode($phrases))
);
}
// Include a manifest
include_once INCLUDE_DIR . 'class.mailfetch.php';
$po_header = Mail_Parse::splitHeaders($mo['']);
$info = array(
'Build-Date' => date(DATE_RFC822),
'Build-Version' => trim(`git describe`),
'Language' => $po_header['Language'],
#'Phrases' =>
#'Translated' =>
#'Approved' =>
'Id' => 'lang:' . $lang,
'Last-Revision' => $po_header['PO-Revision-Date'],
'Version' => (int)(strtotime($po_header['PO-Revision-Date']) / 10000),
);
$phar->addFromString(
'MANIFEST.php',
sprintf('<?php return %s;', var_export($info, true)));
// TODO: Sign files
// Use a very small stub
$phar->setStub('<?php __HALT_COMPILER();');
$phar->setSignatureAlgorithm(Phar::SHA1);
$phar->stopBuffering();
}
示例2: _dcpgettext
return TextDomain::lookup($domain)->getTranslation()->pgettext($context, $msgid);
}
function _dcpgettext($domain, $context, $msgid, $category)
{
return TextDomain::lookup($domain)->getTranslation($category)->pgettext($context, $msgid);
}
function _npgettext($context, $singular, $plural, $n)
{
return TextDomain::lookup()->getTranslation()->npgettext($context, $singular, $plural, $n);
}
function _dnpgettext($domain, $context, $singular, $plural, $n)
{
return TextDomain::lookup($domain)->getTranslation()->npgettext($context, $singular, $plural, $n);
}
function _dcnpgettext($domain, $context, $singular, $plural, $category, $n)
{
return TextDomain::lookup($domain)->getTranslation($category)->npgettext($context, $singular, $plural, $n);
}
do {
if (PHP_SAPI != 'cli') {
break;
}
if (empty($_SERVER['argc']) || $_SERVER['argc'] < 2) {
break;
}
if (empty($_SERVER['PHP_SELF']) || FALSE === strpos($_SERVER['PHP_SELF'], basename(__FILE__))) {
break;
}
$file = $argv[1];
Translation::buildHashFile($file);
} while (0);