summaryrefslogtreecommitdiff
path: root/includes/locale.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-05-22 07:42:37 +0000
committerDries Buytaert <dries@buytaert.net>2007-05-22 07:42:37 +0000
commit0047e35d9137a37235c0248daacaad70ed0105da (patch)
treeee6a8e51e90d2b099ffed5fd12c743a4796d8c60 /includes/locale.inc
parent5094312d3b76d41aaf41c6a5c9dab04ccb7d1590 (diff)
downloadbrdo-0047e35d9137a37235c0248daacaad70ed0105da.tar.gz
brdo-0047e35d9137a37235c0248daacaad70ed0105da.tar.bz2
- Patch #145671 by Gabor: import translation files when adding a new language.
Diffstat (limited to 'includes/locale.inc')
-rw-r--r--includes/locale.inc25
1 files changed, 18 insertions, 7 deletions
diff --git a/includes/locale.inc b/includes/locale.inc
index bc8ea7503..1fba748bc 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -303,6 +303,12 @@ function locale_languages_predefined_form_submit($form_values, $form, &$form_sta
drupal_set_message(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array('%language' => t($predefined[$langcode][0]), '@locale-help' => url('admin/help/locale'))));
}
+ // See if we have language files to import for the newly added
+ // language, collect and import them.
+ if ($batch = locale_batch_by_language($langcode, '_locale_batch_language_finished')) {
+ batch_set($batch);
+ }
+
$form_state['redirect'] = 'admin/settings/language';
return;
}
@@ -848,7 +854,7 @@ function locale_translate_delete($lid) {
* @param $default
* Optionall set this language to be the default.
*/
-function locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = FALSE, $default = FALSE) {
+function locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = TRUE, $default = FALSE) {
// Default prefix on language code.
if (empty($prefix)) {
$prefix = $langcode;
@@ -2111,14 +2117,17 @@ function _locale_get_predefined_list() {
*/
/**
- * Prepare a batch to use to import translations on install time.
+ * Prepare a batch to import translations for all enabled
+ * modules in a given language.
*
* @param $langcode
* Language code to import translations for.
+ * @param $finished
+ * Optional finished callback for the batch.
* @return
* A batch structure or FALSE if no files found.
*/
-function locale_batch_installer($langcode) {
+function locale_batch_by_language($langcode, $finished = '_locale_batch_installer_finished') {
// Collect all files to import for all enabled modules and themes.
$files = array();
@@ -2131,7 +2140,7 @@ function locale_batch_installer($langcode) {
$files = array_merge($files, file_scan_directory(dirname($component->filename) .'/po/', '(^|\.)'. $langcode .'\.po$', array('.', '..', 'CVS'), 0, FALSE));
}
- return _locale_batch_build($files, '_locale_batch_installer_finished');
+ return _locale_batch_build($files, $finished);
}
/**
@@ -2140,7 +2149,7 @@ function locale_batch_installer($langcode) {
* @param $files
* Array of files to import
* @param $finished
- * A finished callback to use for the batch
+ * Optional finished callback for the batch.
* @return
* A batch structure
*/
@@ -2181,8 +2190,10 @@ function _locale_batch_installer_finished($success, $results) {
* @param $components
* An array of component (theme and/or module) names to import
* translations for.
+ * @param $finished
+ * Optional finished callback for the batch.
*/
-function locale_batch_system($components) {
+function locale_batch_by_component($components, $finished = '_locale_batch_system_finished') {
$files = array();
$languages = language_list('enabled');
unset($languages[1]['en']);
@@ -2199,7 +2210,7 @@ function locale_batch_system($components) {
$files = array_merge($files, file_scan_directory(dirname($component->filename) .'/po/', '(^|\.)('. $language_list .')\.po$', array('.', '..', 'CVS'), 0, FALSE));
}
}
- return _locale_batch_build($files, '_locale_batch_system_finished');
+ return _locale_batch_build($files, $finished);
}
return FALSE;
}