function locale_translation_source_build($project, $langcode, $filename = NULL) {
// Create a source object with data of the project object.
$source = clone $project;
$source->project = $project->name;
$source->language = $langcode;
$filename = $filename ? $filename : config('locale.settings')
->get('translation.default_filename');
// If the server_pattern contains a remote file path we will check for a
// remote file. The local version of this file will will only be checked is a
// translations directory has been defined. If the server_pattern is a local
// file path we will only check for a file in the local file system.
$files = array();
if (_locale_translation_file_is_remote($source->server_pattern)) {
$files['remote'] = (object) array(
'type' => 'remote',
'filename' => locale_translation_build_server_pattern($source, basename($source->server_pattern)),
'url' => locale_translation_build_server_pattern($source, $source->server_pattern),
);
if (variable_get('locale_translate_file_directory', conf_path() . '/files/translations')) {
$files['local'] = (object) array(
'type' => 'local',
'directory' => 'translations://',
'filename' => locale_translation_build_server_pattern($source, $filename),
);
}
}
else {
$files['local'] = (object) array(
'type' => 'local',
'directory' => locale_translation_build_server_pattern($source, drupal_dirname($source->server_pattern)),
'filename' => locale_translation_build_server_pattern($source, basename($source->server_pattern)),
);
}
$source->files = $files;
return $source;
}