本文整理汇总了PHP中I18n::is_plural_message方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::is_plural_message方法的具体用法?PHP I18n::is_plural_message怎么用?PHP I18n::is_plural_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I18n
的用法示例。
在下文中一共展示了I18n::is_plural_message方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save()
{
access::verify_csrf();
if (!identity::active_user()->admin) {
access::forbidden();
}
$locale = I18n::instance()->locale();
$input = Input::instance();
$key = $input->post("l10n-message-key");
$root_message = ORM::factory("incoming_translation")->where(array("key" => $key, "locale" => "root"))->find();
if (!$root_message->loaded) {
throw new Exception("@todo bad request data / illegal state");
}
$is_plural = I18n::is_plural_message(unserialize($root_message->message));
if ($is_plural) {
$plural_forms = l10n_client::plural_forms($locale);
$translation = array();
foreach ($plural_forms as $plural_form) {
$value = $input->post("l10n-edit-plural-translation-{$plural_form}");
if (null === $value || !is_string($value)) {
throw new Exception("@todo bad request data");
}
$translation[$plural_form] = $value;
}
} else {
$translation = $input->post("l10n-edit-translation");
if (null === $translation || !is_string($translation)) {
throw new Exception("@todo bad request data");
}
}
$entry = ORM::factory("outgoing_translation")->where(array("key" => $key, "locale" => $locale))->find();
if (!$entry->loaded) {
$entry->key = $key;
$entry->locale = $locale;
$entry->message = $root_message->message;
$entry->base_revision = null;
}
$entry->translation = serialize($translation);
$entry_from_incoming = ORM::factory("incoming_translation")->where(array("key" => $key, "locale" => $locale))->find();
if (!$entry_from_incoming->loaded) {
$entry->base_revision = $entry_from_incoming->revision;
}
$entry->save();
print json_encode(new stdClass());
}