本文整理汇总了PHP中Translation::setTranslation方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::setTranslation方法的具体用法?PHP Translation::setTranslation怎么用?PHP Translation::setTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation::setTranslation方法的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: mergeTranslation
/**
* Merge the translations of two translations.
*
* @param Translation $from
* @param Translation $to
* @param int $options
*/
public static function mergeTranslation(Translation $from, Translation $to, $options = self::DEFAULTS)
{
$override = (bool) ($options & self::TRANSLATION_OVERRIDE);
if (!$to->hasTranslation() || $from->hasTranslation() && $override) {
$to->setTranslation($from->getTranslation());
}
if (!$to->hasPlural() || $from->hasPlural() && $override) {
$to->setPlural($from->getPlural());
}
if (!$to->hasPluralTranslations() || $from->hasPluralTranslations() && $override) {
$to->setPluralTranslations($from->getPluralTranslations());
}
}