/** * 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); } }
/** * {@inheritdoc} */ public function validateDrushParams($args) { $add_language = drush_get_option('languages'); if (!empty($add_language)) { $add_language = explode(',', str_replace(' ', '', $add_language)); // Intersect with the enabled languages to make sure the language args // passed are actually enabled. $values['values']['add_language'] = array_intersect($add_language, array_keys(locale_language_list())); } $values['kill'] = drush_get_option('kill'); $values['title_length'] = 6; $values['num'] = array_shift($args); $values['max_comments'] = array_shift($args); $all_types = array_keys(node_type_get_names()); $default_types = array_intersect(array('page', 'article'), $all_types); $selected_types = _convert_csv_to_array(drush_get_option('types', $default_types)); if (empty($selected_types)) { return drush_set_error('DEVEL_GENERATE_NO_CONTENT_TYPES', dt('No content types available')); } $values['node_types'] = array_combine($selected_types, $selected_types); $node_types = array_filter($values['node_types']); if (!empty($values['kill']) && empty($node_types)) { return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Please provide content type (--types) in which you want to delete the content.')); } return $values; }
/** * Provides information about controller classes and weights needed by the realm system * and some more meta-information for realm administration. * * This information is mainly used to build exportable realms as Features. * * @see i18n_variable_variable_realm_info() * * @return array * Array keyed by realm name which contains the following elements: * - 'title', Humam readable name for the realm. * - 'controller class', Class name for realm controller, implementing VariableRealmControllerInterface. * - 'store class', Class name for realm store, implementing VariableRealmStoreInterface. * - 'weight', Default weight for this realm. * - 'keys', Associative array with human readable names for keys. * - 'keys callback', Callback function to provide the keys. * - 'default key', The default key. * - 'options', Array of variable names that may be set for this realm. If not set * any variable will be allowed for this realm. * - 'list callback', Callback function to provide variable list for this realm. * - 'select', Boolean flag whether variables for this realm can be selected from a list. * - 'select path', Path to variable selection form (optional). * - 'variable name', Name for variables that belong to this realm: e.g. 'multilingual' variable/s * - 'variable class', CSS class name for annotated variables in system settings forms. * - 'form settings', Boolean flag, whether realm variables should be handled automatically * in system settings forms. * - 'form switcher', Boolean flag, whether a realm switcher should be auto-generated * for settings forms which contain variables that belong to this realm. */ function hook_variable_realm_info() { $realm['language'] = array('title' => t('Language'), 'controller class' => 'I18nVariableLanguageRealm', 'store class' => 'VariableStoreRealmStore', 'keys' => locale_language_list('name', TRUE), 'default key' => language_default('language'), 'options' => _i18n_variable_variable_realm_list(), 'select' => TRUE, 'select path' => 'admin/config/regional/i18n/variable', 'variable name' => t('multilingual'), 'variable class' => 'i18n-variable', 'form settings' => TRUE); return $realm; }
/** * {@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; }
/** * {@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; }
/** * Provides human readable information about existing realms. * * This information is mainly used to build exportable realms as Features. * * @see i18n_variable_variable_realm_info() * * @return array * Array keyed by realm name which contains the following elements: * - 'title', Humam readable name for the realm. * - 'keys', Associative array with human readable names for keys. */ function hook_variable_realm_info() { $realm['language'] = array('title' => t('Language'), 'keys' => locale_language_list('name', TRUE)); return $realm; }