本文整理汇总了PHP中Translation::newInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::newInstance方法的具体用法?PHP Translation::newInstance怎么用?PHP Translation::newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation::newInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _n
/**
* Retrieve the singular or plural translation of the string.
*
* @since 2.2
*
* @param string $single_key
* @param string $plural_key
* @param int $count
* @param string $domain
* @return string
*/
function _n($single_key, $plural_key, $count, $domain = 'core')
{
$gt = Translation::newInstance()->_get($domain);
if (!$gt) {
return $key;
}
return $gt->ngettext($single_key, $plural_key, $count);
}
示例2: _n
/**
* Retrieve the singular or plural translation of the string.
*
* @since 2.2
*
* @param string $single_key
* @param string $plural_key
* @param int $count
* @param string $domain
* @return string
*/
function _n($single_key, $plural_key, $count, $domain = 'core')
{
$gt = Translation::newInstance()->_get($domain);
if (!$gt) {
return $key;
}
$string = $gt->ngettext($single_key, $plural_key, $count);
return osc_apply_filter('ngettext', $string);
}
示例3: _e
function _e($key, $domain = 'core')
{
$gt = Translation::newInstance()->_get($domain);
if (!$gt) {
echo $key;
return '';
}
echo $gt->translate($key);
return '';
}
示例4: key
if (Params::getParam('install_locale') != '') {
Session::newInstance()->_set('userLocale', Params::getParam('install_locale'));
Session::newInstance()->_set('adminLocale', Params::getParam('install_locale'));
}
if (Session::newInstance()->_get('adminLocale') != '' && key_exists(Session::newInstance()->_get('adminLocale'), $locales)) {
$current_locale = Session::newInstance()->_get('adminLocale');
} else {
if (isset($locales['en_US'])) {
$current_locale = 'en_US';
} else {
$current_locale = key($locales);
}
}
Session::newInstance()->_set('userLocale', $current_locale);
Session::newInstance()->_set('adminLocale', $current_locale);
$translation = Translation::newInstance(true);
$step = Params::getParam('step');
if (!is_numeric($step)) {
$step = '1';
}
if (is_osclass_installed()) {
$message = __("Похоже у вас уже установлен OSClass. Для повторной установки очистите таблицы базы данных.");
osc_die('Ошибка » OSClass', $message);
}
switch ($step) {
case 1:
$requirements = get_requirements();
$error = check_requirements($requirements);
break;
case 2:
if (Params::getParam('save_stats') == '1' || isset($_COOKIE['osclass_save_stats'])) {
示例5: osc_translate_categories
function osc_translate_categories($locale)
{
$old_locale = Session::newInstance()->_get('adminLocale');
Session::newInstance()->_set('adminLocale', $locale);
Translation::newInstance()->_load(osc_translations_path() . $locale . '/core.mo', 'cat_' . $locale);
$catManager = Category::newInstance();
$old_categories = $catManager->_findNameIDByLocale($old_locale);
$tmp_categories = $catManager->_findNameIDByLocale($locale);
foreach ($tmp_categories as $category) {
$new_categories[$category['pk_i_id']] = $category['s_name'];
}
unset($tmp_categories);
foreach ($old_categories as $category) {
if (!isset($new_categories[$category['pk_i_id']])) {
$fieldsDescription['s_name'] = __($category['s_name'], 'cat_' . $locale);
$fieldsDescription['s_description'] = '';
$fieldsDescription['fk_i_category_id'] = $category['pk_i_id'];
$fieldsDescription['fk_c_locale_code'] = $locale;
$slug_tmp = $slug = osc_sanitizeString(osc_apply_filter('slug', $fieldsDescription['s_name']));
$slug_unique = 1;
while (true) {
if (!$catManager->findBySlug($slug)) {
break;
} else {
$slug = $slug_tmp . "_" . $slug_unique;
$slug_unique++;
}
}
$fieldsDescription['s_slug'] = $slug;
$catManager->insertDescription($fieldsDescription);
}
}
Session::newInstance()->_set('adminLocale', $old_locale);
}