本文整理匯總了PHP中Gettext\Translations::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translations::find方法的具體用法?PHP Translations::find怎麽用?PHP Translations::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Gettext\Translations
的用法示例。
在下文中一共展示了Translations::find方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mergeWith
/**
* Merges this translations with other translations.
*
* @param Translations $translations The translations instance to merge with
* @param int|null $method One or various Translations::MERGE_* constants to define how to merge the translations
*/
public function mergeWith(Translations $translations, $method = null)
{
if ($method === null) {
$method = self::$mergeDefault;
}
if ($method & self::MERGE_HEADERS) {
foreach ($translations->getHeaders() as $name => $value) {
if (!$this->getHeader($name)) {
$this->setHeader($name, $value);
}
}
}
$add = (bool) ($method & self::MERGE_ADD);
foreach ($translations as $entry) {
if ($existing = $this->find($entry)) {
$existing->mergeWith($entry, $method);
} elseif ($add) {
$this[] = clone $entry;
}
}
if ($method & self::MERGE_REMOVE) {
$filtered = array();
foreach ($this as $entry) {
if ($translations->find($entry)) {
$filtered[] = $entry;
}
}
$this->exchangeArray($filtered);
}
if ($method & self::MERGE_LANGUAGE) {
$language = $translations->getLanguage();
$pluralForm = $translations->getPluralForms();
if (!$pluralForm) {
if (!empty($language)) {
$this->setLanguage($language);
}
} else {
if (!empty($language)) {
$this->setHeader(self::HEADER_LANGUAGE, $language);
}
$this->setPluralForms($pluralForm[0], $pluralForm[1]);
}
}
}