init.rb in rwdshell-0.9 vs init.rb in rwdshell-0.92
- old
+ new
@@ -1,9 +1,9 @@
#***********************************************************************
#* Rwd/Tinker -- A Ruby program for the RudyWebDialog.
-#* Copyright (c) 2004 by Steven Gibson. All Rights Reserved.
+#* Copyright (c) 2004, 2005 by Steven Gibson. All Rights Reserved.
#*
#* This library is free software; you can redistribute it and/or
#* modify it under the terms of the GNU General Public
#* License as published by the Free Software Foundation; either
#* .
@@ -41,11 +41,24 @@
fileA.close
end
end
end
end
-
+ def loadguifile(d)
+ a = Array.new(Dir[d].entries.sort)
+ #loop through and get the files names
+ a.each do |x|
+ #adjust the filters to the files you want to see...
+ if(!test(?d,x))
+ # only rwd files
+ if x =~ /rb|rwd|txt/
+ load x #opens the file thats in fileName and reads it
+ $tempdoc += $rwdguivar # adds the file into the doc string
+ end
+ end
+ end
+ end
# Read in the configuration files
Dir.chdir("configuration") #changes the current working directory
@@ -57,12 +70,12 @@
} #closing block
# END of configuration reading
Dir.chdir($progdir) # change back to top program directory
- # build the Language hash file from the parts
- startlangdir = @@langdir +"/" + $lang
+ # build the English Language hash file from the parts
+ startlangdir = @@langdir +"/" + "en"
#get a list of the files and subdirectories on the starting directory only
alanghash = Array.new(Dir[startlangdir].entries.sort)
#loop through the list, ignore the files and add all new directories found
alanghash.each do |x|
#if a directory...
@@ -91,11 +104,67 @@
fileLangHash.write($tempdoc) #writes the contents of doc into the file
fileLangHash.close
# END of Lang building
$tempdoc = " "
Dir.chdir($progdir) # change back to top program directory
+
+ # build the local Language hash file from the parts
+ startlangdir = @@langdir +"/" + $lang
+ #get a list of the files and subdirectories on the starting directory only
+ alanghash = Array.new(Dir[startlangdir].entries.sort)
+ #loop through the list, ignore the files and add all new directories found
+ alanghash.each do |x|
+ #if a directory...
+ if(test(?d,x))
+ # add to the original list of directories
+ @@tmproot = x + "/**"
+ #adds the new ones to the array
+ blanghash = Dir[@@tmproot].entries.sort
+ blanghash.each do |x|
+ if(test(?d,x))
+ alanghash.push(x) #appends to the end of the array...
+ end
+ end
+ end
+ end
+ alanghash.each do |x|
+ #if it is a file...
+ if(!test(?d,x))
+ alanghash.delete(x)
+ else #it is a directory...
+ findfiles(x + "/**")
+ end
+ end
+ filelocalLangHash=File.open(LocalLangHashFile,"w") #deletes and opens a the file in fileName
+ filelocalLangHash.write($tempdoc) #writes the contents of doc into the file
+ filelocalLangHash.close
+
+$tempdoc = " "
+
+ Dir.chdir($progdir) # change back to top program directory
+
+ # build the language hash constant object from the lang parts
+ #get a list of the files in lang directory only
+ alangfile = Dir.new(@@langdir).entries.sort.reverse.delete_if { |x| ! (x =~ /rb$/) }
+ alangfile.length.times{
+ fileName = alangfile.pop
+ Dir.chdir($progdir)
+ Dir.chdir(@@langdir)
+ fileLangA=File.open("#{fileName}","r") #opens the file thats in fileName as read only
+ $tempdoc += fileLangA.read #reads the file into the doc string
+ fileLangA.close
+ }
+
+Dir.chdir($progdir)
+ fileLangB=File.open(LangNameFile,"w") #deletes and opens a the file in fileName
+ fileLangB.write($tempdoc) #writes the contents of doc into the file
+ fileLangB.close
+ load LangNameFile # load the file
+
+ $tempdoc = " "
+
# build the actual program from the code parts
#get a list of the files and subdirectories on the starting directory only
a = Array.new(Dir[@@codedir].entries.sort)
#loop through the list, ignore the files and add all new directories found
a.each do |x|
@@ -149,10 +218,10 @@
#if it is a file...
if(!test(?d,x))
a.delete(x)
else #it is a directory...
- findfiles(x + "/**")
+ loadguifile(x + "/**")
end
end
fileB=File.open(RWDFile,"w") #deletes and opens a the file in fileName
fileB.write($tempdoc) #writes the contents of doc into the file