當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Translation::newInstance方法代碼示例

本文整理匯總了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);
}
開發者ID:acharei,項目名稱:OSClass,代碼行數:19,代碼來源:hTranslations.php

示例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);
}
開發者ID:semul,項目名稱:Osclass,代碼行數:20,代碼來源:hTranslations.php

示例3: _e

function _e($key, $domain = 'core')
{
    $gt = Translation::newInstance()->_get($domain);
    if (!$gt) {
        echo $key;
        return '';
    }
    echo $gt->translate($key);
    return '';
}
開發者ID:hashemgamal,項目名稱:OSClass,代碼行數:10,代碼來源:hTranslations.php

示例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'])) {
開發者ID:bomvendador,項目名稱:soroka_r,代碼行數:31,代碼來源:install.php

示例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);
}
開發者ID:naneri,項目名稱:Osclass,代碼行數:34,代碼來源:utils.php


注:本文中的Translation::newInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。