本文整理汇总了PHP中TranslationPeer::doSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationPeer::doSelect方法的具体用法?PHP TranslationPeer::doSelect怎么用?PHP TranslationPeer::doSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationPeer
的用法示例。
在下文中一共展示了TranslationPeer::doSelect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateFileTranslation
function generateFileTranslation($languageId = '')
{
$translation = array();
$translationJS = array();
if ($languageId === '') {
$languageId = defined('SYS_LANG') ? SYS_LANG : 'en';
}
$c = new Criteria();
$c->add(TranslationPeer::TRN_LANG, $languageId);
$c->addAscendingOrderByColumn('TRN_CATEGORY');
$c->addAscendingOrderByColumn('TRN_ID');
$tranlations = TranslationPeer::doSelect($c);
$cacheFile = PATH_LANGUAGECONT . "translation." . $languageId;
$cacheFileJS = PATH_CORE . 'js' . PATH_SEP . 'labels' . PATH_SEP . $languageId . ".js";
foreach ($tranlations as $key => $row) {
if ($row->getTrnCategory() === 'LABEL') {
$translation[$row->getTrnId()] = $row->getTrnValue();
}
if ($row->getTrnCategory() === 'JAVASCRIPT') {
$translationJS[$row->getTrnId()] = $row->getTrnValue();
}
}
try {
if (!is_dir(dirname($cacheFile))) {
G::mk_dir(dirname($cacheFile));
}
if (!is_dir(dirname($cacheFileJS))) {
G::mk_dir(dirname($cacheFileJS));
}
$f = fopen($cacheFile, 'w+');
fwrite($f, "<?php\n");
fwrite($f, '$translation =' . 'unserialize(\'' . addcslashes(serialize($translation), '\\\'') . "');\n");
fwrite($f, "?>");
fclose($f);
$json = new Services_JSON();
$f = fopen($cacheFileJS, 'w');
fwrite($f, "var G_STRINGS =" . $json->encode($translationJS) . ";\n");
fclose($f);
$res['cacheFile'] = $cacheFile;
$res['cacheFileJS'] = $cacheFileJS;
$res['rows'] = count($translation);
$res['rowsJS'] = count($translationJS);
return $res;
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例2: generateFileTranslationMafe
public function generateFileTranslationMafe ()
{
$translation = Array ();
$c = new Criteria();
$c->add( TranslationPeer::TRN_ID, '%ID_MAFE_%', Criteria::LIKE );
$c->addAscendingOrderByColumn( 'TRN_CATEGORY' );
$c->addAscendingOrderByColumn( 'TRN_ID' );
//$c->addAscendingOrderByColumn( 'TRN_LANG' );
$tranlations = TranslationPeer::doSelect( $c );
$mafeFolder = PATH_HTML . "translations";
$cacheFileMafe = PATH_HTML . "translations" . PATH_SEP. 'translationsMafe' . ".js";
foreach ($tranlations as $key => $row) {
if ($row->getTrnCategory() === 'LABEL') {
$translation[$row->getTrnLang()][$row->getTrnId()] = $row->getTrnValue();
}
}
try {
G::verifyPath($mafeFolder, true);
if (! is_dir( dirname( $cacheFileMafe ) )) {
G::mk_dir( dirname( $cacheFileMafe ) );
}
$f = fopen( $cacheFileMafe, 'w' );
if ($f == false) {
error_log("Error: Cannot write into cacheFileMafe: $cacheFileMafe\n");
} else {
fwrite( $f, "var __TRANSLATIONMAFE = " . Bootstrap::json_encode( $translation ) . ";\n");
fclose( $f );
}
$res['cacheFileMafe'] = $cacheFileMafe;
$res['languague'] = count($cacheFileMafe);
$res['rowsMafeJS'] = count( $translation );
return $res;
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例3: run_create_poedit_file
function run_create_poedit_file($task, $args)
{
// the environment for poedit always is Development
define('G_ENVIRONMENT', G_DEV_ENV);
//the output language .po file
$lgOutId = isset($args[0]) ? $args[0] : 'en';
$countryOutId = isset($args[1]) ? strtoupper($args[1]) : 'US';
$verboseFlag = isset($args[2]) ? $args[2] == true : false;
require_once "propel/Propel.php";
require_once "classes/model/Translation.php";
require_once "classes/model/Language.php";
require_once "classes/model/IsoCountry.php";
Propel::init(PATH_CORE . "config/databases.php");
$configuration = Propel::getConfiguration();
$connectionDSN = $configuration['datasources']['propel']['connection'];
printf("using DSN Connection %s \n", pakeColor::colorize($connectionDSN, 'INFO'));
printf("checking Language table \n");
$c = new Criteria();
$c->add(LanguagePeer::LAN_ENABLED, "1");
$c->addor(LanguagePeer::LAN_ENABLED, "0");
$languages = LanguagePeer::doSelect($c);
$langs = array();
$lgIndex = 0;
$findLang = false;
$langDir = 'english';
$langId = 'en';
foreach ($languages as $rowid => $row) {
$lgIndex++;
$langs[$row->getLanId()] = $row->getLanName();
if ($lgOutId != '' && $lgOutId == $row->getLanId()) {
$findLang = true;
$langDir = strtolower($row->getLanName());
$langId = $row->getLanId();
}
}
printf("read %s entries from language table\n", pakeColor::colorize($lgIndex, 'INFO'));
printf("checking iso_country table \n");
$c = new Criteria();
$c->add(IsoCountryPeer::IC_UID, NULL, Criteria::ISNOTNULL);
$countries = IsoCountryPeer::doSelect($c);
$countryIndex = 0;
$findCountry = false;
$countryDir = 'UNITED STATES';
$countryId = 'US';
foreach ($countries as $rowid => $row) {
$countryIndex++;
if ($countryOutId != '' && $countryOutId == $row->getICUid()) {
$findCountry = true;
$countryDir = strtoupper($row->getICName());
$countryId = $row->getICUid();
}
}
printf("read %s entries from iso_country table\n", pakeColor::colorize($countryIndex, 'INFO'));
if ($findLang == false && $lgOutId != '') {
printf("%s \n", pakeColor::colorize("'{$lgOutId}' is not a valid language ", 'ERROR'));
die;
} else {
printf("language: %s\n", pakeColor::colorize($langDir, 'INFO'));
}
if ($findCountry == false && $countryOutId != '') {
printf("%s \n", pakeColor::colorize("'{$countryOutId}' is not a valid country ", 'ERROR'));
die;
} else {
printf("country: [%s] %s\n", pakeColor::colorize($countryId, 'INFO'), pakeColor::colorize($countryDir, 'INFO'));
}
if ($findCountry && $countryId != '') {
$poeditOutFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $langDir . PATH_SEP . MAIN_POFILE . '.' . $langId . '_' . $countryId . '.po';
} else {
$poeditOutFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $langDir . PATH_SEP . MAIN_POFILE . '.' . $langId . '.po';
}
printf("poedit file: %s\n", pakeColor::colorize($poeditOutFile, 'INFO'));
$poeditOutPathInfo = pathinfo($poeditOutFile);
G::verifyPath($poeditOutPathInfo['dirname'], true);
$lf = "\n";
$fp = fopen($poeditOutFile, 'w');
fprintf($fp, "msgid \"\" \n");
fprintf($fp, "msgstr \"\" \n");
fprintf($fp, "\"Project-Id-Version: %s\\n\"\n", PO_SYSTEM_VERSION);
fprintf($fp, "\"POT-Creation-Date: \\n\"\n");
fprintf($fp, "\"PO-Revision-Date: %s \\n\"\n", date('Y-m-d H:i+0100'));
fprintf($fp, "\"Last-Translator: Fernando Ontiveros<fernando@colosa.com>\\n\"\n");
fprintf($fp, "\"Language-Team: Colosa Developers Team <developers@colosa.com>\\n\"\n");
fprintf($fp, "\"MIME-Version: 1.0 \\n\"\n");
fprintf($fp, "\"Content-Type: text/plain; charset=utf-8 \\n\"\n");
fprintf($fp, "\"Content-Transfer_Encoding: 8bit\\n\"\n");
fprintf($fp, "\"X-Poedit-Language: %s\\n\"\n", ucwords($langDir));
fprintf($fp, "\"X-Poedit-Country: %s\\n\"\n", $countryDir);
fprintf($fp, "\"X-Poedit-SourceCharset: utf-8\\n\"\n");
printf("checking translation table\n");
$c = new Criteria();
$c->add(TranslationPeer::TRN_LANG, "en");
$translation = TranslationPeer::doSelect($c);
$trIndex = 0;
$trError = 0;
$langIdOut = $langId;
//the output language, later we'll include the country too.
$arrayLabels = array();
foreach ($translation as $rowid => $row) {
$keyid = 'TRANSLATION/' . $row->getTrnCategory() . '/' . $row->getTrnId();
if (trim($row->getTrnValue()) == '') {
//.........这里部分代码省略.........
示例4: retrieveByPK
/**
* Retrieve object using using composite pkey values.
* @param string $trn_category
@param string $trn_id
@param string $trn_lang
* @param Connection $con
* @return Translation
*/
public static function retrieveByPK($trn_category, $trn_id, $trn_lang, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria();
$criteria->add(TranslationPeer::TRN_CATEGORY, $trn_category);
$criteria->add(TranslationPeer::TRN_ID, $trn_id);
$criteria->add(TranslationPeer::TRN_LANG, $trn_lang);
$v = TranslationPeer::doSelect($criteria, $con);
return !empty($v) ? $v[0] : null;
}
示例5: retrieveByPK
/**
* Retrieve object using using composite pkey values.
* @param string $language_id
* @param string $string_key
* @param PropelPDO $con
* @return Translation
*/
public static function retrieveByPK($language_id, $string_key, PropelPDO $con = null)
{
$_instancePoolKey = serialize(array((string) $language_id, (string) $string_key));
if (null !== ($obj = TranslationPeer::getInstanceFromPool($_instancePoolKey))) {
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(TranslationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria = new Criteria(TranslationPeer::DATABASE_NAME);
$criteria->add(TranslationPeer::LANGUAGE_ID, $language_id);
$criteria->add(TranslationPeer::STRING_KEY, $string_key);
$v = TranslationPeer::doSelect($criteria, $con);
return !empty($v) ? $v[0] : null;
}