本文整理匯總了PHP中Translation::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translation::load方法的具體用法?PHP Translation::load怎麽用?PHP Translation::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Translation
的用法示例。
在下文中一共展示了Translation::load方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: translate
public function translate($s)
{
global $language_data;
if (isset($language_data) and isset($language_data[$s])) {
return $language_data[$s];
} else {
global $config, $home_dir, $db;
if ($config['debug_mode']) {
require_once $home_dir . 'models/translation.m.php';
require_once $home_dir . 'models/language.m.php';
$language = new Language($db);
$language->loadByCode($language_data['language_code']);
$t = new Translation($db);
$t->load($language->ival('language_id'), $s);
if (!$t->is_loaded) {
$t->data['translation_name'] = $s;
$t->data['translation_language_id'] = $language->ival('language_id');
$t->save();
}
}
return $s;
}
}
示例2: Localization
<?php
global $home_dir, $language_data;
require_once $home_dir . 'classes/localization.php';
require_once $home_dir . 'models/translation.m.php';
require_once $home_dir . 'models/language.m.php';
$localization = new Localization($home_dir . 'lang/');
$language = new Language($db);
$language->loadByCode($language_data['language_code']);
foreach ($language_data as $name => $translation) {
$t = new Translation($db);
$t->load($language->ival('language_id'), $name);
$t->data['translation_name'] = $name;
$t->data['translation_translation'] = $translation;
$t->data['translation_language_id'] = $language->ival('language_id');
$t->save();
}
echo 'Language imported.';