FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index mod_harbour Creating Language Switcher
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Creating Language Switcher
Posted: Tue Jul 20, 2021 09:11 AM
Hello friends,
This is how I change language in our landing page.
Best regards,
Otto












Reading from DBF-file



Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: Creating Language Switcher
Posted: Mon Jul 26, 2021 08:26 AM
Dear team,

instead of
location.href='https://winhotel.space/lp/demo/landingpage1.prg?sprache=en'
I would need the landingpage1.prg part as a variable, because I would like the switcher to work on landinpage1.prg, landingpage2,prg, landingpage3.prg and so on....

how could this be done?

thank you very much and kind regards
Ruth
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Creating Language Switcher
Posted: Mon Jul 26, 2021 10:25 AM
Dear Ruth,
add these lines to the main function

Code (fw): Select all Collapse
 local cEnv := ""
  local cPrgWithPath := ""
  local cProgram := ""

  // <!-- m --><a class="postlink" href="https://github.com/FiveTechSoft/mod_harbour/wiki/Functions-provided-by-the-mod-Harbour">https://github.com/FiveTechSoft/mod_har ... od-Harbour</a><!-- m -->
   cEnv := HB_GETENV( 'PRGPATH' )                        //  Obtains a system environmental setting
   cPrgWithPath :=  AP_FileName()                        // returns the filename.prg provided to Apache by the client inclusive path   
   cProgram := '"'+STRTRAN( cPrgWithPath, cEnv + "/" )+'"'

pass cProgram to the HTML section
Code (fw): Select all Collapse
 TEMPLATE PARAMS hIni, hHash_DBF, cRecords,  cApp, cImgPath, cProgram

and change the displaylanguage function like this.

Code (fw): Select all Collapse
 function displayLang(cLang) {
      cprg = <?prg return  cProgram  ?>;
   
      if (cLang=='en') {
         
         location.href= cprg + '?sprache=en'
      } else if (cLang=='it') {
         
         location.href= cprg + '?sprache=it'
      } else {
         
         location.href= cprg  
      }

}


Best regards,
Otto
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: Creating Language Switcher
Posted: Mon Jul 26, 2021 01:21 PM

...thanks a lot.
this i perfect. Maybe you could explain to me what a "system environmental setting" and the "filename.prg" are?

HB_GETENV( 'PRGPATH' ) // Obtains a system environmental setting
AP_FileName() // returns the filename.prg provided to Apache by the client inclusive path

Kind regards and thanks again :-)

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Creating Language Switcher
Posted: Mon Jul 26, 2021 03:11 PM
Dear Ruth,
Best regards,
Otto

Code (fw): Select all Collapse
function Main()
  local cEnv := ""
  local cPrgWithPath := ""
  local cProgram := ""

    cEnv := HB_GETENV( 'PRGPATH' )            //  Obtains a system environmental setting
    ? cEnv                     
    cPrgWithPath :=  AP_FileName()            // returns the filename.prg provided to Apache by the client inclusive path
    
    ? cPrgWithPath

    ? "STRTRAN()    search for and replace"  

    cProgram := STRTRAN( cPrgWithPath, cEnv + "/" )      
    
    ? cProgram
 
return nil
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: Creating Language Switcher
Posted: Mon Jul 26, 2021 03:22 PM
thank you very much .... i got this now. sorry...i was looking for a filename.prg and could not find it...maybe by now you see that i am very new to all of this :-)

another question please:
why do you use cImgFile and cImgPath? And why is there no
Code (fw): Select all Collapse
 if file( cImgfile )
for landingpage2 and landingpage3?

thanks again and kind regards

