--- brilliant_gallery/brilliant_gallery.module	2009-01-15 14:40:12.000000000 -0200
+++ brilliant_gallery.module	2009-01-16 01:53:02.000000000 -0200
@@ -344,8 +344,8 @@
   $galleryfolder = variable_get('brilliant_gallery_folder', '');
   $path          = url(file_directory_path() .'/'. $galleryfolder, array('absolute' => TRUE));
   # url() ads i18n codes to the URL ... we need to remove them here...
-  if ($langcode <> '') {
-    $path = str_replace('/'. $langcode .'/', '/', $path);
+  if ($langprefix <> '') {
+    $path = str_replace('/'. $langprefix .'/', '/', $path);
   }
   # Non-clean URLs need removing ?q=
   $path = str_replace("?q=", "", $path);
@@ -412,8 +412,8 @@
           # Get this module's path:
           $modulepath = url(drupal_get_path('module', 'brilliant_gallery'), array('absolute' => TRUE));
           # url() ads i18n codes to the URL ... we need to remove them here...
-          if ($langcode <> '') {
-            $modulepath = str_replace('/'. $langcode .'/', '/', $modulepath);
+          if ($langprefix <> '') {
+            $modulepath = str_replace('/'. $langprefix .'/', '/', $modulepath);
           }
           # Non-clean URLs need removing ?q=
           $modulepath = str_replace("?q=", "", $modulepath);
@@ -531,9 +531,10 @@
     cleantmpdir();
   }
   # Patching a possible problem with i18n
-  $langcode = '';
-  if (function_exists('i18n_get_lang')) {
-    $langcode = i18n_get_lang();
+  if ( function_exists('i18n_get_lang') ) { 
+	$langprefix = i18n_language_property(i18n_get_lang(), 'prefix');
+  } else {
+	$langprefix = '';
   }
   #$result = '</p>';
   $result = '';
@@ -598,8 +599,8 @@
   $fullresolutionmaxwidth = variable_get('brilliant_gallery_maxwidth', '1000');
   $path = url(file_directory_path() .'/'. $galleryfolder, array('absolute' => TRUE));
   // url() ads i18n codes to the URL ... we need to remove them here...
-  if ($langcode <> '') {
-    $path = str_replace('/'. $langcode .'/', '/', $path);
+  if ($langprefix <> '') {
+    $path = str_replace('/'. $langprefix .'/', '/', $path);
   }
 
   // Non-clean URLs need removing ?q=
@@ -719,8 +720,8 @@
       # Get this module's path:
       $modulepath = url(drupal_get_path('module', 'brilliant_gallery'), array('absolute' => TRUE));
       # url() ads i18n codes to the URL ... we need to remove them here...
-      if ($langcode <> '') {
-        $modulepath = str_replace('/'. $langcode .'/', '/', $modulepath);
+      if ($langprefix <> '') {
+        $modulepath = str_replace('/'. $langprefix .'/', '/', $modulepath);
       }
       # Non-clean URLs need removing ?q=
       $modulepath = str_replace("?q=", "", $modulepath);
@@ -766,8 +767,8 @@
       /*
                          $modulepath = url(drupal_get_path('module', 'brilliant_gallery'), array('absolute' => TRUE));
                          # url() ads i18n codes to the URL ... we need to remove them here...
-                           if ( $langcode <> '' ) {
-                                $modulepath = str_replace( '/' . $langcode . '/', '/', $modulepath );
+                           if ( $langprefix <> '' ) {
+                                $modulepath = str_replace( '/' . $langprefix . '/', '/', $modulepath );
                               }
                          # Non-clean URLs need removing ?q=
                            $modulepath = str_replace( "?q=", "",  $modulepath );
