/** * 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); }
/** * 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); }
function _e($key, $domain = 'core') { $gt = Translation::newInstance()->_get($domain); if (!$gt) { echo $key; return ''; } echo $gt->translate($key); return ''; }
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'])) {
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); }