当前位置: 首页>>代码示例>>PHP>>正文


PHP locale_add_language函数代码示例

本文整理汇总了PHP中locale_add_language函数的典型用法代码示例。如果您正苦于以下问题:PHP locale_add_language函数的具体用法?PHP locale_add_language怎么用?PHP locale_add_language使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了locale_add_language函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addLanguage

 /**
  * Add language.
  *
  * @param string $language
  *    Language code.
  */
 public function addLanguage($language)
 {
     include_once DRUPAL_ROOT . '/includes/locale.inc';
     // Enable a language only if it has not been enabled already.
     $enabled_languages = locale_language_list();
     if (!isset($enabled_languages[$language])) {
         locale_add_language($language);
     }
 }
开发者ID:janoka,项目名称:platform-dev,代码行数:15,代码来源:Config.php

示例2: addLanguage

 /**
  * Adds a language
  *
  * @param $langcode
  * @param $default
  *   Whether this is the default language
  * @param $load
  *   Whether to load available translations for that language
  */
 function addLanguage($langcode, $default = FALSE, $load = TRUE) {
   require_once './includes/locale.inc';
   // Enable installation language as default site language.
   locale_add_language($langcode, NULL, NULL, NULL, NULL, NULL, 1, $default);
   // Reset language list
   language_list('language', TRUE);
   // We may need to refresh default language
   drupal_init_language();
   // @todo import po files for this language
 }
开发者ID:noomz,项目名称:coldsleepdrupal,代码行数:19,代码来源:drupal_i18n_test_case.php

示例3: install_tasks

/**
 * Tasks performed after the database is initialized.
 */
