--- C:\Documents and Settings\Marc\Desktop\language_sections_original.module	wo okt  8 02:50:49 2008
+++ C:\Documents and Settings\Marc\Desktop\language_sections_trigger.module	di nov 18 11:06:26 2008
@@ -17,13 +17,13 @@
 }
 
 // Get language code for current language (handles Drupal 5/6 compatibility).
-function _language_sections_get_language() {
+function _language_sections_get_language($prefix) {
   $versions = explode('.', VERSION, 2);
   switch($versions[0]) {
     case 6:
       global $language;
-      return $language->language;
-
+      return (variable_get($prefix.'trigger', 0) == 0 ? $language->language : $language->prefix);
+      
     default:
       global $locale;
       return $locale;
@@ -62,7 +62,7 @@
       // Build the output string, keeping only the parts we want...
       // Todo: A better preg pattern - this approach is less than optimal with a large number of languages.
       // Todo: 'qq' and 'qz' codes should probably be configurable.
-      $current_language = _language_sections_get_language();
+      $current_language = _language_sections_get_language($prefix);
       $out = $matches[0]; $default = true;
       for($i = $n1; $i < count($matches); $i += $n3) {
         switch ($matches[$i]) {
@@ -145,6 +145,15 @@
     '#description' => t("If enabled above, this pattern will be used for finding the $mod_name in the text. Initially, this is set to the $mod_name module's internal default. NOTE: You should not change the number of parenthesised groups in the expression."),
   );
 
+  $field = $prefix.'trigger';
+  $form[$mod_id][$field] = array(
+    '#type' => 'radios',
+    '#title' => t("Language trigger"),
+    '#options' => array('0' => t('Language code'), '1' => t('Language url prefix')),
+    '#default_value' => variable_get($field, 0),
+    '#description' => t("Choose if the language sections should be triggered by using the offical RFC 4646 language code (ie. '== en ==' or '== en-US =='), or the Drupal language prefix setting (ie. '== english ==')."),
+  );
+
   return $form;
 }
 
