function language_translations_drush_command in Drush Language Commands 7
Implements of hook_drush_command().
@See drush_parse_command() for a list of recognized keys.
Return value
array An associative array describing your command(s). An associative array describing your command(s).
File
- ./
language_translations.drush.inc, line 19 - Drush language commands related to translations.
Code
function language_translations_drush_command() {
$commands = array();
// Show enabled locale groups.
$commands['language-groups-info'] = array(
'description' => "Print a list with enabled locale groups.",
'aliases' => array(
'language-groups',
'language-info',
),
'callback' => 'drush_language_translations_groups_info',
);
// Import translations.
$commands['language-import-translations'] = array(
'description' => "Import translations to one or more locale groups.",
'arguments' => array(
'langcode' => "The langcode of the language to be imported.",
'path' => "Path to a directory with the translation files or URL of translation file from external site. Can be a file-name if one locale-group is imported.",
),
'options' => array(
'groups' => array(
'description' => "Comma separated list of locale groups. Defaults to 'all'.",
'value' => 'optional',
),
'replace' => array(
'description' => "Replace existing translations in the database. Defaults to 'false'.",
'value' => 'optional',
),
),
'examples' => array(
'Import all locale groups' => "\$ drush language-import-translations fr sites/all/translations/fr" . "\n" . "Reads from directory with filename pattern <locale-group>.<langcode>.po (default.fr.po)",
'Import specific locale groups, replace existing translations' => "\$ drush language-import-translations fr sites/all/translations/fr --groups=default,menu --replace",
'Import menu locale group from file' => "\$ drush language-import-translations fr sites/all/translations/fr/menu.fr.po --groups-menu",
),
'aliases' => array(
'langimp',
'language-import',
),
'callback' => 'drush_language_translations_import',
'drupal dependencies' => array(
'locale',
),
);
// Export translations.
$commands['language-export-translations'] = array(
'description' => "Export translations from one or more locale groups. Note: To export only custom translations install l10n_update and use language-export-translations-ng",
'arguments' => array(
'langcode' => array(
'description' => "The langcode of the language to be exported.",
'value' => 'required',
),
'path' => "Path to a directory where the translation files should be saved. Can be a file-name if one locale-group is exported.",
),
'options' => array(
'groups' => array(
'description' => "Comma separated list of locale groups. Defaults to 'all'.",
'value' => 'optional',
),
'replace' => array(
'description' => "Replace existing translations in the file-system. Defaults to 'false'.",
'value' => 'optional',
),
'sort' => array(
'description' => "Sorts the generated po file by source and context, defaults to 'true'.",
'value' => 'optional',
),
'filter' => array(
'description' => "Removes empty translations from the generated po file, defaults to 'true'.",
'value' => 'optional',
),
),
'examples' => array(
'Export all locale groups' => "\$ drush language-export-translations fr sites/all/translations/fr" . "\n" . "Saves to directory with filename pattern <locale-group>.<langcode>.po (default.fr.po)",
'Export specific locale groups, replace existing export files' => '$ drush language-export-translations fr sites/all/translations/fr --groups=default,menu --replace',
),
'aliases' => array(
'langexp',
'language-export',
),
'callback' => 'drush_language_translations_export',
'drupal dependencies' => array(
'locale',
),
);
// Refresh translations.
$commands['language-refresh-translations'] = array(
'description' => "Refresh translations from one or more locale groups.",
'options' => array(
'groups' => array(
'description' => "Comma separated list of locale groups. Defaults to 'all'.",
'value' => 'optional',
),
'delete' => array(
'description' => "Delete left over strings.",
),
),
'examples' => array(
'Refresh strings in all locale groups' => '$ drush language-export-translations fr',
'Refresh strings in specific locale groups, delete unused' => '$ drush language-export-translations fr --groups=default,menu --delete',
),
'aliases' => array(
'language-refresh',
),
'callback' => 'drush_language_translations_refresh',
'drupal dependencies' => array(
'locale',
'i18n_string',
),
);
$commands['language-export-translations-ng'] = array(
'description' => "Export string of a language and textgroup as a .po file",
'arguments' => array(
'langcode' => 'The langcode of the language to exported.',
'.po file' => 'Path to a .po file. Use "-" or /dev/stdout to use standard output.',
),
'examples' => array(
'Export the french menu translation' => 'drush langexp --group="menu" fr menu.fr.po',
),
'options' => array(
'group' => array(
'description' => 'The text group to export. Defaults to "default".',
'value' => 'optional',
),
'status' => array(
'description' => 'The statuses to export, defaults to \'customized\'.' . "\n" . 'This can be a comma-separated list of \'customized\', \'not-customized\', \'not-translated\', or \'all\'.',
'value' => 'optional',
),
'force' => array(
'description' => 'Write file even if no translations. Defaults to 1.',
'value' => 'optional',
),
),
'aliases' => array(
'langexpng',
'language-export-ng',
),
'callback' => 'drush_language_translations_export_ng',
'drupal dependencies' => array(
'locale',
'l10n_update',
),
);
$commands['language-export-all-translations-ng'] = array(
'description' => 'Export all translations to files',
'options' => array(
'langcodes' => array(
'description' => 'The language codes to export. Defaults to all enabled languages.',
'value' => 'optional',
),
'groups' => array(
'description' => "Comma separated list of text groups. If none given, all are exported.",
'value' => 'optional',
),
'file-pattern' => array(
'description' => 'The target file pattern. Defaults to \'../translations/custom/%group.%language.po(t)\' (pot if --status=not-translated is given).' . "\n" . 'Note that this is the only place where this module\'s auto-importing works.',
'value' => 'optional',
),
'status' => array(
'description' => 'The statuses to export, defaults to \'customized\'.' . "\n" . 'This can be a comma-separated list of \'customized\', \'not-customized\', \'not-translated\', or \'all\'.',
'value' => 'optional',
),
'force' => array(
'description' => 'Write file even if no translations. Defaults to 1.',
'value' => 'optional',
),
),
'aliases' => array(
'langexpallng',
'language-export-all-ng',
),
'callback' => 'drush_language_translations_export_all_ng',
'drupal dependencies' => array(
'locale',
'l10n_update',
),
);
return $commands;
}