Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
eea79f9b
Commit
eea79f9b
authored
Dec 17, 2012
by
Dries
Browse files
Issue
#1866544
by Sutharsan: Improve Locale batch progress and result messages.
parent
08b21153
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/modules/locale/locale.batch.inc
View file @
eea79f9b
...
...
@@ -54,7 +54,7 @@ function locale_translation_batch_status_fetch_remote($source, &$context) {
$context
[
'results'
][
'failed_files'
][]
=
$source
->
name
;
}
$context
[
'results'
][
'sources'
][
$source
->
name
][
$source
->
langcode
]
=
$source
;
$context
[
'message'
]
=
$t
(
'Checked translation f
ile: %name
.'
,
array
(
'%
name
'
=>
$source
->
name
));
$context
[
'message'
]
=
$t
(
'Checked translation f
or %project
.'
,
array
(
'%
project
'
=>
$source
->
project
));
}
}
...
...
@@ -93,7 +93,7 @@ function locale_translation_batch_status_fetch_local($sources, &$context) {
$context
[
'results'
][
'sources'
][
$source
->
name
][
$source
->
langcode
]
=
$source
;
}
}
$context
[
'message'
]
=
$t
(
'Checked translation
file
s.'
);
$context
[
'message'
]
=
$t
(
'Checked
all
translations.'
);
}
/**
...
...
@@ -113,6 +113,7 @@ function locale_translation_batch_status_fetch_local($sources, &$context) {
* @see locale_translation_batch_status_fetch_local()
*/
function
locale_translation_batch_status_compare
(
&
$context
)
{
$t
=
get_t
();
$history
=
locale_translation_get_file_history
();
$results
=
array
();
...
...
@@ -155,8 +156,8 @@ function locale_translation_batch_status_compare(&$context) {
$results
[
$project
][
$langcode
]
=
$source
;
}
}
$context
[
'message'
]
=
$t
(
'Updated translation status.'
);
}
locale_translation_status_save
(
$results
);
}
...
...
@@ -248,7 +249,7 @@ function locale_translation_batch_fetch_download($project, $langcode, &$context)
if
(
isset
(
$source
->
type
)
&&
$source
->
type
==
LOCALE_TRANSLATION_REMOTE
)
{
$t
=
get_t
();
if
(
$file
=
locale_translation_download_source
(
$source
->
files
[
LOCALE_TRANSLATION_REMOTE
]))
{
$context
[
'message'
]
=
$t
(
'
Import
ed translation f
ile: %name
.'
,
array
(
'%
name'
=>
$file
->
filename
));
$context
[
'message'
]
=
$t
(
'
Download
ed translation f
or %project
.'
,
array
(
'%
project'
=>
$source
->
project
));
$source
->
files
[
LOCALE_TRANSLATION_DOWNLOADED
]
=
$file
;
}
else
{
...
...
@@ -308,7 +309,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
$file
=
$source_result
->
files
[
$import_type
];
module_load_include
(
'bulk.inc'
,
'locale'
);
$options
+=
array
(
'message'
=>
$t
(
'Importing translation f
ile: %name'
,
array
(
'%name'
=>
$file
->
filename
)),
'message'
=>
$t
(
'Importing translation f
or %project.'
,
array
(
'%project'
=>
$source
->
project
)),
);
// Import the translation file. For large files the batch operations is
// progressive and will be called repeatedly untill finished.
...
...
@@ -318,7 +319,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
if
(
isset
(
$context
[
'finished'
])
&&
$context
[
'finished'
]
==
1
)
{
// The import is successfull.
if
(
isset
(
$context
[
'results'
][
'files'
][
$file
->
uri
]))
{
$context
[
'message'
]
=
$t
(
'Imported translation f
ile: %name
.'
,
array
(
'%
name'
=>
$file
->
filename
));
$context
[
'message'
]
=
$t
(
'Imported translation f
or %project
.'
,
array
(
'%
project'
=>
$source
->
project
));
// Keep the data of imported source. In the following batch
// operation it will be saved in the {locale_file} table.
...
...
core/modules/locale/locale.bulk.inc
View file @
eea79f9b
...
...
@@ -404,7 +404,7 @@ function locale_translate_batch_build($files, $options) {
$batch
=
array
(
'operations'
=>
$operations
,
'title'
=>
$t
(
'Importing interface translations'
),
'
init
_message'
=>
$t
(
'Starting import'
)
,
'
progress
_message'
=>
''
,
'error_message'
=>
$t
(
'Error importing interface translations'
),
'file'
=>
drupal_get_path
(
'module'
,
'locale'
)
.
'/locale.bulk.inc'
,
);
...
...
@@ -433,7 +433,8 @@ function locale_translate_batch_build($files, $options) {
* are customized translations or come from a community source. Use
* LOCALE_CUSTOMIZED or LOCALE_NOT_CUSTOMIZED. Optional, defaults to
* LOCALE_NOT_CUSTOMIZED.
* - 'message': Alternative message to display during import.
* - 'message': Alternative message to display during import. Note, this must
* be sanitized text.
*
* @param $context
* Contains a list of files imported.
...
...
@@ -470,7 +471,7 @@ function locale_translate_batch_import($file, $options, &$context) {
// http://drupal.org/node/1089472
$context
[
'finished'
]
=
min
(
0.95
,
$report
[
'seek'
]
/
filesize
(
$file
->
uri
));
if
(
isset
(
$options
[
'message'
]))
{
$context
[
'message'
]
=
t
(
'
@
message (@percent%).'
,
array
(
'
@
message'
=>
$options
[
'message'
],
'@percent'
=>
(
int
)
(
$context
[
'finished'
]
*
100
)));
$context
[
'message'
]
=
t
(
'
!
message (@percent%).'
,
array
(
'
!
message'
=>
$options
[
'message'
],
'@percent'
=>
(
int
)
(
$context
[
'finished'
]
*
100
)));
}
else
{
$context
[
'message'
]
=
t
(
'Importing translation file: %filename (@percent%).'
,
array
(
'%filename'
=>
$file
->
filename
,
'@percent'
=>
(
int
)
(
$context
[
'finished'
]
*
100
)));
...
...
@@ -532,6 +533,7 @@ function locale_translate_batch_import_save($context) {
locale_translation_update_file_history
(
$file
);
}
}
$context
[
'message'
]
=
t
(
'Translations imported.'
);
}
}
...
...
core/modules/locale/locale.compare.inc
View file @
eea79f9b
...
...
@@ -306,6 +306,7 @@ function locale_translation_batch_status_build($projects = array(), $langcodes =
$batch
=
array
(
'operations'
=>
$operations
,
'title'
=>
$t
(
'Checking translations'
),
'progress_message'
=>
''
,
'finished'
=>
'locale_translation_batch_status_finished'
,
'error_message'
=>
$t
(
'Error checking translation updates.'
),
'file'
=>
drupal_get_path
(
'module'
,
'locale'
)
.
'/locale.batch.inc'
,
...
...
core/modules/locale/locale.fetch.inc
View file @
eea79f9b
...
...
@@ -38,7 +38,7 @@ function locale_translation_batch_update_build($projects = array(), $langcodes =
$batch
=
array
(
'operations'
=>
$operations
,
'title'
=>
$t
(
'Updating translations'
),
'
init
_message'
=>
$t
(
'Downloading and importing translation files.'
)
,
'
progress
_message'
=>
''
,
'error_message'
=>
$t
(
'Error importing translation files'
),
'finished'
=>
'locale_translation_batch_fetch_finished'
,
'file'
=>
drupal_get_path
(
'module'
,
'locale'
)
.
'/locale.batch.inc'
,
...
...
@@ -68,7 +68,7 @@ function locale_translation_batch_fetch_build($projects = array(), $langcodes =
$batch
=
array
(
'operations'
=>
_locale_translation_fetch_operations
(
$projects
,
$langcodes
,
$options
),
'title'
=>
$t
(
'Updating translations.'
),
'
init
_message'
=>
$t
(
'Downloading and importing translation files.'
)
,
'
progress
_message'
=>
''
,
'error_message'
=>
$t
(
'Error importing translation files'
),
'finished'
=>
'locale_translation_batch_fetch_finished'
,
'file'
=>
drupal_get_path
(
'module'
,
'locale'
)
.
'/locale.batch.inc'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment