aUCBLogo Demos and Tests / translate_help_examples


setCaseIgnored false

be translate_help_examples
clearText
   
language="de
   
load word language "/startup.lg
   
startup_de
   
load "en/startup.lg
   
startup_en
   
setCaseIgnored false
   
translation_en_de=reverse translation_de
   
foreach tolist translation_en
   
[   t=translation_en_de.(?.2)
      
if != []
      
[   i=?.1
;         (pr i t)
         
translation_en_de.i=t
         
i=lowercase ?.1
         
translation_en_de.i=t
         
i=uppercase ?.1
         
translation_en_de.i=t
      
]
   
]
   
translation_en_de=(merge 
      
lowerCase translation_en_de
      
translation_en_de)
   
translation_en_de=(merge 
      
upperCase translation_en_de
      
translation_en_de)
;   print translation_en_de

   
changeDir "D:\temp\help_de
   
fl=(files [aucblogo_all_de.hrf.txt])
   
foreach fl
   
[   translateFile ?
   
]
   
   
be translateFile in
      
in_en="aucblogo.hrf
      
openRead in_en
      
setReader in_en
      
le=array readListFlatRaw
      
setWriter []
      
close in_en

      
out=(word in ".txt)
      
(print in "=> out)
      
openRead in
      
setReader in
      
ld=array readListFlatRaw
      
setReader []
      
close in

      
l=le
      
cnt=count l
      
sections=[]
      
examples=Table 1021
      
esectab=Table 1021
      
linenr=1
      
example=[]
      
exline="
      
exnr=0
      
for [cnt]
      
[   w=l.i
         
ifelse cnt-3
         
[   ifelse (and w=="
            
l.(i+1)=="\    l.(i+2)=="\   )
            
[   i=i+3
;               (print)
               
linenr=linenr+1
;               (type "#\   \   )
               
exline="#\   \   
               
while [and not (and l.== "
                      
(first l.(i+1)) !="\    
                      
(first l.(i+2)) !="\    )
                  
i<cnt-2]
               
[   w=l.i
                  
t=translation_en_de.w
                  
ifelse != [] 
                  
[   w=t
                  
][   
                  
]
;                  (type w)
                  
exline=lput w exline
                  
i=i+1
               
]
               
i=i-1
               
example=lput exline example
            
][
               
ifelse (and w=="
                      
l.(i+1)  !="\    
               
(first l.(i+1)) !="= 
               
(first l.(i+1)) !="-
               
(first l.(i+2)) !="\    )
               
[
                  
examples.exnr=example
                  
example=[]               
                  
exnr=exnr+1
;                  (type w)
;                  (print)
                  
linenr=linenr+1
                  
j=i+2
                  
ifelse (and l.!="
                     
;[l.(j+1) !="
                     ;]
                     
[(first l.(j+1)) !="\   j<cnt-1)
                  
[   title="   ;(word linenr "\   )
;                     (type title)
                  
][   title=[]
                  
]
                  
while [(and l.!="
                     
j<cnt-1)]
                  
[   title=lput l.j title
;                     (type l.j)
                     
j=j+1
                  
]
                  
if (and 
                     
(first l.(j+1)) != "-
                     
(first l.(j+1)) != "=
                     
j<cnt-1)
                  
[
                     
while [(and not (and 
                        
l.=="
                        
l.(j+1) =="
                        
j<cnt-1)]
                     
[
   
;                     (type l.j)
                        
if l.j=="
                        
[   linenr=linenr+1
                        
]
                        
j=j+1
                     
]
                  
]
                  
if title != []
                  
[;   title=lput l.j title
                     
sections=fput title sections
                     
esectab.exnr=title
                  
]
                  
i=j-1
               
][
;               (type w)
               
]
            
]
         
][
;            (type w)
         
]
         
if w=="
         
[   linenr=linenr+1
         
]
      
]
      
examples.exnr=example
      
esections=reverse sections
      
elinenr=linenr

      
openWrite out
      
setWriter out
      
l=ld
      
cnt=count l
      
sections=[]
      
linenr=1
      
exnr=0
      
exlnr=1
      
example=[]
      
for [cnt]
      
[   w=l.i
         
ifelse cnt-3
         
[   ifelse (and w=="
            
l.(i+1)=="\    l.(i+2)=="\   )
            
[   i=i+3
               
(print)
               
linenr=linenr+1
;               (type "#\   \   )
               
ifelse (count example) >= exlnr
               
[   (type example.exlnr)
               
][
;                  (type "######\  exnr)
               
]
               
while [and not (and l.== "
                      
(first l.(i+1)) !="\    
                      
(first l.(i+2)) !="\    )
                  
i<cnt-2]
               
[   w=l.i
                  
i=i+1
               
]
               
i=i-1
               
exlnr=exlnr+1
            
][
               
ifelse (and w=="
                      
l.(i+1)  !="\    
               
(first l.(i+1)) !="= 
               
(first l.(i+1)) !="-
               
(first l.(i+2)) !="\    )
               
[   exnr=exnr+1
                  
example=examples.exnr
                  
exlnr=1
                  
(type w)
                  
(print)
                  
linenr=linenr+1
                  
j=i+2
                  
ifelse (and l.!="
                     
[(first l.(j+1)) !="\   j<cnt-1)
                  
[   title="   ;(word linenr "\   )
                  
][   title=[]
                  
]
                  
while [(and l.!= "
                     
j<cnt-1)]
                  
[   title=lput l.j title
                     
(type l.j)
                     
j=j+1
                  
]
                  
if (and 
                     
(first l.(j+1)) != "-
                     
(first l.(j+1)) != "=
                     
j<cnt-1)
                  
[
                     
while [(and not (and 
                        
l.=="
                        
l.(j+1) =="
                     
j<cnt-1)]
                     
[   (type l.j)
                        
if l.j=="
                        
[   linenr=linenr+1
                        
]
                        
j=j+1
                     
]
                  
]
                  
if title != []
                  
[;   title=lput l.j title
                     
sections=fput title sections
                  
]
                  
i=j-1
               
][
                  
(type w)
               
]
            
]
         
][
            
(type w)
         
]
         
if w=="
         
[   linenr=linenr+1
         
]
      
]
      
sections=reverse sections
      
setWriter []
      
close out
      
(foreach sections esections 
      
[   (type "[ ?1 "] "[ ?2 "]) (print)
      
])
   
end
end