function install_tasks($profile, $task)
{
    global $base_url, $install_locale;
    // Bootstrap newly installed Drupal, while preserving existing messages.
    $messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : '';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    $_SESSION['messages'] = $messages;
    // URL used to direct page requests.
    $url = $base_url . '/install.php?locale=' . $install_locale . '&profile=' . $profile;
    // Build a page for final tasks.
    if (empty($task)) {
        variable_set('install_task', 'profile-install');
        $task = 'profile-install';
    }
    // We are using a list of if constructs here to allow for
    // passing from one task to the other in the same request.
    // Install profile modules.
    if ($task == 'profile-install') {
        $modules = variable_get('install_profile_modules', array());
        $files = module_rebuild_cache();
        variable_del('install_profile_modules');
        $operations = array();
        foreach ($modules as $module) {
            $operations[] = array('_install_module_batch', array($module, $files[$module]->info['name']));
        }
        $batch = array('operations' => $operations, 'finished' => '_install_profile_batch_finished', 'title' => st('Installing @drupal', array('@drupal' => drupal_install_profile_name())), 'error_message' => st('The installation has encountered an error.'));
        // Start a batch, switch to 'profile-install-batch' task. We need to
        // set the variable here, because batch_process() redirects.
        variable_set('install_task', 'profile-install-batch');
        batch_set($batch);
        batch_process($url, $url);
    }
    // We are running a batch install of the profile's modules.
    // This might run in multiple HTTP requests, constantly redirecting
    // to the same address, until the batch finished callback is invoked
    // and the task advances to 'locale-initial-import'.
    if ($task == 'profile-install-batch') {
        include_once 'includes/batch.inc';
        $output = _batch_page();
    }
    // Import interface translations for the enabled modules.
    if ($task == 'locale-initial-import') {
        if (!empty($install_locale) && $install_locale != 'en') {
            include_once 'includes/locale.inc';
            // Enable installation language as default site language.
            locale_add_language($install_locale, NULL, NULL, NULL, NULL, NULL, 1, TRUE);
            // Collect files to import for this language.
            $batch = locale_batch_by_language($install_locale, '_install_locale_initial_batch_finished');
            if (!empty($batch)) {
                // Remember components we cover in this batch set.
                variable_set('install_locale_batch_components', $batch['#components']);
                // Start a batch, switch to 'locale-batch' task. We need to
                // set the variable here, because batch_process() redirects.
                variable_set('install_task', 'locale-initial-batch');
                batch_set($batch);
                batch_process($url, $url);
            }
        }
        // Found nothing to import or not foreign language, go to next task.
        $task = 'configure';
    }
    if ($task == 'locale-initial-batch') {
        include_once 'includes/batch.inc';
        include_once 'includes/locale.inc';
        $output = _batch_page();
    }
    if ($task == 'configure') {
        if (variable_get('site_name', FALSE) || variable_get('site_mail', FALSE)) {
            // Site already configured: This should never happen, means re-running
            // the installer, possibly by an attacker after the 'install_task' variable
            // got accidentally blown somewhere. Stop it now.
            install_already_done_error();
        }
        $form = drupal_get_form('install_configure_form', $url);
        if (!variable_get('site_name', FALSE) && !variable_get('site_mail', FALSE)) {
            // Not submitted yet: Prepare to display the form.
            $output = $form;
            drupal_set_title(st('Configure site'));
            // Warn about settings.php permissions risk
            $settings_dir = './' . conf_path();
            $settings_file = $settings_dir . '/settings.php';
            if (!drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($settings_dir, FILE_NOT_WRITABLE, 'dir')) {
                drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, please consult the <a href="@handbook_url">on-line handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/getting-started')), 'error');
            } else {
                drupal_set_message(st('All necessary changes to %dir and %file have been made. They have been set to read-only for security.', array('%dir' => $settings_dir, '%file' => $settings_file)));
            }
            // Add JavaScript validation.
            _user_password_dynamic_validation();
            drupal_add_js(drupal_get_path('module', 'system') . '/system.js', 'module');
            // We add these strings as settings because JavaScript translation does not
            // work on install time.
            drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail')), 'cleanURL' => array('success' => st('Your server has been successfully tested to support this feature.'), 'failure' => st('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.'), 'testing' => st('Testing clean URLs...'))), 'setting');
            drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
  $(document).ready(function() {
    Drupal.cleanURLsInstallCheck();
//.........这里部分代码省略.........
开发者ID:alexismb5,项目名称:ckan-drupal,代码行数:101,代码来源:install.php

示例4: install_import_locales

/**
 * Installation task; import languages via a batch process.
 *
 * @param $install_state
 *   An array of information about the current installation state.
 * @return
 *   The batch definition, if there are language files to import.
 */
function install_import_locales(&$install_state)
{
    include_once DRUPAL_ROOT . '/includes/locale.inc';
    $install_locale = $install_state['parameters']['locale'];
    // Enable installation language as default site language.
    locale_add_language($install_locale, NULL, NULL, NULL, '', NULL, 1, TRUE);
    // Collect files to import for this language.
    $batch = locale_batch_by_language($install_locale, NULL);
    if (!empty($batch)) {
        // Remember components we cover in this batch set.
        variable_set('install_locale_batch_components', $batch['#components']);
        return $batch;
    }
}
开发者ID:blipp,项目名称:drupal,代码行数:22,代码来源:install.php

示例5: languageCreate

 /**
  * {@inheritdoc}
  */
 public function languageCreate(\stdClass $language)
 {
     if (!module_exists('locale')) {
         throw new \Exception(sprintf("%s::%s line %s: This driver requires the 'locale' module be enabled in order to create languages", get_class($this), __FUNCTION__, __LINE__));
     }
     include_once DRUPAL_ROOT . '/includes/iso.inc';
     include_once DRUPAL_ROOT . '/includes/locale.inc';
     // Get all predefined languages, regardless if they are enabled or not.
     $predefined_languages = _locale_get_predefined_list();
     // If the language code is not valid then throw an InvalidArgumentException.
     if (!isset($predefined_languages[$language->langcode])) {
         throw new InvalidArgumentException("There is no predefined language with langcode '{$language->langcode}'.");
     }
     // Enable a language only if it has not been enabled already.
     $enabled_languages = locale_language_list();
     if (!isset($enabled_languages[$language->langcode])) {
         locale_add_language($language->langcode);
         return $language;
     }
     return FALSE;
 }
开发者ID:acbramley,项目名称:DrupalDriver,代码行数:24,代码来源:Drupal7.php

示例6: languageCreate

 /**
  * {@inheritdoc}
  */
 public function languageCreate(\stdClass $language)
 {
     include_once DRUPAL_ROOT . '/includes/iso.inc';
     include_once DRUPAL_ROOT . '/includes/locale.inc';
     // Get all predefined languages, regardless if they are enabled or not.
     $predefined_languages = _locale_get_predefined_list();
     // If the language code is not valid then throw an InvalidArgumentException.
     if (!isset($predefined_languages[$language->langcode])) {
         throw new InvalidArgumentException("There is no predefined language with langcode '{$language->langcode}'.");
     }
     // Enable a language only if it has not been enabled already.
     $enabled_languages = locale_language_list();
     if (!isset($enabled_languages[$language->langcode])) {
         locale_add_language($language->langcode);
         return $language;
     }
     return FALSE;
 }
开发者ID:nedjo,项目名称:DrupalDriver,代码行数:21,代码来源:Drupal7.php


注:本文中的locale_add_language函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。