Пытаюсь автоматически обновить переводы с помощью l10n_update исходный установочный профиль брал из l10n_install, создал issue. При установке через веб всё супер.
Когда устанавливаю через drush вот такая беда.
is_dir(): Unable to find the wrapper "translations" - did you forget to enable it when you configured [warning]
PHP? file.inc:2118
file_exists(): Unable to find the wrapper "private" - did you forget to enable it when you configured [warning]
PHP? file.inc:486
file_put_contents(): Unable to find the wrapper "private" - did you forget to enable it when you [warning]
configured PHP? file.inc:494
file_put_contents(private:///.htaccess): failed to open stream: No such file or directory file.inc:494 [warning]
WD security: Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your [error]
private:// directory which contains the following lines:
/**
* @file: zniki.install
*/
function zniki_install() {
variable_set('l10n_update_download_store', '/home/translation');
variable_set('file_private_path', '/home/private');
variable_set('file_public_path', 'sites/default/files/public');
variable_set('file_temporary_path', '/home/tmp');
}
/**
* @file: zniki.profile
*/
/**
* Implement hook_install_tasks().
*/
function zniki_install_tasks($install_state) {
return array(
'zniki_import_translation' => array(
'display_name' => st('Set up translations'),
'display' => true,
'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
'type' => 'batch',
),
);
}
/**
* Implement hook_install_tasks_alter().
*
* Perform actions to set up the site for this profile.
*/
function zniki_install_tasks_alter(&$tasks, $install_state) {
// Remove core steps for translation imports.
unset($tasks['install_import_locales']);
unset($tasks['install_import_locales_remaining']);
}
/**
* Installation step callback.
*
* @param $install_state
* An array of information about the current installation state.
*/
function zniki_import_translation(&$install_state) {
// Enable installation language as default site language.
include_once DRUPAL_ROOT . '/includes/locale.inc';
$install_locale = 'ru';
locale_add_language($install_locale, NULL, NULL, NULL, '', NULL, 1, TRUE);
// Fetch and batch the translations!
module_load_include('fetch.inc', 'l10n_update');
$options = _l10n_update_default_update_options();
$last_checked = variable_get('l10n_update_last_check');
if ($last_checked < REQUEST_TIME - L10N_UPDATE_STATUS_TTL) {
l10n_update_clear_status();
$batch = l10n_update_batch_update_build(array(), array($install_locale), $options);
}
else {
$batch = l10n_update_batch_fetch_build(array(), array($install_locale), $options);
}
return $batch;
}
Версия Drupal:
7.xКатегория:
MultilingualСвязанные проекты:
Localization update
Вопрос задан 01.10.2015 - 05:04
Ответы
Мы для себя делали через drush_language:
- В .make файл добавили
defaults:
projects:
translations:
- ru
- Создали install_task с таким кодом:
exec('find . -name "*.po" | xargs drush language-import ru');
exec('drush language-default ru');
Нормальный способ не осилили.
У этого способа плюс в скорости: .po файлы кешируются через drush и не скачиваются при каждой сборке.
Ответ дан 01.10.2015 - 20:37