mirror of https://github.com/BOINC/boinc.git
Updated boinctranslate_update_official_boinc_translations() tool to use a configurable resource name
(DBOINCP-141)
This commit is contained in:
parent
b18adf9388
commit
8caf89cf8e
|
@ -24,6 +24,10 @@ function boinctranslate_admin_settings(&$form_state) {
|
||||||
'boinc_translate_transifex_standard_resources',
|
'boinc_translate_transifex_standard_resources',
|
||||||
"project-generic\nweb"
|
"project-generic\nweb"
|
||||||
),
|
),
|
||||||
|
'transifex_boinc_drupal_resource' => variable_get(
|
||||||
|
'boinc_translate_transifex_boinc_drupal_resource',
|
||||||
|
'drupal'
|
||||||
|
),
|
||||||
'transifex_project_name' => variable_get(
|
'transifex_project_name' => variable_get(
|
||||||
'boinc_translate_transifex_project_name', ''
|
'boinc_translate_transifex_project_name', ''
|
||||||
),
|
),
|
||||||
|
@ -83,6 +87,16 @@ function boinctranslate_admin_settings(&$form_state) {
|
||||||
translations from the resources at the top of the list will be overridden
|
translations from the resources at the top of the list will be overridden
|
||||||
by any matching translations found in resources further down the list.'),
|
by any matching translations found in resources further down the list.'),
|
||||||
);
|
);
|
||||||
|
if (user_access('update official BOINC translations')) {
|
||||||
|
$form['transifex']['boinc_translate_transifex_boinc_drupal_resource'] = array(
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => t('BOINC Drupal resource'),
|
||||||
|
'#default_value' => $default['transifex_boinc_drupal_resource'],
|
||||||
|
'#description' => t('The portion of the Transifex URL that identifies
|
||||||
|
the standard BOINC resource to use for translation of the public
|
||||||
|
content defined in the Drupal system.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
$form['transifex']['boinc_translate_transifex_project_name'] = array(
|
$form['transifex']['boinc_translate_transifex_project_name'] = array(
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#title' => t('Project-specific Transifex project'),
|
'#title' => t('Project-specific Transifex project'),
|
||||||
|
|
|
@ -373,15 +373,18 @@ function boinctranslate_update_official_boinc_translations() {
|
||||||
$project_name = variable_get(
|
$project_name = variable_get(
|
||||||
'boinc_translate_transifex_standard_name', ''
|
'boinc_translate_transifex_standard_name', ''
|
||||||
);
|
);
|
||||||
|
$drupal_resource = variable_get(
|
||||||
|
'boinc_translate_transifex_boinc_drupal_resource', ''
|
||||||
|
);
|
||||||
|
|
||||||
if ($project_name) {
|
if ($project_name AND $drupal_resource) {
|
||||||
// Create or update the translation source, if needed
|
// Create or update the translation source, if needed
|
||||||
$source_exists = FALSE;
|
$source_exists = FALSE;
|
||||||
$path = "project/{$project_name}/resources";
|
$path = "project/{$project_name}/resources";
|
||||||
$resources = boinctranslate_transifex_request($path);
|
$resources = boinctranslate_transifex_request($path);
|
||||||
if ($resources AND is_array($resources)) {
|
if ($resources AND is_array($resources)) {
|
||||||
foreach ($resources as $resource) {
|
foreach ($resources as $resource) {
|
||||||
if ($resource['slug'] == 'drupal-generic') {
|
if ($resource['slug'] == $drupal_resource) {
|
||||||
$source_exists = TRUE;
|
$source_exists = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -390,8 +393,8 @@ function boinctranslate_update_official_boinc_translations() {
|
||||||
// Create the source
|
// Create the source
|
||||||
$path = "project/{$project_name}/resources";
|
$path = "project/{$project_name}/resources";
|
||||||
$post = array(
|
$post = array(
|
||||||
'slug' => 'drupal-generic',
|
'slug' => $drupal_resource,
|
||||||
'name' => 'Drupal-Generic',
|
'name' => 'locale/templates/BOINC-Drupal.pot',
|
||||||
'i18n_type' => 'PO',
|
'i18n_type' => 'PO',
|
||||||
'category' => 'Drupal',
|
'category' => 'Drupal',
|
||||||
'content' => boinctranslate_get_po('en', 'boinc'),
|
'content' => boinctranslate_get_po('en', 'boinc'),
|
||||||
|
@ -399,7 +402,7 @@ function boinctranslate_update_official_boinc_translations() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Update the source
|
// Update the source
|
||||||
$path = "project/{$project_name}/resource/drupal-generic/content";
|
$path = "project/{$project_name}/resource/{$drupal_resource}/content";
|
||||||
$post = array(
|
$post = array(
|
||||||
'content' => boinctranslate_get_po('en', 'boinc')
|
'content' => boinctranslate_get_po('en', 'boinc')
|
||||||
);
|
);
|
||||||
|
@ -415,21 +418,6 @@ function boinctranslate_update_official_boinc_translations() {
|
||||||
else {
|
else {
|
||||||
drupal_set_message('Established new translation resource at Transifex');
|
drupal_set_message('Established new translation resource at Transifex');
|
||||||
}
|
}
|
||||||
// Ensure this exported project resource is in the config
|
|
||||||
$resource_config = (variable_get(
|
|
||||||
'boinc_translate_transifex_standard_resources', ''
|
|
||||||
));
|
|
||||||
$resource_names = boinctranslate_parse_resources($resource_config);
|
|
||||||
if (!in_array('drupal-generic', $resource_names)) {
|
|
||||||
$resource_config .= "\n" . 'drupal-generic';
|
|
||||||
variable_set(
|
|
||||||
'boinc_translate_transifex_standard_resources',
|
|
||||||
$resource_config
|
|
||||||
);
|
|
||||||
drupal_set_message(
|
|
||||||
'Added drupal-generic to BOINC resources'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Try to export translations for all enabled languages
|
// Try to export translations for all enabled languages
|
||||||
foreach ($enabled_languages as $langcode => $language_name) {
|
foreach ($enabled_languages as $langcode => $language_name) {
|
||||||
if ($langcode == en) {
|
if ($langcode == en) {
|
||||||
|
@ -437,7 +425,7 @@ function boinctranslate_update_official_boinc_translations() {
|
||||||
}
|
}
|
||||||
$po_file = boinctranslate_get_po($langcode, 'boinc');
|
$po_file = boinctranslate_get_po($langcode, 'boinc');
|
||||||
if ($po_file) {
|
if ($po_file) {
|
||||||
$path = "project/{$project_name}/resource/drupal-generic/translation/{$langcode}";
|
$path = "project/{$project_name}/resource/{$drupal_resource}/translation/{$langcode}";
|
||||||
$post = array(
|
$post = array(
|
||||||
'content' => $po_file,
|
'content' => $po_file,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue