diff options
Diffstat (limited to 'modules/translation/translation.module')
-rw-r--r-- | modules/translation/translation.module | 92 |
1 files changed, 52 insertions, 40 deletions
diff --git a/modules/translation/translation.module b/modules/translation/translation.module index 794bd35f5..b353aa4ec 100644 --- a/modules/translation/translation.module +++ b/modules/translation/translation.module @@ -2,21 +2,21 @@ /** * @file - * Manages content translations. + * Manages content translations. * - * Translations are managed in sets of posts, which represent the same - * information in different languages. Only content types for which the - * administrator explicitly enabled translations could have translations - * associated. Translations are managed in sets with exactly one source - * post per set. The source post is used to translate to different - * languages, so if the source post is significantly updated, the - * editor can decide to mark all translations outdated. + * Translations are managed in sets of posts, which represent the same + * information in different languages. Only content types for which the + * administrator has explicitly enabled translations could have translations + * associated. Translations are managed in sets with exactly one source post + * per set. The source post is used to translate to different languages, so if + * the source post is significantly updated, the editor can decide to mark all + * translations outdated. * - * The node table stores the values used by this module: - * - 'tnid' is the translation set id, which equals the node id - * of the source post. - * - 'translate' is a flag, either indicating that the translation - * is up to date (0) or needs to be updated (1). + * The node table stores the values used by this module: + * - tnid: Integer for the translation set ID, which equals the node ID of the + * source post. + * - translate: Integer flag, either indicating that the translation is up to + * date (0) or needs to be updated (1). */ /** @@ -70,11 +70,18 @@ function translation_menu() { } /** - * Menu access callback. + * Access callback: Checks that the user has permission to 'translate content'. * - * Only display translation tab for node types, which have translation enabled - * and where the current node is not language neutral (which should span - * all languages). + * Only displays the translation tab for nodes that are not language-neutral + * of types that have translation enabled. + * + * @param $node + * A node object. + * + * @return + * TRUE if the translation tab should be displayed, FALSE otherwise. + * + * @see translation_menu() */ function _translation_tab_access($node) { if ($node->language != LANGUAGE_NONE && translation_supported_type($node->type) && node_access('view', $node)) { @@ -107,7 +114,7 @@ function translation_permission() { } /** - * Implements hook_form_FORM_ID_alter(). + * Implements hook_form_FORM_ID_alter() for node_type_form(). */ function translation_form_node_type_form_alter(&$form, &$form_state) { // Add translation option to content type form. @@ -117,10 +124,12 @@ function translation_form_node_type_form_alter(&$form, &$form_state) { } /** - * Implements hook_form_BASE_FORM_ID_alter(). + * Implements hook_form_BASE_FORM_ID_alter() for node_form(). * - * This function alters language fields on node edit forms when a translation is - * about to be created. + * Alters language fields on node edit forms when a translation is about to be + * created. + * + * @see node_form() */ function translation_form_node_form_alter(&$form, &$form_state) { if (translation_supported_type($form['#node']->type)) { @@ -200,9 +209,9 @@ function translation_form_node_form_alter(&$form, &$form_state) { /** * Implements hook_node_view(). * - * Display translation links with native language names, if this node is part of - * a translation set. If no language provider is enabled "fall back" to the - * simple links built through the result of translation_node_get_translations(). + * Displays translation links with language names if this node is part of a + * translation set. If no language provider is enabled, "fall back" to simple + * links built through the result of translation_node_get_translations(). */ function translation_node_view($node, $view_mode) { // If the site has no translations or is not multilingual we have no content @@ -373,7 +382,7 @@ function translation_node_update($node) { /** * Implements hook_node_validate(). * - * Ensure that duplicate translations can not be created for the same source. + * Ensures that duplicate translations can't be created for the same source. */ function translation_node_validate($node, $form) { // Only act on translatable nodes with a tnid or translation_source. @@ -397,8 +406,10 @@ function translation_node_delete($node) { } /** - * Remove a node from its translation set (if any) - * and update the set accordingly. + * Removes a node from its translation set and updates accordingly. + * + * @param $node + * A node object. */ function translation_remove_from_set($node) { if (isset($node->tnid)) { @@ -432,17 +443,18 @@ function translation_remove_from_set($node) { } /** - * Get all nodes in a translation set, represented by $tnid. + * Gets all nodes in a given translation set. * * @param $tnid - * The translation source nid of the translation set, the identifier - * of the node used to derive all translations in the set. + * The translation source nid of the translation set, the identifier of the + * node used to derive all translations in the set. + * * @return - * Array of partial node objects (nid, title, language) representing - * all nodes in the translation set, in effect all translations - * of node $tnid, including node $tnid itself. Because these are - * partial nodes, you need to node_load() the full node, if you - * need more properties. The array is indexed by language code. + * Array of partial node objects (nid, title, language) representing all + * nodes in the translation set, in effect all translations of node $tnid, + * including node $tnid itself. Because these are partial nodes, you need to + * node_load() the full node, if you need more properties. The array is + * indexed by language code. */ function translation_node_get_translations($tnid) { if (is_numeric($tnid) && $tnid) { @@ -468,21 +480,21 @@ function translation_node_get_translations($tnid) { * Returns whether the given content type has support for translations. * * @return - * Boolean value. + * TRUE if translation is supported, and FALSE if not. */ function translation_supported_type($type) { return variable_get('language_content_type_' . $type, 0) == TRANSLATION_ENABLED; } /** - * Return paths of all translations of a node, based on - * its Drupal path. + * Returns the paths of all translations of a node, based on its Drupal path. * * @param $path * A Drupal path, for example node/432. + * * @return - * An array of paths of translations of the node accessible - * to the current user keyed with language codes. + * An array of paths of translations of the node accessible to the current + * user, keyed with language codes. */ function translation_path_get_translations($path) { $paths = array(); |