本文整理汇总了PHP中Translation::addReference方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::addReference方法的具体用法?PHP Translation::addReference怎么用?PHP Translation::addReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation::addReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getByRow
public static function getByRow($row)
{
$result = null;
if ($row && $row['mtID']) {
$result = new Translation($row['context'], $row['msgid'], $row['msgidPlural']);
$result->mtID = $row['mtID'];
$result->mtSectionID = $row['mtSectionID'];
$result->setTranslation($row['msgstr']);
if (isset($row['comments'])) {
foreach (explode("\n", $row['comments']) as $comment) {
$result->addExtractedComment($comment);
}
}
if ($result->hasPlural() && isset($row['msgstrPlurals'])) {
foreach (explode("", $row['msgstrPlurals']) as $pluralIndex => $plural) {
$result->setPluralTranslation($plural, $pluralIndex);
}
}
if (isset($row['reference'])) {
foreach (explode("\n", $row['reference']) as $reference) {
if ($reference !== '') {
$line = null;
$p = strrpos($reference, ':');
if ($p) {
$s = substr($reference, $p + 1);
if (preg_match('/^\\d+$/', $s)) {
$line = (int) $s;
$reference = substr($reference, 0, $p);
}
}
$result->addReference($reference, $line);
}
}
}
if (isset($row['flags'])) {
foreach (explode("\n", $row['flags']) as $flag) {
if ($flag !== '') {
$result->addFlag($flag);
}
}
}
}
return $result;
}
示例2: mergeReferences
/**
* Merge the references of two translations.
*
* @param Translation $from
* @param Translation $to
* @param int $options
*/
public static function mergeReferences(Translation $from, Translation $to, $options = self::DEFAULTS)
{
if ($options & self::REFERENCES_THEIRS) {
$to->deleteReferences();
}
if (!($options & self::REFERENCES_OURS)) {
foreach ($from->getReferences() as $reference) {
$to->addReference($reference[0], $reference[1]);
}
}
}