本文整理汇总了PHP中I18n::get_message_key方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::get_message_key方法的具体用法?PHP I18n::get_message_key怎么用?PHP I18n::get_message_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I18n
的用法示例。
在下文中一共展示了I18n::get_message_key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
public function setup()
{
$config = array('root_locale' => 'en', 'default_locale' => 'te_ST', 'locale_dir' => VARPATH . 'locale/');
$this->i18n = I18n::instance($config);
ORM::factory("incoming_translation")->where("locale", "te_ST")->delete_all();
$messages_te_ST = array(array('Hello world', 'Hallo Welt'), array(array('one' => 'One item has been added', 'other' => '%count elements have been added'), array('one' => 'Ein Element wurde hinzugefuegt.', 'other' => '%count Elemente wurden hinzugefuegt.')), array('Hello %name, how are you today?', 'Hallo %name, wie geht es Dir heute?'));
foreach ($messages_te_ST as $data) {
list($message, $translation) = $data;
$entry = ORM::factory("incoming_translation");
$entry->key = I18n::get_message_key($message);
$entry->message = serialize($message);
$entry->translation = serialize($translation);
$entry->locale = 'te_ST';
$entry->revision = null;
$entry->save();
}
}
示例2: process_message
static function process_message($message, &$cache)
{
if (empty($cache)) {
foreach (Database::instance()->select("key")->from("incoming_translations")->where("locale", "root")->get() as $row) {
$cache[$row->key] = true;
}
}
$key = I18n::get_message_key($message);
if (array_key_exists($key, $cache)) {
return $cache[$key];
}
$entry = ORM::factory("incoming_translation", array("key" => $key));
if (!$entry->loaded) {
$entry->key = $key;
$entry->message = serialize($message);
$entry->locale = "root";
$entry->save();
}
}
示例3: save
public function save()
{
access::verify_csrf();
user::active()->admin or access::forbidden();
$input = Input::instance();
$message = $input->post("l10n-message-source");
$translation = $input->post("l10n-edit-target");
$key = I18n::get_message_key($message);
$locale = I18n::instance()->locale();
$entry = ORM::factory("outgoing_translation")->where(array("key" => $key, "locale" => $locale))->find();
if (!$entry->loaded) {
$entry->key = $key;
$entry->locale = $locale;
$entry->message = serialize($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());
}