summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Reyero2009-01-10 10:16:28 (GMT)
committer Jose Reyero2009-01-10 10:16:28 (GMT)
commit5196f381c9549e75fe83b6d008b9baf3155caa74 (patch)
tree30a704620cebad4b5777e85251affd6240cec895
parente40ff52f0fc33a6646bc5bc712332cbf03e94115 (diff)
- Added additional language support level, by stella, Roger Lopez, #349193
-rw-r--r--CHANGELOG.txt2
-rw-r--r--i18n.admin.inc13
-rw-r--r--i18n.install1
-rw-r--r--i18n.module59
4 files changed, 55 insertions, 20 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index ca538ff..a64ada6 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -5,12 +5,12 @@ TO DO
- Reimplement: Choose an existing node as a translation, http://drupal.org/node/295682
- Taxonomy autocomplete, localized terms
- Add language filter to search form
-- Allow hiding of *all* node language links
- Support for translation of some node strings, #313840
- Better information for theme variables on settings page
6.x-beta6 to .........
----------------------
+- Added additional language support level, by stella, Roger Lopez, #349193
- Fixed duplicated 'ts' function (CiviCRM), renamed to 'i18nstrings_ts', by mfb, #298154
- Move all admin settings to one place under Language, by stella, #343557
- CCK file fields not removed anymore when one of the translations is deleted, #313613
diff --git a/i18n.admin.inc b/i18n.admin.inc
index 638d6ca..16db6be 100644
--- a/i18n.admin.inc
+++ b/i18n.admin.inc
@@ -29,6 +29,19 @@ function i18n_admin_settings() {
'#options' => _i18n_selection_mode(),
'#description' => t('Determines which content to show depending on the current page language and the default language of the site.'),
);
+
+ // Node translation links setting.
+ $form['links'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Content translation links'),
+ );
+ $form['links']['i18n_hide_translation_links'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Hide content translation links'),
+ '#description' => t('Hide the links to translations in content body and teasers. If you choose this option, switching language will only be available from the language switcher block.'),
+ '#default_value' => variable_get('i18n_hide_translation_links', 0),
+ );
+
return system_settings_form($form);
}
diff --git a/i18n.install b/i18n.install
index c60fc8c..108b5fc 100644
--- a/i18n.install
+++ b/i18n.install
@@ -50,6 +50,7 @@ function i18n_install() {
function i18n_uninstall() {
drupal_uninstall_schema('i18n');
+ variable_del('i18n_hide_translation_links');
}
/**
diff --git a/i18n.module b/i18n.module
index 0235e91..deb37a2 100644
--- a/i18n.module
+++ b/i18n.module
@@ -17,7 +17,7 @@
define('LANGUAGE_SUPPORT_NONE', 0);
define('LANGUAGE_SUPPORT_NORMAL', 1);
define('LANGUAGE_SUPPORT_EXTENDED', 2);
-
+define('LANGUAGE_SUPPORT_EXTENDED_NOT_DISPLAYED', 3);
/**
* Implementation of hook_init().
*
@@ -188,24 +188,28 @@ function i18n_translation_link_alter(&$links, $path) {
// Check for a node related path, and for its translations.
if ((preg_match("!^node/([0-9]+)(/.+|)$!", $path, $matches)) && ($node = node_load((int)$matches[1])) && !empty($node->tnid)) {
- $languages = language_list();
- $extended = array();
- foreach (translation_node_get_translations($node->tnid) as $langcode => $translation_node) {
- if (!isset($links[$langcode]) && isset($languages[$langcode])) {
- $extended[$langcode] = array(
- 'href' => 'node/'. $translation_node->nid . $matches[2],
- 'language' => $language,
- 'language_icon' => $languages[$langcode],
- 'title' => $languages[$langcode]->native,
- 'attributes' => array('class' => 'language-link'),
- );
+ // make sure language support is set to LANUAGE_SUPPORT_EXTENDED, so links
+ // dont get added for LANGUAGE_SUPPORT_EXTENDED_NOT_DISPLAYED
+ if (variable_get('i18n_node_'. $node->type, LANGUAGE_SUPPORT_NORMAL) == LANGUAGE_SUPPORT_EXTENDED) {
+ $languages = language_list();
+ $extended = array();
+ foreach (translation_node_get_translations($node->tnid) as $langcode => $translation_node) {
+ if (!isset($links[$langcode]) && isset($languages[$langcode])) {
+ $extended[$langcode] = array(
+ 'href' => 'node/'. $translation_node->nid . $matches[2],
+ 'language' => $language,
+ 'language_icon' => $languages[$langcode],
+ 'title' => $languages[$langcode]->native,
+ 'attributes' => array('class' => 'language-link'),
+ );
+ }
}
+ // This will run after languageicon module, so we add icon in case that one is enabled.
+ if ($extended && function_exists('languageicons_translation_link_alter')) {
+ languageicons_translation_link_alter($extended, $path);
+ }
+ $links = array_merge($links, $extended);
}
- // This will run after languageicon module, so we add icon in case that one is enabled.
- if ($extended && function_exists('languageicons_translation_link_alter')) {
- languageicons_translation_link_alter($extended, $path);
- }
- $links = array_merge($links, $extended);
}
}
@@ -217,11 +221,27 @@ function i18n_translation_link_alter(&$links, $path) {
function i18n_link_alter(&$links, $node) {
global $language;
+ $language_support = variable_get('i18n_node_'. $node->type, LANGUAGE_SUPPORT_NORMAL);
+
+ // Hide node translation links.
+ if (variable_get('i18n_hide_translation_links', 0) == 1) {
+ foreach ($links as $module => $link) {
+ if (strpos($module, 'node_translation') === 0) {
+ unset($links[$module]);
+ }
+ }
+ }
+
if (!empty($node->tnid)) {
foreach (array_keys(i18n_language_list('extended')) as $langcode) {
$index = 'node_translation_'. $langcode;
if (!empty($links[$index])) {
- $links[$index]['language'] = $language;
+ if ($language_support != LANGUAGE_SUPPORT_EXTENDED && $links[$index]['language']->enabled == 0) {
+ unset($links[$index]);
+ }
+ else {
+ $links[$index]['language'] = $language;
+ }
}
}
}
@@ -806,6 +826,7 @@ function i18n_array_variable_set($name, $element, $value) {
function _i18n_content_language_options() {
return array(
LANGUAGE_SUPPORT_NORMAL => t('Normal - All enabled languages will be allowed.'),
- LANGUAGE_SUPPORT_EXTENDED => t('Extended - All defined languages will be allowed.')
+ LANGUAGE_SUPPORT_EXTENDED => t('Extended - All defined languages will be allowed.'),
+ LANGUAGE_SUPPORT_EXTENDED_NOT_DISPLAYED => t('Extended, but not displayed - All defined languages will be allowed for input, but not displayed in links.'),
);
}