本文整理汇总了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]);
}
}
}