Actualy this is quiet tricky, as there are many referances that needs to be changed to make the modules easy rename, moveable and parallel reuseable.
I've been trying to make a solusion, and I actualy belive the following is quiet useable.
To start from xoops_version.php.
This code will automatically change the dirname to the name of the dir the module is currently resident in:
(Put it in the top of the xoops_version.php file)
 // First split and Reverse current file path. 
$pathparts = array_reverse(explode("/", $_SERVER["SCRIPT_FILENAME"]));  
// Then select the correct part as the dirname, and make sure it's a constant. 
$modversion['dirname'] = constant($pathparts[1]); 
// Aditionally prepare a prefix for the language constants. 
$VarPrefix = '_MI_'.strtoupper($pathparts[1]); 
// And use the language constants 
$modversion['name'] = constant($VarPrefix.'_NAME'); 
$modversion['description'] = constant($VarPrefix.'_DESC');  
In the language file modinfo.php I have the following code:
 // Prepare a prefix for the language constants. 
$pathparts = array_reverse(explode("/", $_SERVER["SCRIPT_FILENAME"]));  
$VarPrefix = '_MI_'.strtoupper($pathparts[1]); 
// Make all the defines. 
define($VarPrefix.'_NAME', 'ModuleName'); 
define($VarPrefix.'_DESC', 'A description of the module.');  
In the languagefile for all other modules, eg. /language/english/main.php I have the following
 $VarPrefix = '_MD_'.strtoupper($xoopsModule->getVar('dirname')); 
 
define($VarPrefix.'_GREETING', 'Hello, '); 
define($VarPrefix.'_ANONYMOUS','My friend, please log in!');  
In the module, blocks etc. I use the language constants like this:
 $VarPrefix = '_MD_'.strtoupper($xoopsModule->getVar('dirname')); 
 
$xoopsTpl->assign('greeting', constant($VarPrefix.'_GREETING')); 
 
$uname = !empty($xoopsUser) ? $xoopsUser->getVar('uname','E') :  constant($VarPrefix.'_ANONYMOUS');  
The important part to remember is to use 
constant() around the language variables.
I also use 
 $ModuleUrlPath = XOOPS_URL."/modules/".$xoopsModule->getVar('dirname'); 
     
$ModuleRootPath = XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar('dirname');  
in modules, blocks and admin, aswell as in smarty - to make it easier to always use the correct path.
I hope I remembered everything important to explain the working of this.
Note: I'm not sure if it's okay to have $pathpart and $VarPrefix without module prefixex. Didn't have time to go into that yet.
I've not tried it together with the database, comments, search etc. (as I haven't used either of those yet), but I hope others will provide examples, and improve on this code.
I hope you can use this code. 
I probably won't have time to look further at this, the comming day or so. But rest assured that I'll be back! 
 
 Best regards,
Daigoro