Code (fw): Select all Collapse
 if lower(cApp) = "landingpage1.prg"
      cImgfile :=  hb_GetEnv( "PRGPATH" )  + "/img/logo1.svg"  
      cImgfile := STRTRAN( cImgfile,"/","\")

      if file( cImgfile ) 
         cImgPath := "./img/logo1.svg"
      endif      

      clandingpageFile := "landingpage1"

   elseif lower(cApp) = "landingpage2.prg"
      clandingpageFile := "landingpage2"

   elseif lower(cApp) = "landingpage3.prg"
      clandingpageFile := "landingpage3"
      
   endif
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: Creating Language Switcher
Posted: Mon Jul 26, 2021 03:46 PM
i post the whole code here...maybe somebody is interested.
Code (fw): Select all Collapse
REQUEST DBFCDX
REQUEST DBFFPT


static hIni  := {=>}
static hHash_DBF, cRecords

static clandingpageFile := "landingpage1"

function main
  LOCAL cStatus := ""
  LOCAL nRecords
  LOCAL cApp :=  AP_FileName() 
  local cExt := ""
  local n := 0
  local cImgPath := "./img/bergland_quadratisch.png"
  local cImgfile := ""
  local cPage := ""
  local cTMPPage := ""
  local cProgram := ""
  // <!-- m --><a class="postlink" href="https://github.com/FiveTechSoft/mod_harbour/wiki/Functions-provided-by-the-mod-Harbour">https://github.com/FiveTechSoft/mod_har ... od-Harbour</a><!-- m -->
   cEnv := HB_GETENV( 'PRGPATH' )                        //  Obtains a system environmental setting
   cPrgWithPath :=  AP_FileName()                        // returns the filename.prg provided to Apache by the client inclusive path   
   cProgram := '"'+STRTRAN( cPrgWithPath, cEnv + "/" )+'"'   


  cPage := controller( AP_Args() )

  //? cFileNoPath( cApp )
  //INI()  
  
  READINI()

  n    := hb_RAt( ".", cApp )
  cExt := left( cApp, n-1)
  
  //? "ohne cExt " + cExt 
  cExt := UPPER( substr( cApp, n + 1) )
  //? "cExt " + cExt 

  cApp := STRTRAN(cApp,"/","\")
  cApp := cFileNoPath( cApp )


   if lower(cApp) = "landingpage1.prg"
      cImgfile :=  hb_GetEnv( "PRGPATH" )  + "/img/logo1.svg"  
      cImgfile := STRTRAN( cImgfile,"/","\")

      if file( cImgfile ) 
         cImgPath := "./img/logo1.svg"
      endif      

      clandingpageFile := "landingpage1"

   elseif lower(cApp) = "landingpage2.prg"
      clandingpageFile := "landingpage2"

   elseif lower(cApp) = "landingpage3.prg"
      clandingpageFile := "landingpage3"
      
   endif      

 
 

aRelationship_DBF := {}
cTMPPage := hb_GetEnv( "PRGPATH" ) + "\data\" + clandingpageFile + ".dbf"
logging( "-->Datenbank einlesen: " + cTMPPage  + "Filter" + cPage )

hHash_DBF := {=>}  

cStatus="ready"

nRecords := 0  


use ( cTMPPage ) new ALIAS landingpage
logging( "close: " + cTMPPage   )
Close 
use ( cTMPPage ) new ALIAS landingpage

index on field->ID  TAG TmpB5Nr TO TEMP5 TEMPORARY
do while .not. eof()
  if field->ready = .T.
   if field->LANGUAGE  = cPage
      nRecords += 1
      AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->ID ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_ID" ] = ALLTRIM( field->ID )  
     
     elseif VALTYPE( field->ID ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_ID" ] = dtoc( field->ID )  
      
      elseif VALTYPE( field->ID ) = "C"  .or. VALTYPE( field->ID ) = "M" 
         if LEN( ALLTRIM( field->ID ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_ID" ] = ALLTRIM( field->ID ) 
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_ID" ] = ALLTRIM( CONVERTUMLAUTE (  field->ID  ) )
         endif
      else   
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_ID" ] = ALLTRIM( field->ID )
      endif



        AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

        if VALTYPE( field->TEXT ) = "N"
           hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TEXT" ] = ALLTRIM( field->TEXT)  
        
        elseif VALTYPE( field->TEXT ) = "D"
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_TEXT" ] = dtoc( field->TEXT )  
         
        
         elseif VALTYPE( field->TEXT ) = "C"  .or. VALTYPE( field->TEXT ) = "M" 
            
            if LEN( ALLTRIM( field->TEXT ) ) = 0
               hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TEXT" ] = ALLTRIM( field->TEXT ) 
            else
               hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TEXT" ] = ALLTRIM( CONVERTUMLAUTE (  field->TEXT  ) )
            endif
         else   
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TEXT" ] = ALLTRIM( field->TEXT )
           endif


           

        AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

        if VALTYPE( field->PICTURE ) = "N"
           hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_PICTURE" ] = ALLTRIM( field->PICTURE)  
        
        elseif VALTYPE( field->PICTURE ) = "D"
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_PICTURE" ] = dtoc( field->PICTURE )  
         
        
         elseif VALTYPE( field->PICTURE ) = "C"  .or. VALTYPE( field->PICTURE ) = "M" 
            
            if LEN( ALLTRIM( field->PICTURE ) ) = 0
               hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_PICTURE" ] = ALLTRIM( field->PICTURE ) 
            else
               hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_PICTURE" ] = ALLTRIM( CONVERTUMLAUTE (  field->PICTURE  ) )
            endif
         else   
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_PICTURE" ] = ALLTRIM( field->PICTURE )
        
        
           endif





   AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->CAPTION ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_CAPTION" ] = ALLTRIM( field->CAPTION )  
     
     elseif VALTYPE( field->CAPTION ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_CAPTION" ] = dtoc( field->CAPTION )  
      
     
      elseif VALTYPE( field->CAPTION ) = "C"  .or. VALTYPE( field->CAPTION ) = "M" 
         
         if LEN( ALLTRIM( field->CAPTION ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_CAPTION" ] = ALLTRIM( field->CAPTION ) 
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_CAPTION" ] = ALLTRIM( CONVERTUMLAUTE (  field->CAPTION  ) )
         endif
      else   
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_CAPTION" ] = ALLTRIM( field->CAPTION )
     
     
        endif
     AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->TITLE ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TITLE" ] = ALLTRIM( field->TITLE )  
     
     elseif VALTYPE( field->TITLE ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_TITLE" ] = dtoc( field->TITLE )  
      
     
      elseif VALTYPE( field->TITLE ) = "C"  .or. VALTYPE( field->TITLE ) = "M" 
         
         if LEN( ALLTRIM( field->TITLE ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TITLE" ] = ALLTRIM( field->TITLE ) 
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TITLE" ] = ALLTRIM( CONVERTUMLAUTE (  field->TITLE  ) )
         endif
      else   
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TITLE" ] = ALLTRIM( field->TITLE )
     
     
        endif
 AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->AWESOME ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_AWESOME" ] = ALLTRIM( field->AWESOME )  
     
     elseif VALTYPE( field->AWESOME ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_AWESOME" ] = dtoc( field->AWESOME )  
      
     
      elseif VALTYPE( field->AWESOME ) = "C"  .or. VALTYPE( field->AWESOME ) = "M" 
         
         if LEN( ALLTRIM( field->AWESOME ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_AWESOME" ] = ALLTRIM( field->AWESOME ) 
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_AWESOME" ] = ALLTRIM( CONVERTUMLAUTE (  field->AWESOME  ) )
         endif
      else   
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_AWESOME" ] = ALLTRIM( field->AWESOME )
     
     
        endif
 AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->FUNC ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_FUNC" ] = ALLTRIM( field->FUNC )  
     
     elseif VALTYPE( field->FUNC ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_FUNC" ] = dtoc( field->FUNC )  
      
     
      elseif VALTYPE( field->FUNC ) = "C"  .or. VALTYPE( field->FUNC ) = "M" 
         
         if LEN( ALLTRIM( field->FUNC ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_FUNC" ] = ALLTRIM( field->FUNC ) 
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_FUNC" ] = ALLTRIM( CONVERTUMLAUTE (  field->FUNC  ) )
         endif
      else   
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_FUNC" ] = ALLTRIM( field->FUNC )
     
     
        endif
 AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->STATUS ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_STATUS" ] = ALLTRIM( field->STATUS )  
     
     elseif VALTYPE( field->STATUS ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_STATUS" ] = dtoc( field->STATUS )  
      
     
      elseif VALTYPE( field->STATUS ) = "C"  .or. VALTYPE( field->STATUS ) = "M" 
         
         if LEN( ALLTRIM( field->STATUS ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_STATUS" ] = ALLTRIM( field->STATUS ) 
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_STATUS" ] = ALLTRIM( CONVERTUMLAUTE (  field->STATUS  ) )
         endif
      else   
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_STATUS" ] = ALLTRIM( field->STATUS )
     
     
        endif
 AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->COLOR ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_COLOR" ] = ALLTRIM( field->COLOR )  
     
     elseif VALTYPE( field->COLOR ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_COLOR" ] = dtoc( field->COLOR )  
      
     
      elseif VALTYPE( field->COLOR ) = "C"  .or. VALTYPE( field->COLOR ) = "M" 
         
         if LEN( ALLTRIM( field->COLOR ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_COLOR" ] = ALLTRIM( field->COLOR ) 
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_COLOR" ] = ALLTRIM( CONVERTUMLAUTE (  field->COLOR  ) )
         endif
      else   
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_COLOR" ] = ALLTRIM( field->COLOR )
     
     
        endif


        AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

        if VALTYPE( field->TEXT_COLOR ) = "N"
           hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TEXT_COLOR" ] = ALLTRIM( field->TEXT_COLOR )  
        
        elseif VALTYPE( field->TEXT_COLOR ) = "D"
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_TEXT_COLOR" ] = dtoc( field->TEXT_COLOR )  
         
        
         elseif VALTYPE( field->TEXT_COLOR ) = "C"  .or. VALTYPE( field->TEXT_COLOR ) = "M" 
            
            if LEN( ALLTRIM( field->TEXT_COLOR ) ) = 0
               hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TEXT_COLOR" ] = ALLTRIM( field->TEXT_COLOR ) 
            else
               hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TEXT_COLOR" ] = ALLTRIM( CONVERTUMLAUTE (  field->TEXT_COLOR  ) )
            endif
         else   
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_TEXT_COLOR" ] = ALLTRIM( field->TEXT_COLOR )
        
        
           endif



           AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

           if VALTYPE( field->BTN_COLOR ) = "N"
              hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_BTN_COLOR" ] = ALLTRIM( field->BTN_COLOR )  
           
           elseif VALTYPE( field->BTN_COLOR ) = "D"
               hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_BTN_COLOR" ] = dtoc( field->BTN_COLOR )  
            
           
            elseif VALTYPE( field->BTN_COLOR ) = "C"  .or. VALTYPE( field->BTN_COLOR ) = "M" 
               
               if LEN( ALLTRIM( field->BTN_COLOR ) ) = 0
                  hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_BTN_COLOR" ] = ALLTRIM( field->BTN_COLOR ) 
               else
                  hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_BTN_COLOR" ] = ALLTRIM( CONVERTUMLAUTE (  field->BTN_COLOR  ) )
               endif
            else   
               hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_BTN_COLOR" ] = ALLTRIM( field->BTN_COLOR )
           
           
              endif


              AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

              if VALTYPE( field->BG_COLOR ) = "N"
                 hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_BG_COLOR" ] = ALLTRIM( field->BG_COLOR )  
              
              elseif VALTYPE( field->BG_COLOR ) = "D"
                  hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_BG_COLOR" ] = dtoc( field->BG_COLOR )  
               
              
               elseif VALTYPE( field->BG_COLOR ) = "C"  .or. VALTYPE( field->BG_COLOR ) = "M" 
                  
                  if LEN( ALLTRIM( field->BG_COLOR ) ) = 0
                     hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_BG_COLOR" ] = ALLTRIM( field->BG_COLOR ) 
                  else
                     hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_BG_COLOR" ] = ALLTRIM( CONVERTUMLAUTE (  field->BG_COLOR  ) )
                  endif
               else   
                  hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_BG_COLOR" ] = ALLTRIM( field->BG_COLOR )
              
              
                 endif
   


 AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->FARBE ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_FARBE" ] = ALLTRIM( field->FARBE )  
     
     elseif VALTYPE( field->FARBE ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_FARBE" ] = dtoc( field->FARBE )  
      
     
      elseif VALTYPE( field->FARBE ) = "C"  .or. VALTYPE( field->FARBE ) = "M" 
         
         if LEN( ALLTRIM( field->FARBE ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_FARBE" ] = ALLTRIM( field->FARBE ) 
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_FARBE" ] = ALLTRIM( CONVERTUMLAUTE (  field->FARBE  ) )
         endif
      else   
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_FARBE" ] = ALLTRIM( field->FARBE )
     
     
        endif
 AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->LANGUAGE ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_LANGUAGE" ] = ALLTRIM( field->LANGUAGE )  
     
     elseif VALTYPE( field->LANGUAGE ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_LANGUAGE" ] = dtoc( field->LANGUAGE )  
      
     
      elseif VALTYPE( field->LANGUAGE ) = "C"  .or. VALTYPE( field->LANGUAGE ) = "M" 
         
         if LEN( ALLTRIM( field->LANGUAGE ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_LANGUAGE" ] = ALLTRIM( field->LANGUAGE ) 
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_LANGUAGE" ] = ALLTRIM( CONVERTUMLAUTE (  field->LANGUAGE  ) )
         endif
      else   
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_LANGUAGE" ] = ALLTRIM( field->LANGUAGE )
     
     
        endif
      endif
      endif  
  select landingpage
  skip
enddo
select landingpage
use


logging( "<--Datenbank eingelesen: " + cTMPPage )
  cRecords := str(nRecords)
  
  TEMPLATE PARAMS hIni, hHash_DBF, cRecords,  cApp, cImgPath, cProgram  
  
  <!DOCTYPE html>
  <html>
  
<!-- HARBOURINO HEAD -->
<head>
  <link rel="manifest" href="manifest.json">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate, private,  max-age=0, no-transform">
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Expires" content="0">
  

  <script>  
  var oIni=<?prg return hb_jsonEncode( hINI )?>;
 
   document.write( "<title>" +  oIni[ 'name' ] + " APP</title>");
  </script>  


  
  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  
  <!-- Font Awesome JS -->
  <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.15.3/css/all.css" integrity="sha384-iKbFRxucmOHIcpWdX9NTZ5WETOPm0Goy0WmfyNcl52qSYtc2Buk0NCe6jU1sWWNB" crossorigin="anonymous">
  
  
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"> 
  
  
  
  <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
  <script src="dist/js/fontawesome-iconpicker.js"></script> 
  
  
  
  <body>
  
 
<!-- navbar start -->
<header>

   <script>
document.write('<nav class="navbar navbar-expand-sm fixed-top '+ oIni["navColor"] +'" style="' + oIni["navStyle"] + '">');
</script>
  
   <a class="navbar-brand" href="#">
   
<script>
 var cImgPath = <?prg return hb_jsonEncode(  cImgPath ) ?>
     document.write( '<img src= "' + cImgPath + '"  style=" max-width::200px;height:100px;" />' )

</script>
        
   </a>
   <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
    <span class="navbar-toggler-icon"></span>
  </button>
   <div class="collapse navbar-collapse" id="collapsibleNavbar">
  <ul class="navbar-nav">
   
    
    <script>
      document.write( '<li class="nav-item"><a class="nav-link" href="'+  oIni[ "Telefonnummer" ] +'">CALL US</a></li>');
      document.write( '<li class="nav-item"><a class="nav-link" href="'+  oIni[ "Facebook" ] +'">FACEBOOK</a></li>');
    
     </script>
     <li class="nav-item"><a class="nav-link" onclick="displayLang(this.id)" id="de"><i class="far fa-flag"></i> deutsch</a></li>
     <li class="nav-item"><a class="nav-link" onclick="displayLang(this.id)" id="en"><i class="far fa-flag"></i> english</a></li>
     <li class="nav-item"><a class="nav-link" onclick="displayLang(this.id)" id="it"><i class="far fa-flag"></i> italiano</a></li>
    
     

  </ul>
  </div>
 
   </nav>
</header>

<script>

   function displayLang(cLang) {
      cprg = <?prg return  cProgram  ?>;
   
      if (cLang=='en') {
         
         location.href= cprg + '?sprache=en'
      } else if (cLang=='it') {
         
         location.href= cprg + '?sprache=it'
      } else {
         
         location.href= cprg  
      }

}
</script>
<!-- navbar end -->

 
   <div class="container-fluid" style="margin-top:140px">  
          
  
<!-- start cards -->
<div class="card-columns">

<script>  
  var object=<?prg return hb_jsonEncode( hHash_DBF )?>;
  var cKeyneu="";
  var nRecords=<?prg return  cRecords  ?>+1;
  var i;
  var cColor="btn-info";
  var cI;
  var cApp =  <?prg return hb_jsonEncode(  cAPP ) ?>

  for (i = 1; i < nRecords; i++) {
    
    cI=  i.toString();
    cCAPTION = object["REC_" + i.toString() + "_CAPTION"]; 
    cTITLE = object["REC_" + i.toString() + "_TITLE" ]; 
    cAWESOME = object["REC_" + i.toString() + "_AWESOME" ]; 
    cFARBE = object["REC_" + i.toString() + "_FARBE" ]; 
    cColor = object["REC_" + i.toString() + "_COLOR" ]; 
    cSprache= object["REC_" + i.toString() + "_LANGUAGE" ]; 
    cLink =  object["REC_" + i.toString() + "_FUNC" ]; 
    cID = object["REC_" + i.toString() + "_ID" ]; 
    cTEXT = object["REC_" + i.toString() + "_TEXT" ]; 
    cPICTURE = object["REC_" + i.toString() + "_PICTURE" ]; 
    cTextColor = object["REC_" + i.toString() + "_TEXT_COLOR" ]; 
    cBgColor = object["REC_" + i.toString() + "_BG_COLOR" ]; 
    cBtnColor = object["REC_" + i.toString() + "_BTN_COLOR" ]; 

   

    <!-- start card-->

  //  document.getElementsByClassName("nav-link").addEventListener("click", displayDate); 
    //function displayDate() {
      //document.getElementById("demo").innerHTML = this.id;
    //}
    

    document.write( ' <div class="card ' + ' ' + ' text-center ' + ' ' + '" style="background-color:' + cBgColor + '; color:'+cTextColor+'"> ');
    <!--start card-img-top-->
    document.write(cPICTURE);  
    <!-- ende card-img-top-->
    
    <!-- start card body-->
    document.write('<div class="card-body">');  
    
      document.write(' <h4 class="card-title font-weight-bold"><i class="' + cAWESOME + '"></i>&nbsp;' + cCAPTION + '</h4>');  
      document.write('<p class="text-uppercase small">' + cTITLE + '</p>');  
      document.write('<p class="card-text">' + cTEXT + '</p>');  
    document.write('</div>'); 
    <!-- ende card body-->
    <!-- start card footer-->
    document.write(' <div class="card-footer">');  
    document.write('<button type="button" class="btn stretched-link btn-lg " style="color:' + cTextColor + '" onMouseOver="buttonMouseOver(this.id, object)" onMouseOut="buttonMouseOut(this.id, object)" onclick="myfunction1( this.id, object )" ID=' + cI + ' >');
    document.write('HIER KLICKEN</button>');

    document.write(' </div>');  
    <!-- ende card footer-->
    document.write(' </div>');
    
    
   
    
        
        }
    
      
  function myfunction1(clickId, object) {
   
     window.open( object["REC_" + clickId + "_FUNC" ] );
    }


 function buttonMouseOver(mouseId, object) {

       document.getElementById(mouseId).style.color = object["REC_"+mouseId+"_BG_COLOR"]; 
       document.getElementById(mouseId).style.background = object["REC_"+mouseId+"_TEXT_COLOR"]; 
  

  } 

  function buttonMouseOut(mouseId, object) {

       document.getElementById(mouseId).style.color = object["REC_"+mouseId+"_TEXT_COLOR"]; 
       document.getElementById(mouseId).style.background = object["REC_"+mouseId+"_BG_COLOR"]; 
  

  }  
      
</script>
     </div>
     <!-- ende card-->

 



  
   <footer>
   <div class="container-fluid mt-5 p-3 border border-secondary text-dark">
      <div class="container text-center"><a href="https://winhotel.space/winhotelat/" title="WinHotel&reg;" target="_blank" class="w3-hover-text-blue text-dark" style="text-decoration:none">
         <b>WinHotel<sup>&reg;</sup></b></a> x 
         <script>  
            document.write( oIni[ 'name' ] );
            </script>
         </div></div> 

  </footer>
  
  
  
 
  
  
  </div>
  </body>
  
  </html>

ENDTEXT

return
//----------------------------------------------------------------------------//


//-- HARBOURINO   --//

INIT PROCEDURE PrgInit
  
  SET CENTURY ON
  SET EPOCH TO YEAR(DATE())-98
  
  SET DELETED ON
  SET EXCLUSIVE OFF
  
  REQUEST HB_Lang_DE
  
  HB_LangSelect("DE")
  
  SET DATE TO GERMAN
  
  rddsetdefault( "DBFCDX" )
  
  EXTERN DESCEND
  
RETURN

function convertUmlaute( cVData )
    local ctest := ""
    local I := 0
    
    
  //  for I := 1 to len(cVData)
    
   // ? ( cVData + CRLF + substr(cVData,I,1) + "  #  "+ str( ASC ( substr(cVData,I,1)) ))
    
    
 //   next
    
    
    cVData  :=  STRTRAN(cVData, chr(228), "&auml;"   )
    cVData  :=  STRTRAN(cVData, chr(132), "&auml;"   )
    
    
    cVData  :=  STRTRAN(cVData, chr(246), "&ouml;"   )
    cVData  :=  STRTRAN(cVData, chr(148), "&ouml;"   )
    
    cVData  :=  STRTRAN(cVData, chr(252), "&uuml;"   )
    cVData  :=  STRTRAN(cVData, chr(129), "&uuml;"   )
    
    cVData  :=  STRTRAN(cVData, chr(196), "&Auml;"   )
    cVData  :=  STRTRAN(cVData, chr(142), "&Auml;"   )
    
    
    cVData  :=  STRTRAN(cVData, chr(214), "&Ouml;"   )
    cVData  :=  STRTRAN(cVData, chr(153), "&Ouml;"   )
    
    cVData  :=  STRTRAN(cVData, chr(220), "&Üuml;" )
    cVData  :=  STRTRAN(cVData, chr(154), "&Üuml;" )
    
    cVData  :=  STRTRAN(cVData, chr(223), "&szlig;" )
    cVData  :=  STRTRAN(cVData, chr(225), "&szlig;" )

    cVData  :=  STRTRAN(cVData, chr(224), "&agrave;" )

    cVData  :=  STRTRAN(cVData, chr(225), "&aacute;" )
  
    
    /*
    
    
    small sharp s ("s-zet")     ß  alt + 225   &szlig;
    small a umlaut  ä  alt + 132   &auml;
    small o umlaut  ö  alt + 148   &ouml;
    small u umlaut  ü  alt + 129   &uuml;
    capital A umlaut    Ä  alt + 142   &Auml;
    capital O umlaut    Ö  alt + 153   &Ouml;
    capital U umlaut    Ü  alt + 154   &Uuml;
    
    
    Zeichen Beschreibung    URL HTML-Entität   Unicode (HTML)
    Ä  Lateinischer Großbuchstabe Umlaut A    %C3%84  &Auml;  Ä  &#xC4;
    Ö  Lateinischer Großbuchstabe Umlaut O    %C3%96  &Ouml;  Ö  &#xD6;
    Ü  Lateinischer Großbuchstabe Umlaut U    %C3%9C  &Uuml;  Ü  &#xDC;
    ß  Lateinischer Kleinbuchstabe Scharfes s  %C3%9F  &szlig; ß  &#xDF;
    ä  Lateinischer Kleinbuchstabe Umlaut a    %C3%A4  &auml;  ä  &#xE4;
    ö  Lateinischer Kleinbuchstabe Umlaut o    %C3%B6  &ouml;  ö  &#xF6;
    ü  Lateinischer Kleinbuchstabe Umlaut u    %C3%BC  &uuml;  ü  &#xFC;
    ẞ Lateinischer Großbuchstabe Scharfes S[1]   %E1%BA%9E       ẞ &#x1E9E;
    HTML-eigene und Wikipedia-spezifische Zeichen
    */
    
return(cVData)


function cFileNoPath( cPathMask )  // returns just the filename no path

   local n := RAt( "\", cPathMask )

return If( n > 0 .and. n < Len( cPathMask ),;
          Right( cPathMask, Len( cPathMask ) - n ),;
          If( ( n := At( ":", cPathMask ) ) > 0,;
          Right( cPathMask, Len( cPathMask ) - n ),;
          cPathMask ) )

//---------------------------------------------------------------------------//

function READINI()

   local cIni      :=  hb_GetEnv( "PRGPATH" ) + '/myini.txt'
   
   hIni := hb_jsondecode( memoread( cIni ))
  
retu nil


function INI()

   local cIni      :=  hb_GetEnv( "PRGPATH" ) + '/myini.txt'
   
  
   hIni[ 'name' ] := 'Charly'
   
   hIni[ 'Facebook' ] := 'Facebook'

   hIni[ 'Telefonnummer' ] := 'Telefonnummer'
   
   hIni[ 'Telefonnummer' ] := 'Telefonnummer'
   
   //  Save your ini
   memowrit( cIni, hb_jsonencode( hIni ) )
  
   //  Read your ini
   h := hb_jsondecode( memoread( cIni ))
  
   ? hIni[ 'name' ]  
   
   ? hIni[ 'Facebook' ]  

   ? hIni[ 'Telefonnummer' ] 
   
   ? hIni[ 'Telefonnummer' ]  
   

retu nil

//----------------------------------------------------------------------------//
function Controller( cRequest )
   local aRequest
    
    logging( cRequest )
    
    if "=" $ cRequest
       aRequest = hb_aTokens( cRequest, "=" )
       cRequest = aRequest[ 2 ]
       logging( cRequest ) 
       if val(cRequest) > 0
         lDefault := .f.    // content from database
       endif  
   else
      cRequest = "de"
   endif    
  
  return( cRequest )
  
  //----------------------------------------------------------------------------//

  function logging( cText )
   local cLog
   local cPRGPath := STRTRAN( HB_GETENV( 'PRGPATH' ), "/", "\" )
   
   cLog := memoread( cPRGPath+ "\prg.log")
   cLog   +=  dtos(date())+time()+ " line: " + ALLTRIM( str(procline(1)) ) + "   : "  + cText+ CRLF
   MEMOWRIT( cPRGPath+ "\prg.log" , cLog, .f. ) 
return nil

//----------------------------------------------------------------//
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Creating Language Switcher
Posted: Mon Jul 26, 2021 05:55 PM

Dear Ruth,

many thanks for sharing it :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion